Example #1
0
    def setUpClass(cls):
        stm = shared_dpay_instance()
        stm.config.refreshBackup()
        nodelist = NodeList()
        nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
            normal=True, appbase=True),
                                                 num_retries=10))

        cls.stm = DPay(
            node=nodelist.get_nodes(appbase=False),
            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.appbase = DPay(node=nodelist.get_nodes(normal=False, appbase=True),
                           nobroadcast=True,
                           bundle=True,
                           num_retries=10)
        cls.stm.set_default_account("test")
        set_shared_dpay_instance(cls.stm)
        # self.stm.newWallet("TestingOneTwoThree")

        cls.wallet = Wallet(dpay_instance=cls.stm)
        cls.wallet.wipe(True)
        cls.wallet.newWallet(pwd="TestingOneTwoThree")
        cls.wallet.unlock(pwd="TestingOneTwoThree")
        cls.wallet.addPrivateKey(wif)
Example #2
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10))
     cls.bts = DPay(
         node=nodelist.get_nodes(appbase=False),
         use_condenser=True,
         nobroadcast=True,
         unsigned=True,
         keys={"active": wif},
         num_retries=10
     )
     cls.appbase = DPay(
         node=nodelist.get_nodes(normal=False, appbase=True),
         nobroadcast=True,
         unsigned=True,
         keys={"active": wif},
         num_retries=10
     )
     acc = Account("holger80", dpay_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
Example #3
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(dpay_instance=DPay(
         node=nodelist.get_nodes(normal=True, appbase=True), num_retries=3))
     cls.nodes = nodelist.get_nodes(https=False, appbase=False)
     cls.nodes_https = nodelist.get_nodes(wss=False, appbase=False)
     cls.nodes_appbase = nodelist.get_nodes(normal=False)
     cls.test_list = nodelist.get_nodes()
     cls.bts = DPay(node=cls.nodes,
                    nobroadcast=True,
                    keys={
                        "active": wif,
                        "owner": wif,
                        "memo": wif
                    },
                    num_retries=10)
     cls.appbase = DPay(node=cls.nodes_appbase,
                        nobroadcast=True,
                        keys={
                            "active": wif,
                            "owner": wif,
                            "memo": wif
                        },
                        num_retries=10)
     cls.rpc = DPayNodeRPC(urls=cls.test_list)
     # from getpass import getpass
     # self.bts.wallet.unlock(getpass())
     set_shared_dpay_instance(cls.bts)
     cls.bts.set_default_account("test")
Example #4
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
         normal=True, appbase=True),
                                              num_retries=10))
     dpay = DPay(node=nodelist.get_nodes(appbase=False),
                 nobroadcast=True,
                 num_retries=10)
     set_shared_dpay_instance(dpay)
Example #5
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        nodelist = NodeList()
        nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
            normal=True, appbase=True),
                                                 num_retries=10))
        stm = DPay(node=nodelist.get_nodes(appbase=False))

        self.ws = DPayWebsocket(urls=stm.rpc.nodes, num_retries=10)
Example #6
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10))
     cls.bts = DPay(
         node=nodelist.get_nodes(),
         nobroadcast=True,
         keys=[wif],
         num_retries=10
     )
     set_shared_dpay_instance(cls.bts)
Example #7
0
    def test_stm1stm2(self):
        nodelist = NodeList()
        nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10))
        b1 = DPay(
            node=nodelist.get_testnet(testnet=True, testnetdev=False),
            nobroadcast=True,
            num_retries=10
        )

        b2 = DPay(
            node=nodelist.get_nodes(appbase=False),
            nobroadcast=True,
            num_retries=10
        )

        self.assertNotEqual(b1.rpc.url, b2.rpc.url)
Example #8
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
         normal=True, appbase=True),
                                              num_retries=10))
     cls.bts = DPay(node=nodelist.get_nodes(appbase=False),
                    nobroadcast=True,
                    num_retries=10)
     cls.appbase = DPay(node=nodelist.get_nodes(normal=False, appbase=True),
                        nobroadcast=True,
                        use_condenser=False,
                        num_retries=10)
     set_shared_dpay_instance(cls.bts)
     cls.asset = Asset("BBD")
     cls.symbol = cls.asset["symbol"]
     cls.precision = cls.asset["precision"]
     cls.asset2 = Asset("BEX")
Example #9
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
         normal=True, appbase=True),
                                              num_retries=10))
     cls.bts = DPay(node=nodelist.get_nodes(appbase=False),
                    nobroadcast=True,
                    keys={"active": wif},
                    num_retries=10)
     cls.appbase = DPay(node=nodes_appbase,
                        nobroadcast=True,
                        keys={"active": wif},
                        num_retries=10)
     cls.test_block_id = 19273700
     # from getpass import getpass
     # self.bts.wallet.unlock(getpass())
     set_shared_dpay_instance(cls.bts)
     cls.bts.set_default_account("test")
Example #10
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
         normal=True, appbase=True),
                                              num_retries=10))
     cls.bts = DPay(
         node=nodelist.get_nodes(appbase=False),
         nobroadcast=True,
         bundle=False,
         # Overwrite wallet to use this list of wifs only
         keys={"active": wif},
         num_retries=10)
     cls.appbase = DPay(
         node=nodelist.get_nodes(appbase=True, dev=True),
         nobroadcast=True,
         bundle=False,
         # Overwrite wallet to use this list of wifs only
         keys={"active": wif},
         num_retries=10)
Example #11
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
            normal=True, appbase=True),
                                                 num_retries=10))
        cls.bts = DPay(node=nodelist.get_nodes(appbase=False),
                       nobroadcast=True,
                       unsigned=True,
                       data_refresh_time_seconds=900,
                       num_retries=10)
        cls.appbase = DPay(node=nodelist.get_nodes(normal=False, appbase=True),
                           nobroadcast=True,
                           unsigned=True,
                           data_refresh_time_seconds=900,
                           num_retries=10)

        cls.account = Account("test", full=True, dpay_instance=cls.bts)
        cls.account_appbase = Account("test",
                                      full=True,
                                      dpay_instance=cls.appbase)
Example #12
0
    def test_default_connection(self):
        nodelist = NodeList()
        nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10))
        b1 = DPay(
            node=nodelist.get_testnet(testnet=True, testnetdev=False),
            nobroadcast=True,
        )
        set_shared_dpay_instance(b1)
        test = Account("dpaygo")

        b2 = DPay(
            node=nodelist.get_nodes(appbase=False),
            nobroadcast=True,
        )
        set_shared_dpay_instance(b2)

        bts = Account("dpaygo")

        self.assertEqual(test.dpay.prefix, "DWT")
        self.assertEqual(bts.dpay.prefix, "DWB")
Example #13
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
            normal=True, appbase=True),
                                                 num_retries=10))
        cls.bts = DPay(
            node=nodelist.get_nodes(),
            nobroadcast=True,
            timeout=30,
            num_retries=30,
        )
        # from getpass import getpass
        # self.bts.wallet.unlock(getpass())
        set_shared_dpay_instance(cls.bts)
        cls.bts.set_default_account("test")

        b = Blockchain(dpay_instance=cls.bts)
        num = b.get_current_block_num()
        # num = 23346630
        cls.start = num - 25
        cls.stop = num
Example #14
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
            normal=True, appbase=True),
                                                 num_retries=10))
        cls.bts = DPay(node=nodelist.get_nodes(appbase=False),
                       nobroadcast=True,
                       keys={"active": wif},
                       num_retries=10)
        cls.appbase = DPay(node=nodes_appbase,
                           nobroadcast=True,
                           keys={"active": wif},
                           num_retries=10)
        # from getpass import getpass
        # self.bts.wallet.unlock(getpass())
        set_shared_dpay_instance(cls.bts)
        cls.bts.set_default_account("test")

        b = Blockchain(dpay_instance=cls.bts)
        num = b.get_current_block_num()
        cls.start = num - 25
        cls.stop = num
Example #15
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
         normal=True, appbase=True),
                                              num_retries=10))
     cls.stm = DPay(node=nodelist.get_nodes(appbase=False),
                    keys={
                        "active": wif,
                        "owner": wif,
                        "memo": wif
                    },
                    nobroadcast=True,
                    num_retries=10)
     cls.appbase = DPay(node=nodelist.get_nodes(normal=False, appbase=True),
                        nobroadcast=True,
                        keys={
                            "active": wif,
                            "owner": wif,
                            "memo": wif
                        },
                        num_retries=10)
     set_shared_dpay_instance(cls.stm)
     cls.stm.set_default_account("test")
Example #16
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
            normal=True, appbase=True),
                                                 num_retries=10))
        cls.bts = DPay(
            node=nodelist.get_nodes(normal=False, appbase=True, dev=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_dpay_instance(cls.bts)
        cls.bts.set_default_account("test")

        b = Blockchain(dpay_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)
Example #17
0
    def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(
            normal=True, appbase=True),
                                                 num_retries=10))
        cls.bts = DPay(node=nodelist.get_nodes(appbase=False),
                       nobroadcast=True,
                       keys={"active": wif},
                       num_retries=10)
        cls.appbase = DPay(node=nodelist.get_nodes(normal=False, appbase=True),
                           nobroadcast=True,
                           keys={"active": wif},
                           num_retries=10)
        # from getpass import getpass
        # self.bts.wallet.unlock(getpass())
        set_shared_dpay_instance(cls.bts)
        cls.bts.set_default_account("test")

        acc = Account("holger80", dpay_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)
Example #18
0
 def setUpClass(cls):
     nodelist = NodeList()
     nodelist.update_nodes(dpay_instance=DPay(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10))
     cls.bts = DPay(
         node=nodelist.get_nodes(normal=True, appbase=False),
         nobroadcast=True,
         bundle=False,
         unsigned=True,
         # Overwrite wallet to use this list of wifs only
         keys={"active": wif},
         num_retries=10
     )
     cls.appbase = DPay(
         node=nodelist.get_nodes(normal=False, appbase=True, dev=False),
         nobroadcast=True,
         bundle=False,
         unsigned=True,
         # Overwrite wallet to use this list of wifs only
         keys={"active": wif},
         num_retries=10
     )
     cls.account = Account("dpaygobot", full=True, dpay_instance=cls.bts)
     cls.account_appbase = Account("dpaygobot", full=True, dpay_instance=cls.appbase)
     set_shared_dpay_instance(cls.bts)
Example #19
0
                       opNames=['vote']):
        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 = []

    stm = DPay(node=node_list, timeout=timeout)
    b = Blockchain(dpay_instance=stm)
    block = b.get_current_block()
    block.set_cache_auto_clean(False)
    opcount, total_duration = stream_votes(stm, 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()
Example #20
0
 def test_nodes_update(self):
     nodelist = NodeList()
     all_nodes = nodelist.get_nodes(normal=True, appbase=True, dev=True, testnet=True)
     nodelist.update_nodes(dpay_instance=self.bts)
     nodes = nodelist.get_nodes()
     self.assertIn(nodes[0], all_nodes)