コード例 #1
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
コード例 #2
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)
コード例 #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")
コード例 #4
0
ファイル: test_dpay.py プロジェクト: dpays/dpaygo
 def test_create_account_password(self, node_param):
     if node_param == "non_appbase":
         bts = DPay(node=self.nodelist.get_nodes(appbase=False),
                     nobroadcast=True,
                     unsigned=True,
                     data_refresh_time_seconds=900,
                     keys={"active": wif, "owner": wif, "memo": wif},
                     num_retries=10)
     elif node_param == "appbase":
         bts = DPay(node=self.nodelist.get_nodes(normal=False, appbase=True),
                     nobroadcast=True,
                     unsigned=True,
                     data_refresh_time_seconds=900,
                     keys={"active": wif, "owner": wif, "memo": wif},
                     num_retries=10)
     name = ''.join(random.choice(string.ascii_lowercase) for _ in range(12))
     key5 = PrivateKey()
     bts.txbuffer.clear()
     tx = bts.create_account(
         name,
         creator="test",   # 1.2.7
         password="******",
         additional_owner_keys=[format(key5.pubkey, core_unit)],
         additional_active_keys=[format(key5.pubkey, core_unit)],
         additional_posting_keys=[format(key5.pubkey, core_unit)],
         additional_owner_accounts=["test1"],  # 1.2.0
         additional_active_accounts=["test1"],
         storekeys=False,
         delegation_fee_dpay="0 BEX"
     )
     self.assertEqual(
         tx["operations"][0][0],
         "account_create"
     )
     op = tx["operations"][0][1]
     role = "active"
     self.assertIn(
         format(key5.pubkey, core_unit),
         [x[0] for x in op[role]["key_auths"]])
     self.assertIn(
         format(key5.pubkey, core_unit),
         [x[0] for x in op[role]["key_auths"]])
     self.assertIn(
         "test1",
         [x[0] for x in op[role]["account_auths"]])
     role = "owner"
     self.assertIn(
         format(key5.pubkey, core_unit),
         [x[0] for x in op[role]["key_auths"]])
     self.assertIn(
         format(key5.pubkey, core_unit),
         [x[0] for x in op[role]["key_auths"]])
     self.assertIn(
         "test1",
         [x[0] for x in op[role]["account_auths"]])
     self.assertEqual(
         op["creator"],
         "test")
コード例 #5
0
ファイル: test_websocket.py プロジェクト: dpays/dpaygo
    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)
コード例 #6
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)
コード例 #7
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)
コード例 #8
0
ファイル: test_instance.py プロジェクト: dpays/dpaygo
 def test_blockchain(self, node_param):
     if node_param == "instance":
         set_shared_dpay_instance(self.bts)
         o = Blockchain()
         self.assertIn(o.dpay.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Blockchain(dpay_instance=DPay(
                 node="https://abc.d", autoconnect=False, num_retries=1))
     else:
         set_shared_dpay_instance(
             DPay(node="https://abc.d", autoconnect=False, num_retries=1))
         stm = self.bts
         o = Blockchain(dpay_instance=stm)
         self.assertIn(o.dpay.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Blockchain()
コード例 #9
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)
コード例 #10
0
 def setUpClass(cls):
     cls.nodelist = NodeList()
     cls.nodelist.update_nodes(dpay_instance=DPay(
         node=cls.nodelist.get_nodes(normal=True, appbase=True),
         num_retries=10))
     stm = shared_dpay_instance()
     stm.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', 'dpaygo'])
     if result.exit_code != 0:
         raise AssertionError(str(result))
     result = runner.invoke(
         cli, ['-o', 'set', 'nodes',
               str(cls.nodelist.get_testnet())])
     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))
コード例 #11
0
ファイル: test_instance.py プロジェクト: dpays/dpaygo
 def test_amount(self, node_param):
     if node_param == "instance":
         stm = DPay(node="https://abc.d", autoconnect=False, num_retries=1)
         set_shared_dpay_instance(self.bts)
         o = Amount("1 BBD")
         self.assertIn(o.dpay.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Amount("1 BBD", dpay_instance=stm)
     else:
         set_shared_dpay_instance(
             DPay(node="https://abc.d", autoconnect=False, num_retries=1))
         stm = self.bts
         o = Amount("1 BBD", dpay_instance=stm)
         self.assertIn(o.dpay.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Amount("1 BBD")
コード例 #12
0
 def setUpClass(cls):
     nodelist = NodeList()
     stm = DPay(node=nodelist.get_testnet(),
                nobroadcast=True,
                num_retries=10,
                expiration=120,
                keys=wif)
     set_shared_dpay_instance(stm)
コード例 #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(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")
コード例 #14
0
ファイル: test_nodelist.py プロジェクト: dpays/dpaygo
 def setUpClass(cls):
     nodelist = NodeList()
     cls.bts = DPay(
         node=nodelist.get_nodes(appbase=False),
         nobroadcast=True,
         num_retries=10
     )
     set_shared_dpay_instance(cls.bts)
コード例 #15
0
ファイル: test_block.py プロジェクト: dpays/dpaygo
 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")
コード例 #16
0
 def test_normal_appbase_switch(self):
     bts = DPay(node=[self.nodes[0], self.nodes_appbase[0]])
     self.assertTrue(bts.chain_params['min_version'] == '0.19.5')
     self.assertFalse(bts.rpc.get_use_appbase())
     self.assertTrue(isinstance(bts.rpc.get_config(api="database"), dict))
     bts.rpc.next()
     self.assertTrue(bts.chain_params['min_version'] == '0.19.10')
     self.assertTrue(bts.rpc.get_use_appbase())
     self.assertTrue(isinstance(bts.rpc.get_config(api="database"), dict))
コード例 #17
0
ファイル: test_testnet.py プロジェクト: dpays/dpaygo
 def test_follow_posting_key(self):
     nodelist = NodeList()
     stm = DPay(node=nodelist.get_testnet(),
                keys=[self.posting_key],
                nobroadcast=True,
                expiration=120,
                num_retries=10)
     account = Account("dpaygo", dpay_instance=stm)
     account.follow("dpaygo1")
コード例 #18
0
ファイル: test_instance.py プロジェクト: dpays/dpaygo
 def test_transactionbuilder(self, node_param):
     if node_param == "instance":
         set_shared_dpay_instance(self.bts)
         o = TransactionBuilder()
         self.assertIn(o.dpay.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             o = TransactionBuilder(dpay_instance=DPay(
                 node="https://abc.d", autoconnect=False, num_retries=1))
             o.dpay.get_config()
     else:
         set_shared_dpay_instance(
             DPay(node="https://abc.d", autoconnect=False, num_retries=1))
         stm = self.bts
         o = TransactionBuilder(dpay_instance=stm)
         self.assertIn(o.dpay.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             o = TransactionBuilder()
             o.dpay.get_config()
コード例 #19
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)
コード例 #20
0
ファイル: test_types.py プロジェクト: dpays/dpaygo
    def test_JsonObj(self):
        j = {"a": 2, "b": "abcde", "c": ["a", "b"]}
        j2 = types.JsonObj(json.dumps(j))
        self.assertEqual(j, j2)

        stm = DPay(offline=True)
        a = Amount("1 BBD", dpay_instance=stm)
        j = a.json()
        j2 = types.JsonObj(json.dumps(j))
        self.assertEqual(j, j2)
コード例 #21
0
ファイル: test_testnet.py プロジェクト: dpays/dpaygo
    def test_transfer_2of2_wif(self):
        nodelist = NodeList()
        # Send a 2 of 2 transaction from elf which needs dpaygo4's cosign to send
        # funds but sign the transaction with elf's key and then serialize the transaction
        # and deserialize the transaction.  After that, sign with dpaygo4's key.
        dpay = DPay(
            node=nodelist.get_testnet(),
            num_retries=10,
            keys=[self.active_private_key_of_dpaygo5],
            expiration=360,
        )

        tx = TransactionBuilder(dpay_instance=dpay)
        tx.appendOps(
            Transfer(
                **{
                    "from": 'dpaygo5',
                    "to": 'dpaygo',
                    "amount": '0.01 BBD',
                    "memo": '2 of 2 serialized/deserialized transaction'
                }))

        tx.appendSigner("dpaygo5", "active")
        tx.addSigningInformation("dpaygo5", "active")
        tx.sign()
        tx.clearWifs()
        self.assertEqual(len(tx['signatures']), 1)
        tx_json = tx.json()
        del dpay
        del tx

        dpay = DPay(
            node=nodelist.get_testnet(),
            num_retries=10,
            keys=[self.active_private_key_of_dpaygo4],
            expiration=360,
        )
        new_tx = TransactionBuilder(tx=tx_json, dpay_instance=dpay)
        new_tx.appendMissingSignatures()
        new_tx.sign(reconstruct_tx=False)
        self.assertEqual(len(new_tx['signatures']), 2)
        new_tx.broadcast()
コード例 #22
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")
コード例 #23
0
ファイル: test_instance.py プロジェクト: dpays/dpaygo
 def test_account(self, node_param):
     if node_param == "instance":
         set_shared_dpay_instance(self.bts)
         acc = Account("test")
         self.assertIn(acc.dpay.rpc.url, self.urls)
         self.assertIn(acc["balance"].dpay.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Account("test",
                     dpay_instance=DPay(node="https://abc.d",
                                        autoconnect=False,
                                        num_retries=1))
     else:
         set_shared_dpay_instance(
             DPay(node="https://abc.d", autoconnect=False, num_retries=1))
         stm = self.bts
         acc = Account("test", dpay_instance=stm)
         self.assertIn(acc.dpay.rpc.url, self.urls)
         self.assertIn(acc["balance"].dpay.rpc.url, self.urls)
         with self.assertRaises(RPCConnection):
             Account("test")
コード例 #24
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)
コード例 #25
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
コード例 #26
0
ファイル: test_testnet.py プロジェクト: dpays/dpaygo
 def setUpClass(cls):
     nodelist = NodeList()
     stm = shared_dpay_instance()
     stm.config.refreshBackup()
     cls.bts = DPay(
         node=nodelist.get_testnet(),
         nobroadcast=True,
         num_retries=10,
         expiration=120,
     )
     # from getpass import getpass
     # self.bts.wallet.unlock(getpass())
     cls.bts.set_default_account("dpaygo")
コード例 #27
0
ファイル: test_blockchain.py プロジェクト: dpays/dpaygo
    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
コード例 #28
0
ファイル: test_txbuffers.py プロジェクト: dpays/dpaygo
 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")
コード例 #29
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)
コード例 #30
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)