def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) crea = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, num_retries=10) set_shared_crea_instance(crea)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) stm = Crea(node=nodelist.get_nodes()) self.ws = CreaWebsocket(urls=stm.rpc.nodes, num_retries=10)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, num_retries=10) cls.account = Account("test", full=True, crea_instance=cls.bts)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, num_retries=10) cls.creait = Crea(node="https://nodes.creary.net", nobroadcast=True, num_retries=10) set_shared_crea_instance(cls.bts)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.appbase = Crea( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, bundle=False, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_crea_instance(cls.bts) cls.bts.set_default_account("test")
def test_blockchain(self, node_param): if node_param == "instance": set_shared_crea_instance(self.bts) o = Blockchain() self.assertIn(o.crea.rpc.url, self.urls) with self.assertRaises(RPCConnection): Blockchain(crea_instance=Crea( node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_crea_instance( Crea(node="https://abc.d", autoconnect=False, num_retries=1)) stm = self.bts o = Blockchain(crea_instance=stm) self.assertIn(o.crea.rpc.url, self.urls) with self.assertRaises(RPCConnection): Blockchain()
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.node_list = nodelist.get_nodes(exclude_limited=True) # stm = shared_crea_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', 'crea']) if result.exit_code != 0: raise AssertionError(str(result)) result = runner.invoke(cli, ['-o', 'set', 'nodes', str(cls.node_list)]) 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() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, num_retries=10) cls.creait = Crea(node="https://nodes.creary.net", nobroadcast=True, use_condenser=False, num_retries=10) set_shared_crea_instance(cls.bts) cls.asset = Asset("CBD") cls.symbol = cls.asset["symbol"] cls.precision = cls.asset["precision"] cls.asset2 = Asset("CREA")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) node_list = nodelist.get_nodes(exclude_limited=True) cls.bts = Crea( 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("creabot", crea_instance=cls.bts) set_shared_crea_instance(cls.bts)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, keys={"active": wif}, num_retries=10) b = Blockchain(crea_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_crea_instance(cls.bts)
def setUpClass(cls): nodelist = NodeList() # stm = shared_crea_instance() # stm.config.refreshBackup() # nodes = nodelist.get_testnet() cls.nodes = nodelist.get_nodes() cls.bts = Crea( node=cls.nodes, nobroadcast=True, num_retries=10, expiration=120, ) # from getpass import getpass # self.bts.wallet.unlock(getpass()) cls.bts.set_default_account("crea") # Test account "crea" cls.active_key = "5Jt2wTfhUt5GkZHV1HYVfkEaJ6XnY8D2iA4qjtK9nnGXAhThM3w" cls.posting_key = "5Jh1Gtu2j4Yi16TfhoDmg8Qj3ULcgRi7A49JXdfUUTVPkaFaRKz" cls.memo_key = "5KPbCuocX26aMxN9CDPdUex4wCbfw9NoT5P7UhcqgDwxXa47bit" # Test account "crea1" cls.active_key1 = "5Jo9SinzpdAiCDLDJVwuN7K5JcusKmzFnHpEAtPoBHaC1B5RDUd" cls.posting_key1 = "5JGNhDXuDLusTR3nbmpWAw4dcmE8WfSM8odzqcQ6mDhJHP8YkQo" cls.memo_key1 = "5KA2ddfAffjfRFoe1UhQjJtKnGsBn9xcsdPQTfMt1fQuErDAkWr" cls.active_private_key_of_crea4 = '5JkZZEUWrDsu3pYF7aknSo7BLJx7VfxB3SaRtQaHhsPouDYjxzi' cls.active_private_key_of_crea5 = '5Hvbm9VjRbd1B3ft8Lm81csaqQudwFwPGdiRKrCmTKcomFS3Z9J'
def test_amount(self, node_param): if node_param == "instance": stm = Crea(node="https://abc.d", autoconnect=False, num_retries=1) set_shared_crea_instance(self.bts) o = Amount("1 CBD") self.assertIn(o.crea.rpc.url, self.urls) with self.assertRaises(RPCConnection): Amount("1 CBD", crea_instance=stm) else: set_shared_crea_instance( Crea(node="https://abc.d", autoconnect=False, num_retries=1)) stm = self.bts o = Amount("1 CBD", crea_instance=stm) self.assertIn(o.crea.rpc.url, self.urls) with self.assertRaises(RPCConnection): Amount("1 CBD")
def setUpClass(cls): nodelist = NodeList() stm = Crea(node=nodelist.get_nodes(), nobroadcast=True, num_retries=10, expiration=120) set_shared_crea_instance(stm)
def test_follow_posting_key(self): nodelist = NodeList() stm = Crea(node=self.nodes, keys=[self.posting_key], nobroadcast=True, expiration=120, num_retries=10) account = Account("crea", crea_instance=stm) account.follow("crea1")
def test_transactionbuilder(self, node_param): if node_param == "instance": set_shared_crea_instance(self.bts) o = TransactionBuilder() self.assertIn(o.crea.rpc.url, self.urls) with self.assertRaises(RPCConnection): o = TransactionBuilder(crea_instance=Crea( node="https://abc.d", autoconnect=False, num_retries=1)) o.crea.get_config() else: set_shared_crea_instance( Crea(node="https://abc.d", autoconnect=False, num_retries=1)) stm = self.bts o = TransactionBuilder(crea_instance=stm) self.assertIn(o.crea.rpc.url, self.urls) with self.assertRaises(RPCConnection): o = TransactionBuilder() o.crea.get_config()
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea( 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_crea_instance(cls.bts) cls.bts.set_default_account("test") b = Blockchain(crea_instance=cls.bts) num = b.get_current_block_num() # num = 23346630 cls.start = num - 25 cls.stop = num
def setUpClass(cls): cls.nodelist = NodeList() cls.nodelist.update_nodes(crea_instance=Crea( node=cls.nodelist.get_nodes( exclude_limited=False), num_retries=10)) stm = Crea(node=cls.nodelist.get_nodes()) stm.config.refreshBackup() stm.set_default_nodes(["xyz"]) del stm cls.urls = cls.nodelist.get_nodes(exclude_limited=True) cls.bts = Crea(node=cls.urls, nobroadcast=True, num_retries=10) set_shared_crea_instance(cls.bts) acc = Account("holger80", crea_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"]
def test_transfer_2of2_wif(self): nodelist = NodeList() # Send a 2 of 2 transaction from elf which needs crea4'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 crea4's key. crea = Crea( node=self.nodes, num_retries=10, keys=[self.active_private_key_of_crea5], expiration=360, ) tx = TransactionBuilder(use_condenser_api=True, crea_instance=crea) tx.appendOps( Transfer( **{ "from": 'crea5', "to": 'crea', "amount": Amount("0.01 CREA", crea_instance=crea), "memo": '2 of 2 serialized/deserialized transaction' })) tx.appendSigner("crea5", "active") tx.addSigningInformation("crea5", "active") tx.sign() tx.clearWifs() self.assertEqual(len(tx['signatures']), 1) tx_json = tx.json() del crea del tx crea = Crea( node=self.nodes, num_retries=10, keys=[self.active_private_key_of_crea4], expiration=360, ) new_tx = TransactionBuilder(tx=tx_json, crea_instance=crea) new_tx.appendMissingSignatures() new_tx.sign(reconstruct_tx=False) self.assertEqual(len(new_tx['signatures']), 2) new_tx.broadcast()
def test_account(self, node_param): if node_param == "instance": set_shared_crea_instance(self.bts) acc = Account("test") self.assertIn(acc.crea.rpc.url, self.urls) self.assertIn(acc["balance"].crea.rpc.url, self.urls) with self.assertRaises(RPCConnection): Account("test", crea_instance=Crea(node="https://abc.d", autoconnect=False, num_retries=1)) else: set_shared_crea_instance( Crea(node="https://abc.d", autoconnect=False, num_retries=1)) stm = self.bts acc = Account("test", crea_instance=stm) self.assertIn(acc.crea.rpc.url, self.urls) self.assertIn(acc["balance"].crea.rpc.url, self.urls) with self.assertRaises(RPCConnection): Account("test")
def test_crea(self, node_param): if node_param == "instance": set_shared_crea_instance(self.bts) o = Crea(node=self.urls) o.get_config() self.assertIn(o.rpc.url, self.urls) with self.assertRaises(RPCConnection): stm = Crea(node="https://abc.d", autoconnect=False, num_retries=1) stm.get_config() else: set_shared_crea_instance( Crea(node="https://abc.d", autoconnect=False, num_retries=1)) stm = self.bts o = stm o.get_config() self.assertIn(o.rpc.url, self.urls) with self.assertRaises(RPCConnection): stm = shared_crea_instance() stm.get_config()
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea( 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_crea_instance(cls.bts) cls.bts.set_default_account("test") b = Blockchain(crea_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(crea_instance=Crea( node=nodelist.get_nodes(normal=True, appbase=True), num_retries=3)) cls.nodes = nodelist.get_nodes() if "https://nodes.creary.net" in cls.nodes: cls.nodes.remove("https://nodes.creary.net") cls.nodes_creait = ["https://nodes.creary.net"] cls.appbase = Crea(node=cls.nodes, nobroadcast=True, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) cls.rpc = CreaNodeRPC(urls=cls.nodes_creait) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_crea_instance(cls.nodes_creait) cls.appbase.set_default_account("test")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) node_list = nodelist.get_nodes(exclude_limited=True) cls.stm = Crea(node=node_list, keys={ "active": wif, "owner": wif, "memo": wif }, nobroadcast=True, num_retries=10) cls.creait = Crea(node="https://nodes.creary.net", nobroadcast=True, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) set_shared_crea_instance(cls.stm) cls.stm.set_default_account("test")
def setUpClass(cls): stm = shared_crea_instance() stm.config.refreshBackup() nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.stm = Crea( 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.stm.set_default_account("test") set_shared_crea_instance(cls.stm) # self.stm.newWallet("TestingOneTwoThree") cls.wallet = Wallet(crea_instance=cls.stm) cls.wallet.wipe(True) cls.wallet.newWallet(pwd="TestingOneTwoThree") cls.wallet.unlock(pwd="TestingOneTwoThree") cls.wallet.addPrivateKey(wif)
def inspect_cread_implementation(): """ Compare implemented methods with current live deployment of cread. """ _apis = distinct(pluck('api', api_methods)) _methods = set(pluck('method', api_methods)) avail_methods = [] s = Crea(re_raise=False) for api in _apis: err = s.exec('nonexistentmethodcall', api=api) [ avail_methods.append(x) for x in err['data']['stack'][0]['data']['api'].keys() ] avail_methods = set(avail_methods) print("\nMissing Methods:") pprint(avail_methods - _methods) print("\nLikely Deprecated Methods:") pprint(_methods - avail_methods)
def test_appendWif(self): nodelist = NodeList() stm = Crea(node=self.nodes, nobroadcast=True, expiration=120, num_retries=10) tx = TransactionBuilder(use_condenser_api=True, crea_instance=stm) tx.appendOps( Transfer( **{ "from": "crea", "to": "crea1", "amount": Amount("1 CREA", crea_instance=stm), "memo": "" })) with self.assertRaises(MissingKeyError): tx.sign() with self.assertRaises(InvalidWifError): tx.appendWif("abcdefg") tx.appendWif(self.active_key) tx.sign() self.assertTrue(len(tx["signatures"]) > 0)
def test_Transfer_broadcast(self): nodelist = NodeList() stm = Crea(node=self.nodes, keys=[self.active_key], nobroadcast=True, expiration=120, num_retries=10) tx = TransactionBuilder(use_condenser_api=True, expiration=10, crea_instance=stm) tx.appendOps( Transfer( **{ "from": "crea", "to": "crea1", "amount": Amount("1 CREA", crea_instance=stm), "memo": "" })) tx.appendSigner("crea", "active") tx.sign() tx.broadcast()
def test_appendSigner(self): nodelist = NodeList() stm = Crea(node=self.nodes, keys=[self.active_key], nobroadcast=True, expiration=120, num_retries=10) tx = TransactionBuilder(use_condenser_api=True, crea_instance=stm) tx.appendOps( Transfer( **{ "from": "crea", "to": "crea1", "amount": Amount("1 CREA", crea_instance=stm), "memo": "" })) account = Account("crea", crea_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)
def test_verifyAuthorityException(self): nodelist = NodeList() stm = Crea(node=self.nodes, keys=[self.posting_key], nobroadcast=True, expiration=120, num_retries=10) tx = TransactionBuilder(use_condenser_api=True, crea_instance=stm) tx.appendOps( Transfer( **{ "from": "crea", "to": "crea1", "amount": Amount("1 CREA", crea_instance=stm), "memo": "" })) account = Account("crea2", crea_instance=stm) tx.appendSigner(account, "active") tx.appendWif(self.posting_key) self.assertTrue(len(tx.wifs) > 0) tx.sign() with self.assertRaises(exceptions.MissingRequiredActiveAuthority): tx.verify_authority() self.assertTrue(len(tx["signatures"]) > 0)