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)) cls.bts = DPay(node=cls.nodelist.get_nodes(), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) cls.testnet = DPay(node="https://testnet.dpaydev.com", nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) cls.account = Account("test", full=True, dpay_instance=cls.bts) cls.account_testnet = Account("test", full=True, dpay_instance=cls.testnet)
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={"active": wif}, num_retries=10) b = Blockchain(dpay_instance=cls.bts) num = b.get_current_block_num() cls.start = num - 25 cls.stop = num cls.testnet = DPay(node="https://testnet.dpaydev.com", 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.testnet) num = b.get_current_block_num() cls.start_testnet = num - 25 cls.stop_testnet = num
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(), 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.testnet = DPay(node="https://testnet.dpaydev.com", 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 __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()) 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(), nobroadcast=True, num_retries=10 ) set_shared_dpay_instance(dpay)
def test_create_account(self): bts = DPay(node=self.nodelist.get_nodes(), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) core_unit = "DWB" name = ''.join( random.choice(string.ascii_lowercase) for _ in range(12)) key1 = PrivateKey() key2 = PrivateKey() key3 = PrivateKey() key4 = PrivateKey() key5 = PrivateKey() bts.txbuffer.clear() tx = bts.create_account( name, creator="test", # 1.2.7 owner_key=format(key1.pubkey, core_unit), active_key=format(key2.pubkey, core_unit), posting_key=format(key3.pubkey, core_unit), memo_key=format(key4.pubkey, core_unit), 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, ) 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 = "posting" 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 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, num_retries=10) cls.testnet = DPay(node="https://testnet.dpaydev.com", nobroadcast=True, num_retries=10) set_shared_dpay_instance(cls.bts)
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(), nobroadcast=True, num_retries=10) self.assertNotEqual(b1.rpc.url, b2.rpc.url)
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(), use_condenser=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")
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 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 setUpClass(cls): cls.nodelist = NodeList() cls.nodelist.update_nodes() 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', 'dpaycli']) 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 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("dpaycli") # Test account "dpaycli" cls.active_key = "5Jt2wTfhUt5GkZHV1HYVfkEaJ6XnY8D2iA4qjtK9nnGXAhThM3w" cls.posting_key = "5Jh1Gtu2j4Yi16TfhoDmg8Qj3ULcgRi7A49JXdfUUTVPkaFaRKz" cls.memo_key = "5KPbCuocX26aMxN9CDPdUex4wCbfw9NoT5P7UhcqgDwxXa47bit" # Test account "dpaycli1" cls.active_key1 = "5Jo9SinzpdAiCDLDJVwuN7K5JcusKmzFnHpEAtPoBHaC1B5RDUd" cls.posting_key1 = "5JGNhDXuDLusTR3nbmpWAw4dcmE8WfSM8odzqcQ6mDhJHP8YkQo" cls.memo_key1 = "5KA2ddfAffjfRFoe1UhQjJtKnGsBn9xcsdPQTfMt1fQuErDAkWr" cls.active_private_key_of_dpaycli4 = '5JkZZEUWrDsu3pYF7aknSo7BLJx7VfxB3SaRtQaHhsPouDYjxzi' cls.active_private_key_of_dpaycli5 = '5Hvbm9VjRbd1B3ft8Lm81csaqQudwFwPGdiRKrCmTKcomFS3Z9J'
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.testnet = DPay(node="https://testnet.dpaydev.com", 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 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 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("dpaycli", dpay_instance=stm) account.follow("dpaycli1")
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_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(), 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() 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, unsigned=True, keys={"active": wif}, num_retries=10) cls.testnet = DPay( # node="https://testnet.timcliff.com", node=nodelist.get_nodes(), nobroadcast=True, unsigned=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")
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("dpaycli") b2 = DPay( node=nodelist.get_nodes(), nobroadcast=True, ) set_shared_dpay_instance(b2) bts = Account("dpaycli") self.assertEqual(test.dpay.prefix, "STX") self.assertEqual(bts.dpay.prefix, "DWB")
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=True) cls.nodes_https = nodelist.get_nodes(wss=False, appbase=True) cls.nodes_appbase = nodelist.get_nodes(normal=False) cls.test_list = nodelist.get_nodes() 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.appbase) cls.appbase.set_default_account("test")
def test_transfer_2of2_wif(self): nodelist = NodeList() # Send a 2 of 2 transaction from elf which needs dpaycli4'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 dpaycli4's key. dpay = DPay( node=nodelist.get_testnet(), num_retries=10, keys=[self.active_private_key_of_dpaycli5], expiration=360, ) tx = TransactionBuilder(use_condenser_api=True, dpay_instance=dpay) tx.appendOps(Transfer(**{"from": 'dpaycli5', "to": 'dpaycli', "amount": Amount("0.01 BEX", dpay_instance=dpay), "memo": '2 of 2 serialized/deserialized transaction'})) tx.appendSigner("dpaycli5", "active") tx.addSigningInformation("dpaycli5", "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_dpaycli4], 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 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(), keys={ "active": wif, "owner": wif, "memo": wif }, nobroadcast=True, num_retries=10) cls.testnet = DPay(node="https://testnet.dpaydev.com", 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(), 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(), nobroadcast=True, bundle=False, unsigned=True, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10) cls.testnet = DPay( node="https://testnet.dpaydev.com", nobroadcast=True, bundle=False, unsigned=True, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10) cls.account = Account("dpayclibot", full=True, dpay_instance=cls.bts) 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(), nobroadcast=True, keys={"active": wif}, num_retries=10) cls.testnet = DPay(node="https://testnet.dpaydev.com", 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)
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(), use_condenser=True, nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10) cls.testnet = DPay(node="https://testnet.dpaydev.com", 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 test_Transfer_broadcast(self): nodelist = NodeList() stm = DPay(node=nodelist.get_testnet(), keys=[self.active_key], nobroadcast=True, expiration=120, num_retries=10) tx = TransactionBuilder(use_condenser_api=True, expiration=10, dpay_instance=stm) tx.appendOps(Transfer(**{"from": "dpaycli", "to": "dpaycli1", "amount": Amount("1 BEX", dpay_instance=stm), "memo": ""})) tx.appendSigner("dpaycli", "active") tx.sign() tx.broadcast()
def test_appendSigner(self): nodelist = NodeList() stm = DPay(node=nodelist.get_testnet(), keys=[self.active_key], nobroadcast=True, expiration=120, num_retries=10) tx = TransactionBuilder(use_condenser_api=True, dpay_instance=stm) tx.appendOps(Transfer(**{"from": "dpaycli", "to": "dpaycli1", "amount": Amount("1 BEX", dpay_instance=stm), "memo": ""})) account = Account("dpaycli", dpay_instance=stm) with self.assertRaises( AssertionError ): tx.appendSigner(account, "abcdefg") tx.appendSigner(account, "active") self.assertTrue(len(tx.wifs) > 0) tx.sign() self.assertTrue(len(tx["signatures"]) > 0)