diff --git a/beem/blockchain.py b/beem/blockchain.py index 68c15f3e071f826431ca4959b5974c6f117c888a..2b301de9ae2cbd25675cc7c43940a9c77646a6ef 100644 --- a/beem/blockchain.py +++ b/beem/blockchain.py @@ -730,6 +730,15 @@ class Blockchain(object): block_num = block.get("id") _id = self.hash_op(event) timestamp = block.get("timestamp") + elif "op" in event and isinstance(event["op"], dict) and "type" in event["op"] and "value" in event["op"]: + op_type = event["op"]["type"] + if len(op_type) > 10 and op_type[len(op_type) - 10:] == "_operation": + op_type = op_type[:-10] + op = event["op"]["value"] + trx_id = event.get("trx_id") + block_num = event.get("block") + _id = self.hash_op(event["op"]) + timestamp = event.get("timestamp") else: op_type, op = event["op"] trx_id = event.get("trx_id") diff --git a/beemgraphenebase/chains.py b/beemgraphenebase/chains.py index efbcdb5449418d53679ce9cdbb091015993cd1b5..cf77df5d14e40df15fc4f0d4d889f881f880ed5b 100644 --- a/beemgraphenebase/chains.py +++ b/beemgraphenebase/chains.py @@ -58,11 +58,11 @@ known_chains = { "TESTDEV": { "chain_id": "18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e", - "min_version": '0.0.0', + "min_version": '0.20.0', "prefix": "TST", "chain_assets": [ - {"asset": "@@000000013", "symbol": "SBD", "precision": 3, "id": 0}, - {"asset": "@@000000021", "symbol": "STEEM", "precision": 3, "id": 1}, + {"asset": "@@000000013", "symbol": "TBD", "precision": 3, "id": 0}, + {"asset": "@@000000021", "symbol": "TESTS", "precision": 3, "id": 1}, {"asset": "@@000000037", "symbol": "VESTS", "precision": 6, "id": 2} ], }, diff --git a/tests/beem/test_account.py b/tests/beem/test_account.py index 07b7734a70e0dc8ac9648d881bdb4d4542e23463..3250125b93df6bac833c930c7a5bc4d5dfde8212 100644 --- a/tests/beem/test_account.py +++ b/tests/beem/test_account.py @@ -29,7 +29,7 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(normal=True, appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, bundle=False, unsigned=True, @@ -37,8 +37,8 @@ class Testcases(unittest.TestCase): keys={"active": wif}, num_retries=10 ) - cls.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True, dev=False), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, bundle=False, unsigned=True, @@ -47,20 +47,12 @@ class Testcases(unittest.TestCase): num_retries=10 ) cls.account = Account("beembot", full=True, steem_instance=cls.bts) - cls.account_appbase = Account("beembot", full=True, steem_instance=cls.appbase) + cls.account_testnet = Account("beembot", full=True, steem_instance=cls.testnet) set_shared_steem_instance(cls.bts) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_account(self, node_param): - if node_param == "non_appbase": - stm = self.bts - account = self.account - else: - stm = self.appbase - account = self.account_appbase + def test_account(self): + stm = self.bts + account = self.account Account("beembot", steem_instance=stm) with self.assertRaises( exceptions.AccountDoesNotExistsException @@ -86,17 +78,9 @@ class Testcases(unittest.TestCase): self.assertEqual(str(account), "<Account beembot>") self.assertIsInstance(Account(account), Account) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_history(self, node_param): - if node_param == "non_appbase": - account = self.account - zero_element = 0 - else: - account = self.account_appbase - zero_element = 1 # Bug in steem + def test_history(self): + account = self.account + zero_element = 0 h_all_raw = [] for h in account.history_reverse(raw_output=True): h_all_raw.append(h) @@ -196,15 +180,8 @@ class Testcases(unittest.TestCase): self.assertEqual(h_list[0][1]['block'], h_all_raw[-10 + zero_element][1]['block']) self.assertEqual(h_list[-1][1]['block'], h_all_raw[-2 + zero_element][1]['block']) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_history2(self, node_param): - if node_param == "non_appbase": - stm = self.bts - else: - stm = self.appbase + def test_history2(self): + stm = self.bts account = Account("beembot", steem_instance=stm) h_list = [] max_index = account.virtual_op_count() @@ -235,15 +212,8 @@ class Testcases(unittest.TestCase): for i in range(1, 5): self.assertEqual(h_list[i][0] - h_list[i - 1][0], 1) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_history_reverse2(self, node_param): - if node_param == "non_appbase": - stm = self.bts - else: - stm = self.appbase + def test_history_reverse2(self): + stm = self.bts account = Account("beembot", steem_instance=stm) h_list = [] max_index = account.virtual_op_count() @@ -274,17 +244,9 @@ class Testcases(unittest.TestCase): for i in range(1, 5): self.assertEqual(h_list[i][0] - h_list[i - 1][0], -1) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_history_block_num(self, node_param): - if node_param == "non_appbase": - stm = self.bts - zero_element = 0 - else: - stm = self.appbase - zero_element = 0 # bug in steem + def test_history_block_num(self): + stm = self.bts + zero_element = 0 account = Account("fullnodeupdate", steem_instance=stm) h_all_raw = [] for h in account.history_reverse(raw_output=True): @@ -318,15 +280,8 @@ class Testcases(unittest.TestCase): self.assertEqual(h_list[0][1]['block'], h_all_raw[-10 + zero_element][1]['block']) self.assertEqual(h_list[-1][1]['block'], h_all_raw[-2 + zero_element][1]['block']) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_account_props(self, node_param): - if node_param == "non_appbase": - account = self.account - else: - account = self.account_appbase + def test_account_props(self): + account = self.account rep = account.get_reputation() self.assertTrue(isinstance(rep, float)) vp = account.get_voting_power() @@ -459,17 +414,10 @@ class Testcases(unittest.TestCase): "beembot", op["from"]) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_json_export(self, node_param): - if node_param == "non_appbase": - account = self.account - else: - account = self.account_appbase + def test_json_export(self): + account = self.account if account.steem.rpc.get_use_appbase(): - content = self.appbase.rpc.find_accounts({'accounts': [account["name"]]}, api="database")["accounts"][0] + content = self.testnet.rpc.find_accounts({'accounts': [account["name"]]}, api="database")["accounts"][0] else: content = self.bts.rpc.get_accounts([account["name"]])[0] keys = list(content.keys()) @@ -535,15 +483,8 @@ class Testcases(unittest.TestCase): votes_list2.append(v) self.assertTrue(abs(len(votes_list) - len(votes_list2)) < 2) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_comment_history(self, node_param): - if node_param == "non_appbase": - account = self.account - else: - account = self.account_appbase + def test_comment_history(self): + account = self.account comments = [] for c in account.comment_history(limit=1): comments.append(c) @@ -553,14 +494,14 @@ class Testcases(unittest.TestCase): self.assertTrue(comments[0].depth > 0) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_blog_history(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": account = Account("holger80", steem_instance=self.bts) else: - account = Account("holger80", steem_instance=self.appbase) + account = Account("holger80", steem_instance=self.testnet) posts = [] for p in account.blog_history(limit=1): posts.append(p) @@ -569,15 +510,8 @@ class Testcases(unittest.TestCase): self.assertTrue(posts[0].is_main_post()) self.assertTrue(posts[0].depth == 0) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_reply_history(self, node_param): - if node_param == "non_appbase": - account = self.account - else: - account = self.account_appbase + def test_reply_history(self): + account = self.account replies = [] for r in account.reply_history(limit=1): replies.append(r) diff --git a/tests/beem/test_amount.py b/tests/beem/test_amount.py index 26db2395dd211aaaaba89c3783c995fbf0f339f2..8544211599ae0a84317f7acd33f2c0d28edc2464 100644 --- a/tests/beem/test_amount.py +++ b/tests/beem/test_amount.py @@ -22,8 +22,8 @@ class Testcases(unittest.TestCase): nobroadcast=True, num_retries=10 ) - cls.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, use_condenser=False, num_retries=10 @@ -41,14 +41,14 @@ class Testcases(unittest.TestCase): self.assertIsInstance(ret["amount"], float) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_init(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": stm = self.bts else: - stm = self.appbase + stm = self.testnet # String init asset = Asset("SBD", steem_instance=stm) symbol = asset["symbol"] @@ -111,21 +111,10 @@ class Testcases(unittest.TestCase): amount.tuple(), (1.0, self.symbol)) - def test_json(self): - amount = Amount("1", self.symbol) - self.assertEqual( - amount.json(), - "{:.{prec}f} {}".format( - 1, - self.asset["symbol"], - prec=self.precision - ) - ) - def test_json_appbase(self): - asset = Asset("SBD", steem_instance=self.appbase) - amount = Amount("1", asset, new_appbase_format=False, steem_instance=self.appbase) - if self.appbase.rpc.get_use_appbase(): + asset = Asset("SBD", steem_instance=self.bts) + amount = Amount("1", asset, new_appbase_format=False, steem_instance=self.bts) + if self.bts.rpc.get_use_appbase(): self.assertEqual( amount.json(), [str(1 * 10 ** asset.precision), asset.precision, asset.asset]) @@ -133,9 +122,9 @@ class Testcases(unittest.TestCase): self.assertEqual(amount.json(), "1.000 SBD") def test_json_appbase2(self): - asset = Asset("SBD", steem_instance=self.appbase) - amount = Amount("1", asset, new_appbase_format=True, steem_instance=self.appbase) - if self.appbase.rpc.get_use_appbase(): + asset = Asset("SBD", steem_instance=self.bts) + amount = Amount("1", asset, new_appbase_format=True, steem_instance=self.bts) + if self.bts.rpc.get_use_appbase(): self.assertEqual( amount.json(), {'amount': str(1 * 10 ** asset.precision), 'nai': asset.asset, 'precision': asset.precision}) diff --git a/tests/beem/test_asset.py b/tests/beem/test_asset.py index 7be22de43b0252ec0eed31ce8ca1b384e2f0d1e8..401e0bf6bf7822806020c02d2189bf15ba8bc921 100644 --- a/tests/beem/test_asset.py +++ b/tests/beem/test_asset.py @@ -19,59 +19,56 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, num_retries=10 ) - cls.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, num_retries=10 ) set_shared_steem_instance(cls.bts) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_assert(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": stm = self.bts else: - stm = self.appbase + stm = self.testnet with self.assertRaises(AssetDoesNotExistsException): Asset("FOObarNonExisting", full=False, steem_instance=stm) @parameterized.expand([ - ("non_appbase", "SBD", "SBD", 3, "SBD"), - ("non_appbase", "STEEM", "STEEM", 3, "STEEM"), - ("non_appbase", "VESTS", "VESTS", 6, "VESTS"), - ("appbase", "SBD", "SBD", 3, "@@000000013"), - ("appbase", "STEEM", "STEEM", 3, "@@000000021"), - ("appbase", "VESTS", "VESTS", 6, "@@000000037"), - ("appbase", "@@000000013", "SBD", 3, "@@000000013"), - ("appbase", "@@000000021", "STEEM", 3, "@@000000021"), - ("appbase", "@@000000037", "VESTS", 6, "@@000000037"), + ("normal", "SBD", "SBD", 3, "@@000000013"), + ("normal", "STEEM", "STEEM", 3, "@@000000021"), + ("normal", "VESTS", "VESTS", 6, "@@000000037"), + ("normal", "@@000000013", "SBD", 3, "@@000000013"), + ("normal", "@@000000021", "STEEM", 3, "@@000000021"), + ("normal", "@@000000037", "VESTS", 6, "@@000000037"), ]) def test_properties(self, node_param, data, symbol_str, precision, asset_str): - if node_param == "non_appbase": + if node_param == "normal": stm = self.bts else: - stm = self.appbase + stm = self.testnet asset = Asset(data, full=False, steem_instance=stm) self.assertEqual(asset.symbol, symbol_str) self.assertEqual(asset.precision, precision) self.assertEqual(asset.asset, asset_str) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_assert_equal(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": stm = self.bts else: - stm = self.appbase + stm = self.testnet asset1 = Asset("SBD", full=False, steem_instance=stm) asset2 = Asset("SBD", full=False, steem_instance=stm) self.assertTrue(asset1 == asset2) diff --git a/tests/beem/test_base_objects.py b/tests/beem/test_base_objects.py index 3ffb6a24b94b7727674e159120799dbf590ec9e9..5da9add50c94abe1bb6304219148ea3867872eda 100644 --- a/tests/beem/test_base_objects.py +++ b/tests/beem/test_base_objects.py @@ -17,7 +17,7 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, num_retries=10 ) diff --git a/tests/beem/test_block.py b/tests/beem/test_block.py index 4a2c8c1d3feec02bfcfc36f012220ba80ae07de7..6cb638f5aa39a070dd98a497dcd77819eacac0e7 100644 --- a/tests/beem/test_block.py +++ b/tests/beem/test_block.py @@ -13,7 +13,6 @@ from beem.instance import set_shared_steem_instance from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" -nodes_appbase = ["https://api.steemitstage.com", "https://api.steem.house", "https://api.steemit.com"] class Testcases(unittest.TestCase): @@ -22,41 +21,44 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, keys={"active": wif}, num_retries=10 ) - cls.appbase = Steem( - node=nodes_appbase, + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, keys={"active": wif}, num_retries=10 ) cls.test_block_id = 19273700 + cls.test_block_id_testnet = 10000 # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_steem_instance(cls.bts) cls.bts.set_default_account("test") @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_block(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts + test_block_id = self.test_block_id else: - bts = self.appbase - block = Block(self.test_block_id, steem_instance=bts) - self.assertEqual(block.identifier, self.test_block_id) + bts = self.testnet + test_block_id = self.test_block_id_testnet + block = Block(test_block_id, steem_instance=bts) + self.assertEqual(block.identifier, test_block_id) self.assertTrue(isinstance(block.time(), datetime)) self.assertTrue(isinstance(block, dict)) self.assertTrue(len(block.operations)) self.assertTrue(isinstance(block.ops_statistics(), dict)) - block2 = Block(self.test_block_id + 1, steem_instance=bts) + block2 = Block(test_block_id + 1, steem_instance=bts) self.assertTrue(block2.time() > block.time()) with self.assertRaises( exceptions.BlockDoesNotExistsException @@ -64,23 +66,25 @@ class Testcases(unittest.TestCase): Block(0, steem_instance=bts) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_block_only_ops(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts + test_block_id = self.test_block_id else: - bts = self.appbase - block = Block(self.test_block_id, only_ops=True, steem_instance=bts) - self.assertEqual(block.identifier, self.test_block_id) + bts = self.testnet + test_block_id = self.test_block_id_testnet + block = Block(test_block_id, only_ops=True, steem_instance=bts) + self.assertEqual(block.identifier, test_block_id) self.assertTrue(isinstance(block.time(), datetime)) self.assertTrue(isinstance(block, dict)) self.assertTrue(len(block.operations)) self.assertTrue(isinstance(block.ops_statistics(), dict)) - block2 = Block(self.test_block_id + 1, steem_instance=bts) + block2 = Block(test_block_id + 1, steem_instance=bts) self.assertTrue(block2.time() > block.time()) with self.assertRaises( exceptions.BlockDoesNotExistsException @@ -88,20 +92,22 @@ class Testcases(unittest.TestCase): Block(0, steem_instance=bts) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_block_header(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts + test_block_id = self.test_block_id else: - bts = self.appbase - block = BlockHeader(self.test_block_id, steem_instance=bts) - self.assertEqual(block.identifier, self.test_block_id) + bts = self.testnet + test_block_id = self.test_block_id_testnet + block = BlockHeader(test_block_id, steem_instance=bts) + self.assertEqual(block.identifier, test_block_id) self.assertTrue(isinstance(block.time(), datetime)) self.assertTrue(isinstance(block, dict)) - block2 = BlockHeader(self.test_block_id + 1, steem_instance=bts) + block2 = BlockHeader(test_block_id + 1, steem_instance=bts) self.assertTrue(block2.time() > block.time()) with self.assertRaises( exceptions.BlockDoesNotExistsException @@ -109,15 +115,17 @@ class Testcases(unittest.TestCase): BlockHeader(0, steem_instance=bts) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_export(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts + block_num = 2000000 else: - bts = self.appbase - block_num = 2000000 + bts = self.testnet + block_num = 2 + if bts.rpc.get_use_appbase(): block = bts.rpc.get_block({"block_num": block_num}, api="block") if block and "block" in block: diff --git a/tests/beem/test_blockchain.py b/tests/beem/test_blockchain.py index 2e2a34eee275ef350ff9073313f927843e98c7a9..a3b9cea5b923b70485b6fa10c832e97c5250eac0 100644 --- a/tests/beem/test_blockchain.py +++ b/tests/beem/test_blockchain.py @@ -27,13 +27,18 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, keys={"active": wif}, num_retries=10 ) - cls.appbase = Steem( - node=nodes_appbase, + b = Blockchain(steem_instance=cls.bts) + num = b.get_current_block_num() + cls.start = num - 25 + cls.stop = num + + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, keys={"active": wif}, num_retries=10 @@ -42,21 +47,20 @@ class Testcases(unittest.TestCase): # self.bts.wallet.unlock(getpass()) set_shared_steem_instance(cls.bts) cls.bts.set_default_account("test") - - b = Blockchain(steem_instance=cls.bts) + b = Blockchain(steem_instance=cls.testnet) num = b.get_current_block_num() - cls.start = num - 25 - cls.stop = num + cls.start_testnet = num - 25 + cls.stop_testnet = num @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_blockchain(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet b = Blockchain(steem_instance=bts) num = b.get_current_block_num() self.assertTrue(num > 0) @@ -71,14 +75,14 @@ class Testcases(unittest.TestCase): self.assertEqual(block_timestamp, timestamp) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_estimate_block_num(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet b = Blockchain(steem_instance=bts) last_block = b.get_current_block() num = last_block.identifier @@ -93,14 +97,14 @@ class Testcases(unittest.TestCase): est_block_num = b.get_estimated_block_num(date, estimateForwards=True, accurate=False) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_get_all_accounts(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet b = Blockchain(steem_instance=bts) accounts = [] limit = 200 @@ -110,14 +114,14 @@ class Testcases(unittest.TestCase): self.assertEqual(len(set(accounts)), limit) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_awaitTX(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet b = Blockchain(steem_instance=bts) trans = {'ref_block_num': 3855, 'ref_block_prefix': 1730859721, 'expiration': '2018-03-09T06:21:06', 'operations': [], @@ -129,47 +133,42 @@ class Testcases(unittest.TestCase): ): b.awaitTxConfirmation(trans) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_stream(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_stream(self): + bts = self.bts + start = self.start + stop = self.stop b = Blockchain(steem_instance=bts) ops_stream = [] opNames = ["transfer", "vote"] - for op in b.stream(opNames=opNames, start=self.start, stop=self.stop): + for op in b.stream(opNames=opNames, start=start, stop=stop): ops_stream.append(op) self.assertTrue(len(ops_stream) > 0) ops_raw_stream = [] opNames = ["transfer", "vote"] - for op in b.stream(opNames=opNames, raw_ops=True, start=self.start, stop=self.stop): + for op in b.stream(opNames=opNames, raw_ops=True, start=start, stop=stop): ops_raw_stream.append(op) self.assertTrue(len(ops_raw_stream) > 0) only_ops_stream = [] opNames = ["transfer", "vote"] - for op in b.stream(opNames=opNames, start=self.start, stop=self.stop, only_ops=True): + for op in b.stream(opNames=opNames, start=start, stop=stop, only_ops=True): only_ops_stream.append(op) self.assertTrue(len(only_ops_stream) > 0) only_ops_raw_stream = [] opNames = ["transfer", "vote"] - for op in b.stream(opNames=opNames, raw_ops=True, start=self.start, stop=self.stop, only_ops=True): + for op in b.stream(opNames=opNames, raw_ops=True, start=start, stop=stop, only_ops=True): only_ops_raw_stream.append(op) self.assertTrue(len(only_ops_raw_stream) > 0) - op_stat = b.ops_statistics(start=self.start, stop=self.stop) + op_stat = b.ops_statistics(start=start, stop=stop) op_stat2 = {"transfer": 0, "vote": 0} for op in ops_stream: self.assertIn(op["type"], opNames) op_stat2[op["type"]] += 1 - self.assertTrue(op["block_num"] >= self.start) - self.assertTrue(op["block_num"] <= self.stop) + self.assertTrue(op["block_num"] >= start) + self.assertTrue(op["block_num"] <= stop) self.assertEqual(op_stat["transfer"], op_stat2["transfer"]) self.assertEqual(op_stat["vote"], op_stat2["vote"]) @@ -177,8 +176,8 @@ class Testcases(unittest.TestCase): for op in ops_raw_stream: self.assertIn(op["op"][0], opNames) op_stat3[op["op"][0]] += 1 - self.assertTrue(op["block_num"] >= self.start) - self.assertTrue(op["block_num"] <= self.stop) + self.assertTrue(op["block_num"] >= start) + self.assertTrue(op["block_num"] <= stop) self.assertEqual(op_stat["transfer"], op_stat3["transfer"]) self.assertEqual(op_stat["vote"], op_stat3["vote"]) @@ -186,8 +185,8 @@ class Testcases(unittest.TestCase): for op in only_ops_stream: self.assertIn(op["type"], opNames) op_stat5[op["type"]] += 1 - self.assertTrue(op["block_num"] >= self.start) - self.assertTrue(op["block_num"] <= self.stop) + self.assertTrue(op["block_num"] >= start) + self.assertTrue(op["block_num"] <= stop) self.assertEqual(op_stat["transfer"], op_stat5["transfer"]) self.assertEqual(op_stat["vote"], op_stat5["vote"]) @@ -195,13 +194,13 @@ class Testcases(unittest.TestCase): for op in only_ops_raw_stream: self.assertIn(op["op"][0], opNames) op_stat6[op["op"][0]] += 1 - self.assertTrue(op["block_num"] >= self.start) - self.assertTrue(op["block_num"] <= self.stop) + self.assertTrue(op["block_num"] >= start) + self.assertTrue(op["block_num"] <= stop) self.assertEqual(op_stat["transfer"], op_stat6["transfer"]) self.assertEqual(op_stat["vote"], op_stat6["vote"]) ops_blocks = [] - for op in b.blocks(start=self.start, stop=self.stop): + for op in b.blocks(start=start, stop=stop): ops_blocks.append(op) op_stat4 = {"transfer": 0, "vote": 0} self.assertTrue(len(ops_blocks) > 0) @@ -216,8 +215,8 @@ class Testcases(unittest.TestCase): op_type = op_type[:-10] if op_type in opNames: op_stat4[op_type] += 1 - self.assertTrue(block.identifier >= self.start) - self.assertTrue(block.identifier <= self.stop) + self.assertTrue(block.identifier >= start) + self.assertTrue(block.identifier <= stop) self.assertEqual(op_stat["transfer"], op_stat4["transfer"]) self.assertEqual(op_stat["vote"], op_stat4["vote"]) @@ -228,14 +227,14 @@ class Testcases(unittest.TestCase): self.assertTrue(len(ops_blocks) == 1) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_stream2(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet b = Blockchain(steem_instance=bts) stop_block = b.get_current_block_num() start_block = stop_block - 10 @@ -245,14 +244,14 @@ class Testcases(unittest.TestCase): self.assertTrue(len(ops_stream) > 0) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_wait_for_and_get_block(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet b = Blockchain(steem_instance=bts, max_block_wait_repetition=18) start_num = b.get_current_block_num() blocknum = start_num @@ -282,7 +281,7 @@ class Testcases(unittest.TestCase): self.assertEqual(hash1, hash2) def test_signing_appbase(self): - b = Blockchain(steem_instance=self.appbase) + b = Blockchain(steem_instance=self.bts) st = None for block in b.blocks(start=25304468, stop=25304468): for trx in block.transactions: diff --git a/tests/beem/test_blockchain_batch.py b/tests/beem/test_blockchain_batch.py index f883695beea56962d85c569f3cace744c7b5be91..3a1b7be26db3833666ee97e2b4ff12742aa3e5fe 100644 --- a/tests/beem/test_blockchain_batch.py +++ b/tests/beem/test_blockchain_batch.py @@ -25,7 +25,7 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(normal=False, appbase=True, dev=True), + node=nodelist.get_nodes(), nobroadcast=True, num_retries=10, timeout=30, diff --git a/tests/beem/test_cli.py b/tests/beem/test_cli.py index 793abc3ef331e6949741b1e7e24cb5be74e82e41..bab365235c9ee5092f8b8f9a82329f23ccb8adee 100644 --- a/tests/beem/test_cli.py +++ b/tests/beem/test_cli.py @@ -28,6 +28,7 @@ class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): cls.nodelist = NodeList() + cls.nodelist.update_nodes() cls.nodelist.update_nodes(steem_instance=Steem(node=cls.nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) stm = shared_steem_instance() stm.config.refreshBackup() diff --git a/tests/beem/test_comment.py b/tests/beem/test_comment.py index 583d32270598d20f4ef1737042e11439302b23e8..df767971e0769130acbc8214df51a5fac8351745 100644 --- a/tests/beem/test_comment.py +++ b/tests/beem/test_comment.py @@ -23,15 +23,15 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), use_condenser=True, nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10 ) - cls.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, unsigned=True, keys={"active": wif}, @@ -50,15 +50,8 @@ class Testcases(unittest.TestCase): # set_shared_steem_instance(cls.bts) # cls.bts.set_default_account("test") - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_comment(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_comment(self): + bts = self.bts with self.assertRaises( exceptions.ContentDoesNotExistsException ): @@ -93,19 +86,11 @@ class Testcases(unittest.TestCase): self.assertTrue(isinstance(c.get_reblogged_by(), list)) self.assertTrue(len(c.get_reblogged_by()) > 0) self.assertTrue(isinstance(c.get_votes(), list)) - if node_param == "appbase": - self.assertTrue(len(c.get_votes()) > 0) - self.assertTrue(isinstance(c.get_votes()[0], Vote)) + self.assertTrue(len(c.get_votes()) > 0) + self.assertTrue(isinstance(c.get_votes()[0], Vote)) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_comment_dict(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_comment_dict(self): + bts = self.bts title = '' cnt = 0 while title == '' and cnt < 5: @@ -126,15 +111,8 @@ class Testcases(unittest.TestCase): self.assertEqual(c.parent_permlink, self.category) self.assertEqual(c.title, self.title) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_vote(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_vote(self): + bts = self.bts c = Comment(self.authorperm, steem_instance=bts) bts.txbuffer.clear() tx = c.vote(100, account="test") @@ -163,15 +141,8 @@ class Testcases(unittest.TestCase): op = tx["operations"][0][1] self.assertEqual(op["weight"], -9990) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_export(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_export(self): + bts = self.bts if bts.rpc.get_use_appbase(): content = bts.rpc.get_discussion({'author': self.author, 'permlink': self.permlink}, api="tags") diff --git a/tests/beem/test_connection.py b/tests/beem/test_connection.py index 31d130bd011b2885d101aca80bdea4baa8a5f193..5a529b24b71c96b4e97ed042ef109354556d96d3 100644 --- a/tests/beem/test_connection.py +++ b/tests/beem/test_connection.py @@ -21,7 +21,7 @@ class Testcases(unittest.TestCase): ) b2 = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, num_retries=10 ) @@ -39,7 +39,7 @@ class Testcases(unittest.TestCase): test = Account("beem") b2 = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, ) set_shared_steem_instance(b2) diff --git a/tests/beem/test_discussions.py b/tests/beem/test_discussions.py index 04d96277ad76eefd65fa9cd85dd48ea0f66d37eb..9e2f8cecc4dce5511ee477b1b59045f9918c4b23 100644 --- a/tests/beem/test_discussions.py +++ b/tests/beem/test_discussions.py @@ -27,14 +27,14 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), use_condenser=True, nobroadcast=True, keys={"active": wif}, num_retries=10 ) - cls.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, keys={"active": wif}, num_retries=10 @@ -44,75 +44,41 @@ class Testcases(unittest.TestCase): set_shared_steem_instance(cls.bts) cls.bts.set_default_account("test") - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_trending(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_trending(self): + bts = self.bts query = Query() query["limit"] = 10 query["tag"] = "steemit" d = Discussions_by_trending(query, steem_instance=bts) self.assertEqual(len(d), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_comment_payout(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_comment_payout(self): + bts = self.bts query = Query() query["limit"] = 10 query["tag"] = "steemit" d = Comment_discussions_by_payout(query, steem_instance=bts) self.assertEqual(len(d), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_post_payout(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_post_payout(self): + bts = self.bts + query = Query() query["limit"] = 10 query["tag"] = "steemit" d = Post_discussions_by_payout(query, steem_instance=bts) self.assertEqual(len(d), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_created(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_created(self): + bts = self.bts query = Query() query["limit"] = 10 query["tag"] = "steemit" d = Discussions_by_created(query, steem_instance=bts) self.assertEqual(len(d), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_active(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_active(self): + bts = self.bts query = Query() query["limit"] = 10 query["tag"] = "steemit" @@ -120,80 +86,45 @@ class Testcases(unittest.TestCase): self.assertEqual(len(d), 10) def test_cashout(self): - bts = self.appbase + bts = self.testnet query = Query(limit=10) Discussions_by_cashout(query, steem_instance=bts) # self.assertEqual(len(d), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_votes(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_votes(self): + bts = self.bts query = Query() query["limit"] = 10 query["tag"] = "steemit" d = Discussions_by_votes(query, steem_instance=bts) self.assertEqual(len(d), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_children(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_children(self): + bts = self.bts query = Query() query["limit"] = 10 query["tag"] = "steemit" d = Discussions_by_children(query, steem_instance=bts) self.assertEqual(len(d), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_feed(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_feed(self): + bts = self.bts query = Query() query["limit"] = 10 query["tag"] = "gtg" d = Discussions_by_feed(query, steem_instance=bts) self.assertEqual(len(d), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_blog(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_blog(self): + bts = self.bts query = Query() query["limit"] = 10 query["tag"] = "gtg" d = Discussions_by_blog(query, steem_instance=bts) self.assertEqual(len(d), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_comments(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_comments(self): + bts = self.bts query = Query() query["limit"] = 10 query["filter_tags"] = ["gtg"] @@ -201,15 +132,8 @@ class Testcases(unittest.TestCase): d = Discussions_by_comments(query, steem_instance=bts) self.assertEqual(len(d), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_promoted(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_promoted(self): + bts = self.bts query = Query() query["limit"] = 10 query["tag"] = "steemit" diff --git a/tests/beem/test_market.py b/tests/beem/test_market.py index ccb602b88a4336622dadb89271d015e37d55686a..766beea508541b09c45445bf948e691384582bcc 100644 --- a/tests/beem/test_market.py +++ b/tests/beem/test_market.py @@ -24,14 +24,14 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10 ) - cls.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, unsigned=True, keys={"active": wif}, @@ -43,14 +43,14 @@ class Testcases(unittest.TestCase): cls.bts.set_default_account("test") @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_market(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet m1 = Market(u'STEEM', u'SBD', steem_instance=bts) self.assertEqual(m1.get_string(), u'SBD:STEEM') m2 = Market(steem_instance=bts) @@ -65,14 +65,14 @@ class Testcases(unittest.TestCase): self.assertEqual(m.get_string(), u'STEEM:SBD') @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_ticker(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet m = Market(u'STEEM:SBD', steem_instance=bts) ticker = m.ticker() self.assertEqual(len(ticker), 6) @@ -80,28 +80,21 @@ class Testcases(unittest.TestCase): self.assertEqual(ticker['sbd_volume']["symbol"], u'SBD') @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_volume(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet m = Market(u'STEEM:SBD', steem_instance=bts) volume = m.volume24h() self.assertEqual(volume['STEEM']["symbol"], u'STEEM') self.assertEqual(volume['SBD']["symbol"], u'SBD') - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_orderbook(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_orderbook(self): + bts = self.bts m = Market(u'STEEM:SBD', steem_instance=bts) orderbook = m.orderbook(limit=10) self.assertEqual(len(orderbook['asks_date']), 10) @@ -109,30 +102,16 @@ class Testcases(unittest.TestCase): self.assertEqual(len(orderbook['bids_date']), 10) self.assertEqual(len(orderbook['bids']), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_recenttrades(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_recenttrades(self): + bts = self.bts m = Market(u'STEEM:SBD', steem_instance=bts) recenttrades = m.recent_trades(limit=10) recenttrades_raw = m.recent_trades(limit=10, raw_data=True) self.assertEqual(len(recenttrades), 10) self.assertEqual(len(recenttrades_raw), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_trades(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_trades(self): + bts = self.bts m = Market(u'STEEM:SBD', steem_instance=bts) trades = m.trades(limit=10) trades_raw = m.trades(limit=10, raw_data=True) @@ -141,42 +120,35 @@ class Testcases(unittest.TestCase): self.assertTrue(len(trades_history) > 0) self.assertEqual(len(trades_raw), 10) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_market_history(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_market_history(self): + bts = self.bts m = Market(u'STEEM:SBD', steem_instance=bts) buckets = m.market_history_buckets() history = m.market_history(buckets[2]) self.assertTrue(len(history) > 0) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_accountopenorders(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet m = Market(u'STEEM:SBD', steem_instance=bts) openOrder = m.accountopenorders("test") self.assertTrue(isinstance(openOrder, list)) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_buy(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet m = Market(u'STEEM:SBD', steem_instance=bts) bts.txbuffer.clear() tx = m.buy(5, 0.1, account="test") @@ -203,14 +175,14 @@ class Testcases(unittest.TestCase): self.assertEqual(str(Amount('0.500 SBD', steem_instance=bts)), op["amount_to_sell"]) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_sell(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet bts.txbuffer.clear() m = Market(u'STEEM:SBD', steem_instance=bts) tx = m.sell(5, 0.1, account="test") @@ -237,14 +209,14 @@ class Testcases(unittest.TestCase): self.assertEqual(str(Amount('0.100 STEEM', steem_instance=bts)), op["amount_to_sell"]) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_cancel(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet bts.txbuffer.clear() m = Market(u'STEEM:SBD', steem_instance=bts) tx = m.cancel(5, account="test") diff --git a/tests/beem/test_nodelist.py b/tests/beem/test_nodelist.py index ad4ac16c9746891d13b9fcde062ce29f006e3601..c3c556a5b1547696fc993a9b8747d2f77e0b0b63 100644 --- a/tests/beem/test_nodelist.py +++ b/tests/beem/test_nodelist.py @@ -15,7 +15,7 @@ class Testcases(unittest.TestCase): def setUpClass(cls): nodelist = NodeList() cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, num_retries=10 ) diff --git a/tests/beem/test_price.py b/tests/beem/test_price.py index 14beb82f9a5dbf99476a86d9a38a619015c28da7..c418746f20fb5a50581030124d635f371608e357 100644 --- a/tests/beem/test_price.py +++ b/tests/beem/test_price.py @@ -17,7 +17,7 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) steem = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, num_retries=10 ) diff --git a/tests/beem/test_steem.py b/tests/beem/test_steem.py index 2d90987e9cd9d0bfb4de9f540c09e9718720f9d6..b967d058f5862aa5347f36844d04056eca43a3cf 100644 --- a/tests/beem/test_steem.py +++ b/tests/beem/test_steem.py @@ -23,7 +23,7 @@ from beem.instance import set_shared_steem_instance from beem.nodelist import NodeList # Py3 compatibility import sys -core_unit = "STM" + wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -34,14 +34,14 @@ class Testcases(unittest.TestCase): cls.nodelist = NodeList() cls.nodelist.update_nodes(steem_instance=Steem(node=cls.nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=cls.nodelist.get_nodes(appbase=False), + 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.appbase = Steem( - node=cls.nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, @@ -49,19 +49,19 @@ class Testcases(unittest.TestCase): num_retries=10) cls.account = Account("test", full=True, steem_instance=cls.bts) - cls.account_appbase = Account("test", full=True, steem_instance=cls.appbase) + cls.account_testnet = Account("test", full=True, steem_instance=cls.testnet) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_transfer(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts acc = self.account - elif node_param == "appbase": - bts = self.appbase - acc = self.account_appbase + elif node_param == "testnet": + bts = self.testnet + acc = self.account_testnet acc.steem.txbuffer.clear() tx = acc.transfer( "test", 1.33, "SBD", memo="Foobar", account="test1") @@ -79,24 +79,26 @@ class Testcases(unittest.TestCase): self.assertEqual(float(amount), 1.33) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_create_account(self, node_param): - if node_param == "non_appbase": - bts = Steem(node=self.nodelist.get_nodes(appbase=False), + if node_param == "normal": + bts = Steem(node=self.nodelist.get_nodes(), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) - elif node_param == "appbase": - bts = Steem(node=self.nodelist.get_nodes(normal=False, appbase=True), + core_unit = "STM" + elif node_param == "testnet": + bts = Steem(node="https://testnet.steemitdev.com", nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) + core_unit = "TST" name = ''.join(random.choice(string.ascii_lowercase) for _ in range(12)) key1 = PrivateKey() key2 = PrivateKey() @@ -159,24 +161,26 @@ class Testcases(unittest.TestCase): "test") @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_create_account_password(self, node_param): - if node_param == "non_appbase": - bts = Steem(node=self.nodelist.get_nodes(appbase=False), + if node_param == "normal": + bts = Steem(node=self.nodelist.get_nodes(), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) - elif node_param == "appbase": - bts = Steem(node=self.nodelist.get_nodes(normal=False, appbase=True), + core_unit = "STM" + elif node_param == "testnet": + bts = Steem(node="https://testnet.steemitdev.com", nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) + core_unit = "TST" name = ''.join(random.choice(string.ascii_lowercase) for _ in range(12)) key5 = PrivateKey() bts.txbuffer.clear() @@ -222,24 +226,26 @@ class Testcases(unittest.TestCase): "test") @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_create_account_with_delegation(self, node_param): - if node_param == "non_appbase": - bts = Steem(node=self.nodelist.get_nodes(appbase=False), + if node_param == "normal": + bts = Steem(node=self.nodelist.get_nodes(), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) - elif node_param == "appbase": - bts = Steem(node=self.nodelist.get_nodes(normal=False, appbase=True), + core_unit = "STM" + elif node_param == "testnet": + bts = Steem(node="https://testnet.steemitdev.com", nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) + core_unit = "TST" name = ''.join(random.choice(string.ascii_lowercase) for _ in range(12)) key1 = PrivateKey() key2 = PrivateKey() @@ -291,25 +297,25 @@ class Testcases(unittest.TestCase): "test") @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_connect(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts - elif node_param == "appbase": - bts = self.appbase + elif node_param == "testnet": + bts = self.testnet bts.connect() @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_info(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts - elif node_param == "appbase": - bts = self.appbase + elif node_param == "testnet": + bts = self.testnet info = bts.info() for key in ['current_witness', 'head_block_id', @@ -321,17 +327,9 @@ class Testcases(unittest.TestCase): 'time']: self.assertTrue(key in info) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_finalizeOps(self, node_param): - if node_param == "non_appbase": - bts = self.bts - acc = self.account - elif node_param == "appbase": - bts = self.appbase - acc = self.account_appbase + def test_finalizeOps(self): + bts = self.bts + acc = self.account tx1 = bts.new_tx() tx2 = bts.new_tx() @@ -346,46 +344,54 @@ class Testcases(unittest.TestCase): self.assertEqual(len(ops2), 1) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_weight_threshold(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts - elif node_param == "appbase": - bts = self.appbase + pkey1 = 'STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n' + pkey2 = 'STM7GM9YXcsoAJAgKbqW2oVj7bnNXFNL4pk9NugqKWPmuhoEDbkDv' + elif node_param == "testnet": + bts = self.testnet + pkey1 = 'TST55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n' + pkey2 = 'TST7GM9YXcsoAJAgKbqW2oVj7bnNXFNL4pk9NugqKWPmuhoEDbkDv' auth = {'account_auths': [['test', 1]], 'extensions': [], 'key_auths': [ - ['STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n', 1], - ['STM7GM9YXcsoAJAgKbqW2oVj7bnNXFNL4pk9NugqKWPmuhoEDbkDv', 1]], + [pkey1, 1], + [pkey2, 1]], 'weight_threshold': 3} # threshold fine bts._test_weights_treshold(auth) auth = {'account_auths': [['test', 1]], 'extensions': [], 'key_auths': [ - ['STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n', 1], - ['STM7GM9YXcsoAJAgKbqW2oVj7bnNXFNL4pk9NugqKWPmuhoEDbkDv', 1]], + [pkey1, 1], + [pkey2, 1]], 'weight_threshold': 4} # too high with self.assertRaises(ValueError): bts._test_weights_treshold(auth) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_allow(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts acc = self.account - elif node_param == "appbase": - bts = self.appbase - acc = self.account_appbase - self.assertIn(bts.prefix, "STM") + prefix = "STM" + wif = "STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n" + elif node_param == "testnet": + bts = self.testnet + acc = self.account_testnet + prefix = "TST" + wif = "TST55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n" + self.assertIn(bts.prefix, prefix) tx = acc.allow( - "STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n", + wif, account="test", weight=1, threshold=1, @@ -398,49 +404,40 @@ class Testcases(unittest.TestCase): op = tx["operations"][0][1] self.assertIn("owner", op) self.assertIn( - ["STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n", '1'], + [wif, '1'], op["owner"]["key_auths"]) self.assertEqual(op["owner"]["weight_threshold"], 1) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_disallow(self, node_param): - if node_param == "non_appbase": - acc = self.account - elif node_param == "appbase": - acc = self.account_appbase + def test_disallow(self): + acc = self.account + pkey1 = "STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n" + pkey2 = "STM6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" if sys.version > '3': _assertRaisesRegex = self.assertRaisesRegex else: _assertRaisesRegex = self.assertRaisesRegexp with _assertRaisesRegex(ValueError, ".*Changes nothing.*"): acc.disallow( - "STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n", + pkey1, weight=1, threshold=1, permission="owner" ) with _assertRaisesRegex(ValueError, ".*Changes nothing!.*"): acc.disallow( - "STM6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", + pkey2, weight=1, threshold=1, permission="owner" ) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_update_memo_key(self, node_param): - if node_param == "non_appbase": - acc = self.account - elif node_param == "appbase": - acc = self.account_appbase + def test_update_memo_key(self): + acc = self.account + prefix = "STM" + pkey = 'STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n' + self.assertEqual(acc.steem.prefix, prefix) acc.steem.txbuffer.clear() - tx = acc.update_memo_key("STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n") + tx = acc.update_memo_key(pkey) self.assertEqual( (tx["operations"][0][0]), "account_update" @@ -448,17 +445,17 @@ class Testcases(unittest.TestCase): op = tx["operations"][0][1] self.assertEqual( op["memo_key"], - "STM55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n") + pkey) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_approvewitness(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": w = self.account - elif node_param == "appbase": - w = self.account_appbase + elif node_param == "testnet": + w = self.account_testnet w.steem.txbuffer.clear() tx = w.approvewitness("test1") self.assertEqual( @@ -519,7 +516,7 @@ class Testcases(unittest.TestCase): self.assertFalse(bts.get_blockchain_version() == '0.0.0') def test_offline(self): - bts = Steem(node=self.nodelist.get_nodes(appbase=False), + bts = Steem(node=self.nodelist.get_nodes(), offline=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}) @@ -544,18 +541,18 @@ class Testcases(unittest.TestCase): self.assertEqual(bts.get_blockchain_version(), '0.0.0') @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_properties(self, node_param): - if node_param == "non_appbase": - bts = Steem(node=self.nodelist.get_nodes(appbase=False), + if node_param == "normal": + bts = Steem(node=self.nodelist.get_nodes(), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) - elif node_param == "appbase": - bts = Steem(node=self.nodelist.get_nodes(normal=False, appbase=True), + elif node_param == "testnet": + bts = Steem(node="https://testnet.steemitdev.com", nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, diff --git a/tests/beem/test_steemconnect.py b/tests/beem/test_steemconnect.py index b3bfa19c75d37283512c1becc717bd5e2ee0e098..104a14e2dbe4f428c8d84a1a2d08f8640c75e2d6 100644 --- a/tests/beem/test_steemconnect.py +++ b/tests/beem/test_steemconnect.py @@ -34,32 +34,32 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, num_retries=10) - cls.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, num_retries=10) cls.account = Account("test", full=True, steem_instance=cls.bts) - cls.account_appbase = Account("test", full=True, steem_instance=cls.appbase) + cls.account_testnet = Account("test", full=True, steem_instance=cls.testnet) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_transfer(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts acc = self.account - elif node_param == "appbase": - bts = self.appbase - acc = self.account_appbase + elif node_param == "testnet": + bts = self.testnet + acc = self.account_testnet acc.steem.txbuffer.clear() tx = acc.transfer( "test1", 1.000, "STEEM", memo="test") @@ -77,14 +77,14 @@ class Testcases(unittest.TestCase): self.assertEqual(len(list(set(url_parts).intersection(set(url_test_parts)))), 4) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_login_url(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts - elif node_param == "appbase": - bts = self.appbase + elif node_param == "testnet": + bts = self.testnet sc2 = SteemConnect(steem_instance=bts) url = sc2.get_login_url("localhost", scope="login,vote") url_test = 'https://steemconnect.com/oauth2/authorize?client_id=None&redirect_uri=localhost&scope=login,vote' diff --git a/tests/beem/test_storage.py b/tests/beem/test_storage.py index 314da3aa8304b9da94e96cba64976badc031d396..36133c4829e2898e274f3d4c4dff659719bddb0e 100644 --- a/tests/beem/test_storage.py +++ b/tests/beem/test_storage.py @@ -36,15 +36,15 @@ class Testcases(unittest.TestCase): nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.stm = Steem( - node=nodelist.get_nodes(appbase=False), + 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.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, bundle=True, num_retries=10 @@ -65,14 +65,14 @@ class Testcases(unittest.TestCase): stm.config.recover_with_latest_backup() @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_set_default_account(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": stm = self.stm - elif node_param == "appbase": - stm = self.appbase + elif node_param == "testnet": + stm = self.testnet stm.set_default_account("test") self.assertEqual(stm.config["default_account"], "test") diff --git a/tests/beem/test_txbuffers.py b/tests/beem/test_txbuffers.py index 7763cc1ad2fe2b1409abcd8331450612d92da539..4e06fa27daa6344fe54f6bf16d3121575cb92051 100644 --- a/tests/beem/test_txbuffers.py +++ b/tests/beem/test_txbuffers.py @@ -34,13 +34,13 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.stm = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), keys={"active": wif, "owner": wif, "memo": wif}, nobroadcast=True, num_retries=10 ) - cls.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10 diff --git a/tests/beem/test_vote.py b/tests/beem/test_vote.py index b9bebcefb58f550cb7ceba1903efcfc1ec06e094..f1ecd70708468355f22d567532eaa6127558298b 100644 --- a/tests/beem/test_vote.py +++ b/tests/beem/test_vote.py @@ -25,13 +25,13 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, keys={"active": wif}, num_retries=10 ) - cls.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, keys={"active": wif}, num_retries=10 @@ -59,15 +59,8 @@ class Testcases(unittest.TestCase): cls.voter = voter cls.authorperm = construct_authorperm(author, permlink) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_vote(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_vote(self): + bts = self.bts vote = Vote(self.authorpermvoter, steem_instance=bts) self.assertEqual(self.voter, vote["voter"]) self.assertEqual(self.author, vote["author"]) @@ -103,14 +96,14 @@ class Testcases(unittest.TestCase): self.assertTrue(vote.time is not None) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_keyerror(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet with self.assertRaises( exceptions.VoteDoesNotExistsException ): @@ -127,28 +120,21 @@ class Testcases(unittest.TestCase): Vote(construct_authorpermvoter("sdalfj", "dsfa", "asdfsldfjlasd"), steem_instance=bts) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_activevotes(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet votes = ActiveVotes(self.authorperm, steem_instance=bts) votes.printAsTable() vote_list = votes.get_list() self.assertTrue(isinstance(vote_list, list)) - @parameterized.expand([ - ("non_appbase"), - ("appbase"), - ]) - def test_accountvotes(self, node_param): - if node_param == "non_appbase": - bts = self.bts - else: - bts = self.appbase + def test_accountvotes(self): + bts = self.bts utc = pytz.timezone('UTC') limit_time = utc.localize(datetime.utcnow()) - timedelta(days=7) votes = AccountVotes(self.author, start=limit_time, steem_instance=bts) diff --git a/tests/beem/test_wallet.py b/tests/beem/test_wallet.py index a3213b7981353118766eb8b782ab18107dd28cf1..aef4832b7fcf43b16bbde69ad003a8380092a9ba 100644 --- a/tests/beem/test_wallet.py +++ b/tests/beem/test_wallet.py @@ -27,15 +27,15 @@ class Testcases(unittest.TestCase): nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.stm = Steem( - node=nodelist.get_nodes(appbase=False), + 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.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + node="https://testnet.steemitdev.com", nobroadcast=True, bundle=True, num_retries=10 @@ -88,14 +88,14 @@ class Testcases(unittest.TestCase): self.assertEqual(private, wif) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_account_by_pub(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": stm = self.stm else: - stm = self.appbase + stm = self.testnet self.wallet.steem = stm self.wallet.unlock(pwd="TestingOneTwoThree") acc = Account("gtg") @@ -115,14 +115,14 @@ class Testcases(unittest.TestCase): self.assertEqual(pub, acc_by_pub_list[0]["pubkey"]) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_pub_lookup(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": stm = self.stm else: - stm = self.appbase + stm = self.testnet self.wallet.steem = stm self.wallet.unlock(pwd="TestingOneTwoThree") with self.assertRaises( @@ -143,14 +143,14 @@ class Testcases(unittest.TestCase): self.wallet.getPostingKeyForAccount("test") @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_pub_lookup_keys(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": stm = self.stm else: - stm = self.appbase + stm = self.testnet self.wallet.steem = stm self.wallet.unlock(pwd="TestingOneTwoThree") with self.assertRaises( diff --git a/tests/beem/test_witness.py b/tests/beem/test_witness.py index 9ac46018ff64474fbc05ed5fa42965bbab4d5558..fc8433fe633c02c581a78b0abcf091f90f776482 100644 --- a/tests/beem/test_witness.py +++ b/tests/beem/test_witness.py @@ -20,14 +20,15 @@ class Testcases(unittest.TestCase): nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) cls.bts = Steem( - node=nodelist.get_nodes(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10 ) - cls.appbase = Steem( - node=nodelist.get_nodes(normal=False, appbase=True), + cls.testnet = Steem( + # node="https://testnet.timcliff.com", + node=nodelist.get_nodes(), nobroadcast=True, unsigned=True, keys={"active": wif}, @@ -39,14 +40,14 @@ class Testcases(unittest.TestCase): cls.bts.set_default_account("test") @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_feed_publish(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet bts.txbuffer.clear() w = Witness("gtg", steem_instance=bts) tx = w.feed_publish("4 SBD", "1 STEEM") @@ -60,14 +61,14 @@ class Testcases(unittest.TestCase): op["publisher"]) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_update(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet bts.txbuffer.clear() w = Witness("gtg", steem_instance=bts) props = {"account_creation_fee": "0.1 STEEM", @@ -81,56 +82,56 @@ class Testcases(unittest.TestCase): op["owner"]) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_witnesses(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet w = Witnesses(steem_instance=bts) w.printAsTable() self.assertTrue(len(w) > 0) self.assertTrue(isinstance(w[0], Witness)) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_WitnessesVotedByAccount(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet w = WitnessesVotedByAccount("gtg", steem_instance=bts) w.printAsTable() self.assertTrue(len(w) > 0) self.assertTrue(isinstance(w[0], Witness)) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_WitnessesRankedByVote(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet w = WitnessesRankedByVote(steem_instance=bts) w.printAsTable() self.assertTrue(len(w) > 0) self.assertTrue(isinstance(w[0], Witness)) @parameterized.expand([ - ("non_appbase"), - ("appbase"), + ("normal"), + ("testnet"), ]) def test_export(self, node_param): - if node_param == "non_appbase": + if node_param == "normal": bts = self.bts else: - bts = self.appbase + bts = self.testnet owner = "gtg" if bts.rpc.get_use_appbase(): witness = bts.rpc.find_witnesses({'owners': [owner]}, api="database")['witnesses'] diff --git a/tests/beemapi/test_steemnoderpc.py b/tests/beemapi/test_steemnoderpc.py index f0556c6957a48883ab655f349b0a6205ff5a879c..662a5a5e552288713b7973ff03cc30a6b09741b3 100644 --- a/tests/beemapi/test_steemnoderpc.py +++ b/tests/beemapi/test_steemnoderpc.py @@ -36,12 +36,7 @@ class Testcases(unittest.TestCase): 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 = Steem( - node=cls.nodes, - nobroadcast=True, - keys={"active": wif, "owner": wif, "memo": wif}, - num_retries=10 - ) + cls.appbase = Steem( node=cls.nodes_appbase, nobroadcast=True, @@ -51,24 +46,14 @@ class Testcases(unittest.TestCase): cls.rpc = SteemNodeRPC(urls=cls.test_list) # from getpass import getpass # self.bts.wallet.unlock(getpass()) - set_shared_steem_instance(cls.bts) - cls.bts.set_default_account("test") + set_shared_steem_instance(cls.appbase) + cls.appbase.set_default_account("test") def get_reply(self, msg): reply = '<html> <head><title>403 Forbidden</title></head><body bgcolor="white"><center><h1>' \ '%s</h1></center><hr><center>nginx</center></body> </html>' % (msg) return reply - def test_non_appbase(self): - bts = self.bts - 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)) - with self.assertRaises( - exceptions.NoMethodWithName - ): - bts.rpc.get_config_abc() - def test_appbase(self): bts = self.appbase self.assertTrue(bts.chain_params['min_version'] == '0.19.10') @@ -83,16 +68,6 @@ class Testcases(unittest.TestCase): ): bts.rpc.get_config_abc() - def test_normal_appbase_switch(self): - bts = Steem(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_connect_test_node(self): rpc = self.rpc self.assertIn(rpc.url, self.nodes + self.nodes_appbase + self.nodes_https) @@ -203,7 +178,7 @@ class Testcases(unittest.TestCase): SteemNodeRPC(urls=nodes, num_retries=0, num_retries_call=0, timeout=1) def test_error_handling(self): - rpc = SteemNodeRPC(urls=self.nodes, num_retries=2, num_retries_call=3) + rpc = SteemNodeRPC(urls=self.nodes_appbase, num_retries=2, num_retries_call=3) with self.assertRaises( exceptions.NoMethodWithName ): diff --git a/tests/beemapi/test_websocket.py b/tests/beemapi/test_websocket.py index 0b2bb21cb66b19d40bad6ca9ad75903a46db0eaf..a0da41054f7f2dfc285b9bbaaa39d8b8bc24ac44 100644 --- a/tests/beemapi/test_websocket.py +++ b/tests/beemapi/test_websocket.py @@ -27,7 +27,7 @@ class Testcases(unittest.TestCase): super().__init__(*args, **kwargs) nodelist = NodeList() nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(normal=True, appbase=True), num_retries=10)) - stm = Steem(node=nodelist.get_nodes(appbase=False)) + stm = Steem(node=nodelist.get_nodes()) self.ws = SteemWebsocket( urls=stm.rpc.nodes,