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
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)
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")
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")
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)
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)
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)
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()
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)
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))
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")
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)
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")
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)
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")
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))
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")
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()
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)
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)
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()
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")
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")
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)
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
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")
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
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")
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)
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)