Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
0
 def setUpClass(cls):
     nodelist = NodeList()
     hv = Hive(node=nodelist.get_nodes(),
               nobroadcast=True,
               num_retries=10,
               expiration=120)
     set_shared_hive_instance(hv)
Beispiel #4
0
def profiling(name_list):
    hv = Hive()
    set_shared_hive_instance(hv)
    del hv
    print("start")
    for name in name_list:
        print("account: %s" % (name))
        acc = Account(name)
        max_index = acc.virtual_op_count()
        print(max_index)
        stopTime = datetime(2018, 4, 22, 0, 0, 0)
        hist_elem = None
        for h in acc.history_reverse(stop=stopTime):
            hist_elem = h
        print(hist_elem)
    print("blockchain")
    blockchain_object = Blockchain()
    current_num = blockchain_object.get_current_block_num()
    startBlockNumber = current_num - 20
    endBlockNumber = current_num
    block_elem = None
    for o in blockchain_object.stream(start=startBlockNumber,
                                      stop=endBlockNumber):
        print("block %d" % (o["block_num"]))
        block_elem = o
    print(block_elem)
Beispiel #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)
Beispiel #6
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)
Beispiel #7
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")
Beispiel #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,
                    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")
Beispiel #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,
                       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")
Beispiel #10
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)
Beispiel #11
0
 def test_blockchain(self, node_param):
     if node_param == "instance":
         set_shared_hive_instance(self.bts)
         o = Blockchain()
         self.assertIn(o.hive.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Blockchain(hive_instance=Hive(
                 node="https://abc.d", autoconnect=False, num_retries=1))
     else:
         set_shared_hive_instance(
             Hive(node="https://abc.d", autoconnect=False, num_retries=1))
         hv = self.bts
         o = Blockchain(hive_instance=hv)
         self.assertIn(o.hive.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Blockchain()
Beispiel #12
0
 def test_amount(self, node_param):
     if node_param == "instance":
         hv = Hive(node="https://abc.d", autoconnect=False, num_retries=1)
         set_shared_hive_instance(self.bts)
         o = Amount("1 HBD")
         self.assertIn(o.hive.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Amount("1 HBD", hive_instance=hv)
     else:
         set_shared_hive_instance(
             Hive(node="https://abc.d", autoconnect=False, num_retries=1))
         hv = self.bts
         o = Amount("1 HBD", hive_instance=hv)
         self.assertIn(o.hive.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Amount("1 HBD")
Beispiel #13
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)
Beispiel #14
0
 def test_transactionbuilder(self, node_param):
     if node_param == "instance":
         set_shared_hive_instance(self.bts)
         o = TransactionBuilder()
         self.assertIn(o.hive.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             o = TransactionBuilder(hive_instance=Hive(
                 node="https://abc.d", autoconnect=False, num_retries=1))
             o.hive.get_config()
     else:
         set_shared_hive_instance(
             Hive(node="https://abc.d", autoconnect=False, num_retries=1))
         hv = self.bts
         o = TransactionBuilder(hive_instance=hv)
         self.assertIn(o.hive.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             o = TransactionBuilder()
             o.hive.get_config()
Beispiel #15
0
    def setUpClass(cls):
        cls.nodelist = NodeList()
        cls.nodelist.update_nodes(hive_instance=Hive(
            node=cls.nodelist.get_nodes(
                exclude_limited=False), num_retries=10))
        hv = Hive(node=cls.nodelist.get_nodes())
        hv.config.refreshBackup()
        hv.set_default_nodes(["xyz"])
        del hv

        cls.urls = cls.nodelist.get_nodes(exclude_limited=True)
        cls.bts = Hive(node=cls.urls, nobroadcast=True, num_retries=10)
        set_shared_hive_instance(cls.bts)
        acc = Account("bhive.app", hive_instance=cls.bts)
        comment = acc.get_blog(limit=20)[-1]
        cls.authorperm = comment.authorperm
        votes = acc.get_account_votes()
        last_vote = votes[-1]
        cls.authorpermvoter = '@' + last_vote['authorperm'] + '|' + acc["name"]
Beispiel #16
0
 def test_account(self, node_param):
     if node_param == "instance":
         set_shared_hive_instance(self.bts)
         acc = Account("test")
         self.assertIn(acc.hive.rpc.url, self.urls)
         self.assertIn(acc["balance"].hive.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Account("test",
                     hive_instance=Hive(node="https://abc.d",
                                        autoconnect=False,
                                        num_retries=1))
     else:
         set_shared_hive_instance(
             Hive(node="https://abc.d", autoconnect=False, num_retries=1))
         hv = self.bts
         acc = Account("test", hive_instance=hv)
         self.assertIn(acc.hive.rpc.url, self.urls)
         self.assertIn(acc["balance"].hive.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Account("test")
    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
Beispiel #18
0
 def test_hive(self, node_param):
     if node_param == "instance":
         set_shared_hive_instance(self.bts)
         o = Hive(node=self.urls)
         o.get_config()
         self.assertIn(o.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             hv = Hive(node="https://abc.d",
                       autoconnect=False,
                       num_retries=1)
             hv.get_config()
     else:
         set_shared_hive_instance(
             Hive(node="https://abc.d", autoconnect=False, num_retries=1))
         hv = self.bts
         o = hv
         o.get_config()
         self.assertIn(o.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             hv = shared_hive_instance()
             hv.get_config()
    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)
Beispiel #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")
Beispiel #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")
Beispiel #22
0
        hv = None
    acc_dict = {}
    for name in name_list:
        acc = Account(name, hive_instance=hv)
        acc_dict[name] = acc
        if clear_acc_cache:
            acc.clear_cache()
        acc_dict = {}
    if clear_all_cache:
        clear_cache()
    if not shared_instance:
        del hv.rpc


if __name__ == "__main__":
    hv = Hive()
    print("Shared instance: " + str(hv))
    set_shared_hive_instance(hv)
    b = Blockchain()
    account_list = []
    for a in b.get_all_accounts(limit=500):
        account_list.append(a)
    shared_instance = False
    clear_acc_cache = False
    clear_all_cache = False
    node = "https://api.hive.blog"
    n = 3
    for i in range(1, n + 1):
        print("%d of %d" % (i, n))
        profiling(node, account_list, shared_instance=shared_instance, clear_acc_cache=clear_acc_cache, clear_all_cache=clear_all_cache)
Beispiel #23
0
 def test_config(self):
     set_shared_config({"node": self.urls})
     set_shared_hive_instance(None)
     o = shared_hive_instance()
     self.assertIn(o.rpc.url, self.urls)