Exemple #1
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
        cls.bts = Hive(node=nodelist.get_nodes(exclude_limited=True),
                       nobroadcast=True,
                       keys={"active": wif},
                       num_retries=10)
        # from getpass import getpass
        # self.bts.wallet.unlock(getpass())
        set_shared_hive_instance(cls.bts)
        cls.bts.set_default_account("test")

        acc = Account("bhive.app", hive_instance=cls.bts)
        n_votes = 0
        index = 0
        while n_votes == 0:
            comment = acc.get_feed(limit=30)[::-1][index]
            votes = comment.get_votes()
            n_votes = len(votes)
            index += 1

        last_vote = votes[0]

        cls.authorpermvoter = construct_authorpermvoter(
            last_vote['author'], last_vote['permlink'], last_vote["voter"])
        [author, permlink,
         voter] = resolve_authorpermvoter(cls.authorpermvoter)
        cls.author = author
        cls.permlink = permlink
        cls.voter = voter
        cls.authorperm = construct_authorperm(author, permlink)
Exemple #2
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
        cls.node_list = nodelist.get_nodes(exclude_limited=True)

        # hv = shared_hive_instance()
        # hv.config.refreshBackup()
        runner = CliRunner()
        result = runner.invoke(cli,
                               ['-o', 'set', 'default_vote_weight', '100'])
        if result.exit_code != 0:
            raise AssertionError(str(result))
        result = runner.invoke(cli, ['-o', 'set', 'default_account', 'bhive'])
        if result.exit_code != 0:
            raise AssertionError(str(result))
        result = runner.invoke(cli, ['-o', 'set', 'nodes', str(cls.node_list)])
        if result.exit_code != 0:
            raise AssertionError(str(result))
        result = runner.invoke(cli, ['createwallet', '--wipe'],
                               input="test\ntest\n")
        if result.exit_code != 0:
            raise AssertionError(str(result))
        result = runner.invoke(cli, ['addkey'], input="test\n" + wif + "\n")
        if result.exit_code != 0:
            raise AssertionError(str(result))
        result = runner.invoke(cli, ['addkey'],
                               input="test\n" + posting_key + "\n")
        if result.exit_code != 0:
            raise AssertionError(str(result))
        result = runner.invoke(cli, ['addkey'],
                               input="test\n" + memo_key + "\n")
        if result.exit_code != 0:
            raise AssertionError(str(result))
Exemple #3
0
    def setUpClass(cls):
        hv = shared_hive_instance()
        hv.config.refreshBackup()
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))

        cls.hv = Hive(
            node=nodelist.get_nodes(exclude_limited=True),
            nobroadcast=True,
            # We want to bundle many operations into a single transaction
            bundle=True,
            num_retries=10
            # Overwrite wallet to use this list of wifs only
        )

        cls.hv.set_default_account("test")
        set_shared_hive_instance(cls.hv)
        # self.hv.newWallet("TestingOneTwoThree")

        cls.wallet = Wallet(hive_instance=cls.hv)
        cls.wallet.wipe(True)
        cls.wallet.newWallet(pwd="TestingOneTwoThree")
        cls.wallet.unlock(pwd="TestingOneTwoThree")
        cls.wallet.addPrivateKey(wif)
Exemple #4
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
        node_list = nodelist.get_nodes(exclude_limited=True)

        cls.bts = Hive(node=node_list,
                       use_condenser=True,
                       nobroadcast=True,
                       unsigned=True,
                       keys={"active": wif},
                       num_retries=10)
        cls.hiveio = Hive(node="https://api.hive.blog",
                          nobroadcast=True,
                          unsigned=True,
                          keys={"active": wif},
                          num_retries=10)
        acc = Account("bhive.app", hive_instance=cls.bts)
        comment = acc.get_feed(limit=20)[-1]
        cls.authorperm = comment.authorperm
        [author, permlink] = resolve_authorperm(cls.authorperm)
        cls.author = author
        cls.permlink = permlink
        cls.category = comment.category
        cls.title = comment.title
Exemple #5
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(hive_instance=Hive(
         node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
     hive = Hive(node=nodelist.get_nodes(exclude_limited=True),
                 nobroadcast=True,
                 num_retries=10)
     set_shared_hive_instance(hive)
Exemple #6
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(node=nodelist.get_nodes(
            normal=True, appbase=True),
                                                 num_retries=10))
        hv = Hive(node=nodelist.get_nodes())

        self.ws = HiveWebsocket(urls=hv.rpc.nodes, num_retries=10)
Exemple #7
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(hive_instance=Hive(
         node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
     cls.appbase = Hive(
         node=nodelist.get_nodes(exclude_limited=True),
         nobroadcast=True,
         bundle=False,
         # Overwrite wallet to use this list of wifs only
         keys={"active": wif},
         num_retries=10)
Exemple #8
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
        cls.bts = Hive(node=nodelist.get_nodes(exclude_limited=True),
                       nobroadcast=True,
                       unsigned=True,
                       data_refresh_time_seconds=900,
                       num_retries=10)

        cls.account = Account("test", full=True, hive_instance=cls.bts)
Exemple #9
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(hive_instance=Hive(
         node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
     cls.bts = Hive(node=nodelist.get_nodes(exclude_limited=True),
                    nobroadcast=True,
                    num_retries=10)
     cls.hiveio = Hive(node="https://api.hive.blog",
                       nobroadcast=True,
                       num_retries=10)
     set_shared_hive_instance(cls.bts)
Exemple #10
0
    def test_default_connection(self):
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))

        b2 = Hive(
            node=nodelist.get_nodes(exclude_limited=True),
            nobroadcast=True,
        )
        set_shared_hive_instance(b2)
        bts = Account("bhive")
        self.assertEqual(bts.hive.prefix, "STM")
Exemple #11
0
    def test_hv1hv2(self):
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
        b1 = Hive(node="https://api.hive.blog",
                  nobroadcast=True,
                  num_retries=10)
        node_list = nodelist.get_nodes(exclude_limited=True)

        b2 = Hive(node=node_list, nobroadcast=True, num_retries=10)

        self.assertNotEqual(b1.rpc.url, b2.rpc.url)
Exemple #12
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(hive_instance=Hive(
         node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
     cls.bts = Hive(node=nodelist.get_nodes(exclude_limited=True),
                    nobroadcast=True,
                    keys={"active": wif},
                    num_retries=10)
     cls.test_block_id = 19273700
     # from getpass import getpass
     # self.bts.wallet.unlock(getpass())
     set_shared_hive_instance(cls.bts)
     cls.bts.set_default_account("test")
Exemple #13
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
        cls.bts = Hive(node=nodelist.get_nodes(exclude_limited=True),
                       nobroadcast=True,
                       keys={"active": wif},
                       num_retries=10)
        b = Blockchain(hive_instance=cls.bts)
        num = b.get_current_block_num()
        cls.start = num - 25
        cls.stop = num

        # from getpass import getpass
        # self.bts.wallet.unlock(getpass())
        set_shared_hive_instance(cls.bts)
Exemple #14
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
        node_list = nodelist.get_nodes(exclude_limited=True)

        cls.bts = Hive(
            node=node_list,
            nobroadcast=True,
            bundle=False,
            unsigned=True,
            # Overwrite wallet to use this list of wifs only
            keys={"active": wif},
            num_retries=10)
        cls.account = Account("bhive.app", hive_instance=cls.bts)
        set_shared_hive_instance(cls.bts)
Exemple #15
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(hive_instance=Hive(
         node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
     cls.bts = Hive(node=nodelist.get_nodes(exclude_limited=True),
                    nobroadcast=True,
                    num_retries=10)
     cls.hiveio = Hive(node="https://api.hive.blog",
                       nobroadcast=True,
                       use_condenser=False,
                       num_retries=10)
     set_shared_hive_instance(cls.bts)
     cls.asset = Asset("HBD")
     cls.symbol = cls.asset["symbol"]
     cls.precision = cls.asset["precision"]
     cls.asset2 = Asset("HIVE")
Exemple #16
0
    def setUpClass(cls):
        nodelist = NodeList()
        # hv = shared_hive_instance()
        # hv.config.refreshBackup()
        # nodes = nodelist.get_testnet()
        cls.nodes = nodelist.get_nodes()
        cls.bts = Hive(
            node=cls.nodes,
            nobroadcast=True,
            num_retries=10,
            expiration=120,
        )
        # from getpass import getpass
        # self.bts.wallet.unlock(getpass())
        cls.bts.set_default_account("bhive")

        # Test account "bhive"
        cls.active_key = "5Jt2wTfhUt5GkZHV1HYVfkEaJ6XnY8D2iA4qjtK9nnGXAhThM3w"
        cls.posting_key = "5Jh1Gtu2j4Yi16TfhoDmg8Qj3ULcgRi7A49JXdfUUTVPkaFaRKz"
        cls.memo_key = "5KPbCuocX26aMxN9CDPdUex4wCbfw9NoT5P7UhcqgDwxXa47bit"

        # Test account "bhive1"
        cls.active_key1 = "5Jo9SinzpdAiCDLDJVwuN7K5JcusKmzFnHpEAtPoBHaC1B5RDUd"
        cls.posting_key1 = "5JGNhDXuDLusTR3nbmpWAw4dcmE8WfSM8odzqcQ6mDhJHP8YkQo"
        cls.memo_key1 = "5KA2ddfAffjfRFoe1UhQjJtKnGsBn9xcsdPQTfMt1fQuErDAkWr"

        cls.active_private_key_of_bhive4 = '5JkZZEUWrDsu3pYF7aknSo7BLJx7VfxB3SaRtQaHhsPouDYjxzi'
        cls.active_private_key_of_bhive5 = '5Hvbm9VjRbd1B3ft8Lm81csaqQudwFwPGdiRKrCmTKcomFS3Z9J'
Exemple #17
0
 def setUpClass(cls):
     nodelist = NodeList()
     hv = Hive(node=nodelist.get_nodes(),
               nobroadcast=True,
               num_retries=10,
               expiration=120)
     set_shared_hive_instance(hv)
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
        cls.bts = Hive(
            node=nodelist.get_nodes(exclude_limited=True),
            nobroadcast=True,
            timeout=30,
            num_retries=30,
        )
        # from getpass import getpass
        # self.bts.wallet.unlock(getpass())
        set_shared_hive_instance(cls.bts)
        cls.bts.set_default_account("test")

        b = Blockchain(hive_instance=cls.bts)
        num = b.get_current_block_num()
        # num = 23346630
        cls.start = num - 25
        cls.stop = num
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
        cls.bts = Hive(
            node=nodelist.get_nodes(exclude_limited=True),
            nobroadcast=True,
            num_retries=10,
            timeout=30,
            use_condenser=False,
            keys={"active": wif},
        )
        # from getpass import getpass
        # self.bts.wallet.unlock(getpass())
        set_shared_hive_instance(cls.bts)
        cls.bts.set_default_account("test")

        b = Blockchain(hive_instance=cls.bts)
        num = b.get_current_block_num()
        cls.start = num - 100
        cls.stop = num
        cls.max_batch_size = 1  # appbase does not support batch rpc calls at the momement (internal error)
Exemple #20
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(hive_instance=Hive(
            node=nodelist.get_nodes(normal=True, appbase=True), num_retries=3))
        cls.nodes = nodelist.get_nodes()
        if "https://api.hive.blog" in cls.nodes:
            cls.nodes.remove("https://api.hive.blog")
        cls.nodes_hiveit = ["https://api.hive.blog"]

        cls.appbase = Hive(node=cls.nodes,
                           nobroadcast=True,
                           keys={
                               "active": wif,
                               "owner": wif,
                               "memo": wif
                           },
                           num_retries=10)
        cls.rpc = HiveNodeRPC(urls=cls.nodes_hiveit)
        # from getpass import getpass
        # self.bts.wallet.unlock(getpass())
        set_shared_hive_instance(cls.nodes_hiveit)
        cls.appbase.set_default_account("test")
Exemple #21
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(hive_instance=Hive(
         node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
     node_list = nodelist.get_nodes(exclude_limited=True)
     cls.hv = Hive(node=node_list,
                   keys={
                       "active": wif,
                       "owner": wif,
                       "memo": wif
                   },
                   nobroadcast=True,
                   num_retries=10)
     cls.hiveio = Hive(node="https://api.hive.blog",
                       nobroadcast=True,
                       keys={
                           "active": wif,
                           "owner": wif,
                           "memo": wif
                       },
                       num_retries=10)
     set_shared_hive_instance(cls.hv)
     cls.hv.set_default_account("test")
Exemple #22
0
        sys.stdout.write("\r%s" % op['block_num'])
        opcount += 1
    now = time.time()
    total_duration = now - start_time
    print(" votes: %d, time %.2f" % (opcount, total_duration))
    return opcount, total_duration


if __name__ == "__main__":
    node_setup = 1
    threading = True
    thread_num = 8
    timeout = 10
    nodes = NodeList()
    nodes.update_nodes(weights={"block": 1})
    node_list = nodes.get_nodes()[:5]

    vote_result = []
    duration = []

    hv = Hive(node=node_list, timeout=timeout)
    b = Blockchain(hive_instance=hv)
    block = b.get_current_block()
    block.set_cache_auto_clean(False)
    opcount, total_duration = stream_votes(hv, threading, thread_num)
    print("Finished!")
    block.set_cache_auto_clean(True)
    cache_len = len(list(block._cache))
    start_time = time.time()
    block.clear_cache_from_expired_items()
    clear_duration = time.time() - start_time
Exemple #23
0
 def test_get_nodes(self):
     nodelist = NodeList()
     all_nodes = nodelist.get_nodes(exclude_limited=False, dev=True, testnet=True, testnetdev=True)
     self.assertEqual(len(nodelist) - 22, len(all_nodes))
     https_nodes = nodelist.get_nodes(wss=False)
     self.assertEqual(https_nodes[0][:5], 'https')
Exemple #24
0
from bhive.block import Block
from bhive.hive import Hive
from bhive.utils import parse_time, formatTimedelta
from bhive.nodelist import NodeList
from bhiveapi.exceptions import NumRetriesReached
log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

if __name__ == "__main__":
    how_many_minutes = 10
    how_many_virtual_op = 10000
    max_batch_size = None
    threading = False
    thread_num = 16
    nodelist = NodeList()
    nodes = nodelist.get_nodes(normal=True, appbase=True, dev=True)
    t = PrettyTable([
        "node", "10 blockchain minutes", "10000 virtual account op", "version"
    ])
    t.align = "l"
    for node in nodes:
        print("Current node:", node)
        try:
            hv = Hive(node=node, num_retries=3)
            blockchain = Blockchain(hive_instance=hv)
            account = Account("gtg", hive_instance=hv)
            virtual_op_count = account.virtual_op_count()
            blockchain_version = hv.get_blockchain_version()

            last_block_id = 19273700
            last_block = Block(last_block_id, hive_instance=hv)
Exemple #25
0
 def test_nodes_update(self):
     nodelist = NodeList()
     all_nodes = nodelist.get_nodes(exclude_limited=False, dev=True, testnet=True)
     nodelist.update_nodes(hive_instance=self.bts)
     nodes = nodelist.get_nodes()
     self.assertIn(nodes[0], all_nodes)
Exemple #26
0
        sys.stdout.write("\r%s" % op['block_num'])
        opcount += 1
    now = time.time()
    total_duration = now - start_time
    print(" votes: %d, time %.2f" % (opcount, total_duration))
    return opcount, total_duration


if __name__ == "__main__":
    node_setup = 1
    threading = True
    thread_num = 8
    timeout = 10
    nodes = NodeList()
    nodes.update_nodes(weights={"block": 1})
    node_list_wss = nodes.get_nodes(https=False)[:5]
    node_list_https = nodes.get_nodes(wss=False)[:5]

    vote_result = []
    duration = []
    hv_wss = Hive(node=node_list_wss, timeout=timeout)
    hv_https = Hive(node=node_list_https, timeout=timeout)
    print("Without threading wss")
    opcount_wot_wss, total_duration_wot_wss = stream_votes(hv_wss, False, 8)
    print("Without threading https")
    opcount_wot_https, total_duration_wot_https = stream_votes(
        hv_https, False, 8)
    if threading:
        print("\n Threading with %d threads is activated now." % thread_num)

    hv = Hive(node=node_list_wss, timeout=timeout)
Exemple #27
0
import logging

from bhive.blockchain import Blockchain
from bhive.block import Block
from bhive.hive import Hive
from bhive.utils import parse_time, formatTimedelta
from bhive.nodelist import NodeList
log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

if __name__ == "__main__":
    node_setup = 1
    how_many_hours = 1
    nodes = NodeList()
    if node_setup == 0:
        hv = Hive(node=nodes.get_nodes(normal=True, wss=True), num_retries=10)
        max_batch_size = None
        threading = False
        thread_num = 8
    elif node_setup == 1:
        hv = Hive(node=nodes.get_nodes(normal=True, wss=True), num_retries=10)
        max_batch_size = None
        threading = True
        thread_num = 16
    elif node_setup == 2:
        hv = Hive(node=nodes.get_nodes(appbase=False, https=False),
                  num_retries=10)
        max_batch_size = None
        threading = True
        thread_num = 16
    blockchain = Blockchain(hive_instance=hv)