diff --git a/beem/__init__.py b/beem/__init__.py index e716f4986d0755bf85d8f896d8f57811160ee331..aa25ea60cf067fb01dcdfe991bdb4420258d5f49 100644 --- a/beem/__init__.py +++ b/beem/__init__.py @@ -20,5 +20,6 @@ __all__ = [ "comment", "discussions", "witness", - "profile" + "profile", + "nodelist" ] diff --git a/beem/cli.py b/beem/cli.py index ac1f049788461105d4f4cb50f09d25de2905e23b..1778cab145e610220135be84c2d8c28a20fb1e4b 100644 --- a/beem/cli.py +++ b/beem/cli.py @@ -175,7 +175,7 @@ def cli(node, offline, no_broadcast, no_wallet, unsigned, expires, verbose): debug=debug, num_retries=10, num_retries_call=3, - timeout=10, + timeout=15, autoconnect=False ) set_shared_steem_instance(stm) diff --git a/beem/exceptions.py b/beem/exceptions.py index f7e93172bd19ebd1b929d88ecf9c34edc9f5a1aa..ee7dddefd8b729c57d724313c365d5e27c501169 100644 --- a/beem/exceptions.py +++ b/beem/exceptions.py @@ -133,12 +133,6 @@ class VestingBalanceDoesNotExistsException(Exception): pass -class ObjectNotInProposalBuffer(Exception): - """ Object was not found in proposal - """ - pass - - class InvalidMessageSignature(Exception): """ The message signature does not fit the message """ diff --git a/beem/nodelist.py b/beem/nodelist.py new file mode 100644 index 0000000000000000000000000000000000000000..2fd9975f5362c4c8103a60d6a4d78c37a5176df4 --- /dev/null +++ b/beem/nodelist.py @@ -0,0 +1,247 @@ +# This Python file uses the following encoding: utf-8 +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +from builtins import next +import re +import time +import math + + +class NodeList(list): + def __init__(self): + nodes = [ + { + "url": "https://api.steemit.com", + "version": "0.19.4", + "type": "appbase", + "owner": "steemit", + "score": 100 + }, + { + "url": "wss://appbasetest.timcliff.com", + "version": "0.19.4", + "type": "appbase", + "owner": "timcliff", + "score": 20 + }, + { + "url": "https://appbasetest.timcliff.com", + "version": "0.19.4", + "type": "appbase", + "owner": "timcliff", + "score": 10 + }, + { + "url": "https://api.steem.house", + "version": "0.19.4", + "type": "appbase", + "owner": "gtg", + "score": 90 + }, + { + "url": "https://api.steemitdev.com", + "version": "0.19.4", + "type": "appbase-dev", + "owner": "steemit", + "score": 100 + }, + { + "url": "https://api.steemitstage.com", + "version": "0.19.4", + "type": "appbase-dev", + "owner": "steemit", + "score": 110 + }, + { + "url": "wss://rpc.steemviz.com", + "version": "0.19.3", + "type": "normal", + "owner": "ausbitbank", + "score": 175 + }, + { + "url": "https://rpc.steemviz.com", + "version": "0.19.3", + "type": "normal", + "owner": "ausbitbank", + "score": 80 + }, + { + "url": "wss://steemd.privex.io", + "version": "0.19.3", + "type": "normal", + "owner": "privex", + "score": 90 + }, + { + "url": "https://steemd.privex.io", + "version": "0.19.3", + "type": "normal", + "owner": "privex", + "score": 50 + }, + { + "url": "wss://rpc.buildteam.io", + "version": "0.19.3", + "type": "normal", + "owner": "themarkymark", + "score": 165 + }, + { + "url": "https://rpc.buildteam.io", + "version": "0.19.3", + "type": "normal", + "owner": "themarkymark", + "score": 120 + }, + { + "url": "wss://gtg.steem.house:8090", + "version": "0.19.3", + "type": "normal", + "owner": "gtg", + "score": 75 + }, + { + "url": "https://gtg.steem.house:8090", + "version": "0.19.3", + "type": "normal", + "owner": "gtg", + "score": 80 + }, + { + "url": "wss://steemd.pevo.science", + "version": "0.19.3", + "type": "normal", + "owner": "pharesim", + "score": 170 + }, + { + "url": "https://steemd.pevo.science", + "version": "0.19.3", + "type": "normal", + "owner": "pharesim", + "score": 30 + }, + { + "url": "wss://rpc.steemliberator.com", + "version": "0.19.3", + "type": "normal", + "owner": "netuoso", + "score": 20 + }, + { + "url": "https://rpc.steemliberator.com", + "version": "0.19.3", + "type": "normal", + "owner": "netuoso", + "score": 10 + }, + { + "url": "wss://seed.bitcoiner.me", + "version": "0.19.3", + "type": "normal", + "owner": "bitcoiner", + "score": 1 + }, + { + "url": "https://seed.bitcoiner.me", + "version": "0.19.3", + "type": "normal", + "owner": "bitcoiner", + "score": 1 + }, + { + "url": "wss://steemd.steemgigs.org", + "version": "0.19.3", + "type": "normal", + "owner": "steemgigs", + "score": 10 + }, + { + "url": "https://steemd.steemgigs.org", + "version": "0.19.3", + "type": "normal", + "owner": "steemgigs", + "score": 10 + }, + { + "url": "wss://steemd.minnowsupportproject.org", + "version": "0.19.3", + "type": "normal", + "owner": "followbtcnews", + "score": 10 + }, + { + "url": "https://steemd.minnowsupportproject.org", + "version": "0.19.3", + "type": "normal", + "owner": "followbtcnews", + "score": 10 + }, + { + "url": "https://rpc.curiesteem.com", + "version": "0.19.3", + "type": "normal", + "owner": "curie", + "score": 50 + }, + { + "url": "wss://testnet.steem.vc", + "version": "0.19.2", + "type": "testnet", + "owner": "almost-digital", + "score": 1 + }, + { + "url": "ws://testnet.steem.vc", + "version": "0.19.2", + "type": "testnet", + "owner": "almost-digital", + "score": 5 + }, + { + "url": "https://testnet.steem.vc", + "version": "0.19.2", + "type": "testnet", + "owner": "almost-digital", + "score": 1 + }, + { + "url": "http://testnet.steem.vc", + "version": "0.19.2", + "type": "testnet", + "owner": "almost-digital", + "score": 5 + } + ] + super(NodeList, self).__init__(nodes) + + def get_nodes(self, normal=True, appbase=True, dev=False, testnet=False): + """ Returns nodes as list + + :param bool normal: when True, nodes with version 0.19.2 or 0.19.3 are included + :param bool appbase: when True, nodes with version 0.19.4 are included + :param bool dev: when True, dev nodes with version 0.19.4 are included + :param bool testnet: when True, testnet nodes are included + + """ + node_list = [] + node_type_list = [] + if normal: + node_type_list.append("normal") + if appbase: + node_type_list.append("appbase") + if dev: + node_type_list.append("appbase-dev") + if testnet: + node_type_list.append("testnet") + for node in self: + if node["type"] in node_type_list: + node_list.append(node) + return [node["url"] for node in sorted(node_list, key=lambda self: self['score'], reverse=True)] + + def get_testnet(self): + """Returns testnet nodes""" + return self.get_nodes(normal=False, appbase=False, testnet=True) diff --git a/beem/storage.py b/beem/storage.py index 2cffb88c3203d0ebe38a16f998b84033e4663027..7c33dc9a3b29b2dd98801a5f147af6d849c6b695 100644 --- a/beem/storage.py +++ b/beem/storage.py @@ -18,7 +18,7 @@ from binascii import hexlify import random import hashlib from .exceptions import WrongMasterPasswordException, NoWriteAccess -from .utils import get_node_list +from .nodelist import NodeList log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) log.addHandler(logging.StreamHandler()) @@ -273,7 +273,8 @@ class Configuration(DataDir): __tablename__ = "config" #: Default configuration - nodes = get_node_list(appbase=False) + get_node_list(appbase=True) + nodelist = NodeList() + nodes = nodelist.get_nodes(normal=True, appbase=True, dev=False, testnet=False) config_defaults = { "node": nodes, "password_storage": "environment", diff --git a/beem/utils.py b/beem/utils.py index 18c58e96e20b50fc11730707b368ade5e7f750a2..2ecbeb39f3be13d1816dab18472a2503f4625c6e 100644 --- a/beem/utils.py +++ b/beem/utils.py @@ -10,7 +10,6 @@ import math from datetime import datetime, tzinfo, timedelta import pytz import difflib -from .exceptions import ObjectNotInProposalBuffer timeFormat = '%Y-%m-%dT%H:%M:%S' # https://github.com/matiasb/python-unidiff/blob/master/unidiff/constants.py#L37 @@ -257,23 +256,3 @@ def make_patch(a, b, n=3): def findall_patch_hunks(body=None): return RE_HUNK_HEADER.findall(body) - - -def get_node_list(appbase=False, testing=False): - """Returns node list""" - if appbase: - node_list = ["https://api.steemit.com", "wss://appbasetest.timcliff.com", "https://api.steem.house"] - if testing: - node_list = ["https://api.steemitdev.com", "https://api.steemitstage.com"] + node_list - return node_list - else: - return ["wss://steemd.privex.io", "wss://rpc.buildteam.io", "https://steemd.privex.io", "https://rpc.buildteam.io", "wss://steemd.pevo.science", - "wss://rpc.steemliberator.com", "wss://gtg.steem.house:8090", - "wss://rpc.steemviz.com", "wss://seed.bitcoiner.me", "wss://steemd.steemgigs.org", "wss://steemd.minnowsupportproject.org", - "https://steemd.minnowsupportproject.org", "https://steemd.pevo.science", "https://rpc.steemviz.com", "https://seed.bitcoiner.me", - "https://rpc.steemliberator.com", "https://gtg.steem.house:8090", - "https://rpc.curiesteem.com", "https://steemd.steemgigs.org"] - - -def get_test_node_list(): - return ["wss://testnet.steem.vc", "ws://testnet.steem.vc", "https://testnet.steem.vc", "http://testnet.steem.vc"] diff --git a/beemapi/__init__.py b/beemapi/__init__.py index 024b915de1faef7435fad1b4485b787525c2e2a2..d96158f435ffc7936e08099ff0c05139695a7367 100644 --- a/beemapi/__init__.py +++ b/beemapi/__init__.py @@ -4,4 +4,7 @@ __all__ = [ "steemnoderpc", "exceptions", "websocket", + "rpcutils", + "graphenerpc", + "node", ] diff --git a/examples/benchmark_nodes.py b/examples/benchmark_nodes.py index a82d37b9f188c98f09e6b6d81920e15aaf14cfa7..6079c10c842e0f7fd3a823f717f57e16207b1218 100644 --- a/examples/benchmark_nodes.py +++ b/examples/benchmark_nodes.py @@ -12,7 +12,8 @@ from beem.blockchain import Blockchain from beem.account import Account from beem.block import Block from beem.steem import Steem -from beem.utils import parse_time, formatTimedelta, get_node_list +from beem.utils import parse_time, formatTimedelta +from beem.nodelist import NodeList from beemapi.exceptions import NumRetriesReached log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) @@ -24,7 +25,8 @@ if __name__ == "__main__": max_batch_size = None threading = False thread_num = 16 - nodes = get_node_list(appbase=False) + get_node_list(appbase=True) + nodelist = NodeList() + nodes = nodelist.get_nodes(normal=True, appbase=True, dev=True) t = PrettyTable(["node", "10 blockchain minutes", "10000 virtual account op", "version"]) t.align = "l" for node in nodes: diff --git a/examples/benchmark_nodes2.py b/examples/benchmark_nodes2.py index 0e28887971e70c9b403d74d1fe7637d08effbc4d..ebfba89709078bffa13310b4573d37019724b73a 100644 --- a/examples/benchmark_nodes2.py +++ b/examples/benchmark_nodes2.py @@ -13,8 +13,9 @@ from beem.blockchain import Blockchain from beem.account import Account from beem.block import Block from beem.steem import Steem -from beem.utils import parse_time, formatTimedelta, get_node_list, construct_authorperm, resolve_authorperm, resolve_authorpermvoter, construct_authorpermvoter +from beem.utils import parse_time, formatTimedelta, construct_authorperm, resolve_authorperm, resolve_authorpermvoter, construct_authorpermvoter, formatTimeString from beem.comment import Comment +from beem.nodelist import NodeList from beem.vote import Vote from beemapi.exceptions import NumRetriesReached FUTURES_MODULE = None @@ -35,19 +36,22 @@ def benchmark_node(node, how_many_minutes=10, how_many_seconds=30): access_time = 0 follow_time = 0 blockchain_version = u'0.0.0' - sucessfull = False + sucessfull = True error_msg = None start_total = timer() max_batch_size = None threading = False thread_num = 16 + + authorpermvoter = u"@gtg/steem-pressure-4-need-for-speed|gandalf" + [author, permlink, voter] = resolve_authorpermvoter(authorpermvoter) + authorperm = construct_authorperm(author, permlink) + last_block_id = 19273700 try: - stm = Steem(node=node, num_retries=2, num_retries_call=3, timeout=10) + stm = Steem(node=node, num_retries=3, num_retries_call=3, timeout=30) blockchain = Blockchain(steem_instance=stm) - account = Account("gtg", steem_instance=stm) blockchain_version = stm.get_blockchain_version() - last_block_id = 19273700 last_block = Block(last_block_id, steem_instance=stm) stopTime = last_block.time() + timedelta(seconds=how_many_minutes * 60) @@ -75,12 +79,45 @@ def benchmark_node(node, how_many_minutes=10, how_many_seconds=30): break if timer() - start > how_many_seconds or quit_thread: break + except NumRetriesReached: + error_msg = 'NumRetriesReached' + block_count = -1 + except KeyboardInterrupt: + error_msg = 'KeyboardInterrupt' + # quit = True + except Exception as e: + error_msg = str(e) + block_count = -1 + + try: + stm = Steem(node=node, num_retries=3, num_retries_call=3, timeout=30) + account = Account("gtg", steem_instance=stm) + blockchain_version = stm.get_blockchain_version() start = timer() for acc_op in account.history_reverse(batch_size=100): history_count += 1 if timer() - start > how_many_seconds or quit_thread: break + except NumRetriesReached: + error_msg = 'NumRetriesReached' + history_count = -1 + sucessfull = False + except KeyboardInterrupt: + error_msg = 'KeyboardInterrupt' + history_count = -1 + sucessfull = False + # quit = True + except Exception as e: + error_msg = str(e) + history_count = -1 + sucessfull = False + + try: + stm = Steem(node=node, num_retries=3, num_retries_call=3, timeout=30) + account = Account("gtg", steem_instance=stm) + blockchain_version = stm.get_blockchain_version() + start = timer() Vote(authorpermvoter, steem_instance=stm) stop = timer() @@ -98,14 +135,15 @@ def benchmark_node(node, how_many_minutes=10, how_many_seconds=30): stop = timer() follow_time = stop - start access_time = (vote_time + comment_time + account_time + follow_time) / 4.0 - sucessfull = True except NumRetriesReached: error_msg = 'NumRetriesReached' + access_time = -1 except KeyboardInterrupt: error_msg = 'KeyboardInterrupt' # quit = True except Exception as e: error_msg = str(e) + access_time = -1 return {'sucessfull': sucessfull, 'node': node, 'error': error_msg, 'total_duration': timer() - start_total, 'block_count': block_count, 'history_count': history_count, 'access_time': access_time, 'follow_time': follow_time, @@ -116,17 +154,16 @@ if __name__ == "__main__": how_many_seconds = 30 how_many_minutes = 10 threading = True - set_default_nodes = True + set_default_nodes = False quit_thread = False benchmark_time = timer() - authorpermvoter = u"@gtg/ffdhu-gtg-witness-log|gandalf" - [author, permlink, voter] = resolve_authorpermvoter(authorpermvoter) - authorperm = construct_authorperm(author, permlink) - - nodes = get_node_list(appbase=False) + get_node_list(appbase=True) + nodelist = NodeList() + nodes = nodelist.get_nodes(normal=True, appbase=True, dev=True) t = PrettyTable(["node", "N blocks", "N acc hist", "dur. call in s"]) t.align = "l" + t2 = PrettyTable(["node", "version"]) + t2.align = "l" working_nodes = [] results = [] if threading and FUTURES_MODULE: @@ -144,8 +181,12 @@ if __name__ == "__main__": print("Current node:", node) result = benchmark_node(node, how_many_minutes, how_many_seconds) results.append(result) + for result in results: + t2.add_row([result["node"], result["version"]]) + print(t2) + print("\n") - sortedList = sorted(results, key=lambda self: self["total_duration"], reverse=False) + sortedList = sorted(results, key=lambda self: self["history_count"], reverse=True) for result in sortedList: if result["sucessfull"]: t.add_row([ diff --git a/examples/op_on_testnet.py b/examples/op_on_testnet.py index 6171cf56a1d9930b135fc11d51f78430343c4bad..22752ec9cefad788bf65b7e00aec8db3e4121646 100644 --- a/examples/op_on_testnet.py +++ b/examples/op_on_testnet.py @@ -16,6 +16,7 @@ from beemgraphenebase.account import PasswordKey, PrivateKey, PublicKey from beem.steem import Steem from beem.utils import parse_time, formatTimedelta from beemapi.exceptions import NumRetriesReached +from beem.nodelist import NodeList log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) @@ -24,7 +25,8 @@ username = "beem" useWallet = False if __name__ == "__main__": - stm = Steem(node=["wss://testnet.steem.vc"]) + nodelist = NodeList() + stm = Steem(node=nodelist.get_nodes(normal=False, appbase=False, testnet=True)) prefix = stm.prefix # curl --data "username=username&password=secretPassword" https://testnet.steem.vc/create stm.wallet.wipe(True) @@ -49,9 +51,10 @@ if __name__ == "__main__": stm.wallet.addPrivateKey(memo_privkey) stm.wallet.addPrivateKey(posting_privkey) else: - stm = Steem(node=["wss://testnet.steem.vc"], wif={'active': str(active_privkey), - 'posting': str(posting_privkey), - 'memo': str(memo_privkey)}) + stm = Steem(node=nodelist.get_nodes(normal=False, appbase=False, testnet=True), + wif={'active': str(active_privkey), + 'posting': str(posting_privkey), + 'memo': str(memo_privkey)}) account = Account(username, steem_instance=stm) account.disallow("beem1", permission='posting') account.allow('beem1', weight=1, permission='posting', account=None) diff --git a/tests/beem/test_account.py b/tests/beem/test_account.py index 520743638b92667dc6c1294dd0c47761d47bfd30..62fabd3242512e8e1903013f19cb9708fbcd75bf 100644 --- a/tests/beem/test_account.py +++ b/tests/beem/test_account.py @@ -15,7 +15,8 @@ from beem.account import Account from beem.block import Block from beem.amount import Amount from beem.asset import Asset -from beem.utils import formatTimeString, get_node_list +from beem.utils import formatTimeString +from beem.nodelist import NodeList from beem.instance import set_shared_steem_instance wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -25,9 +26,9 @@ class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): - + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(normal=True, appbase=False), nobroadcast=True, bundle=False, # Overwrite wallet to use this list of wifs only @@ -35,7 +36,7 @@ class Testcases(unittest.TestCase): num_retries=10 ) cls.appbase = Steem( - node=get_node_list(appbase=True, testing=True), + node=nodelist.get_nodes(normal=False, appbase=True, dev=True), nobroadcast=True, bundle=False, # Overwrite wallet to use this list of wifs only diff --git a/tests/beem/test_amount.py b/tests/beem/test_amount.py index 4bc20a5360ebb8c22ab8fde5a83967fd36d1ff6f..05b4aa32735e53b381c7c2fc62ff844e50408f63 100644 --- a/tests/beem/test_amount.py +++ b/tests/beem/test_amount.py @@ -8,20 +8,21 @@ from parameterized import parameterized from beem import Steem from beem.amount import Amount from beem.asset import Asset -from beem.utils import get_node_list +from beem.nodelist import NodeList from beem.instance import set_shared_steem_instance, SharedInstance class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10 ) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, use_condenser=False, num_retries=10 diff --git a/tests/beem/test_asset.py b/tests/beem/test_asset.py index 6291bd39b4b17691cc2449067113857737bc86fd..e41f2426a24835e9414165adacd15dee0627f3aa 100644 --- a/tests/beem/test_asset.py +++ b/tests/beem/test_asset.py @@ -10,19 +10,20 @@ from beem import Steem from beem.asset import Asset from beem.instance import set_shared_steem_instance from beem.exceptions import AssetDoesNotExistsException -from beem.utils import get_node_list +from beem.nodelist import NodeList class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10 ) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, num_retries=10 ) diff --git a/tests/beem/test_base_objects.py b/tests/beem/test_base_objects.py index 05103439810530d80a66fb88d94674871d0dd961..f5de5526ecc9ba668abb60bad8c58ed6d205c735 100644 --- a/tests/beem/test_base_objects.py +++ b/tests/beem/test_base_objects.py @@ -8,15 +8,15 @@ from beem import Steem, exceptions from beem.instance import set_shared_steem_instance from beem.account import Account from beem.witness import Witness -from beem.utils import get_node_list +from beem.nodelist import NodeList class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): - + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10 ) diff --git a/tests/beem/test_block.py b/tests/beem/test_block.py index 315fe5afd3def5437f78af65d76ce42f27bf44da..5456f1fa3c443bb6fe12193c0089257005403cb8 100644 --- a/tests/beem/test_block.py +++ b/tests/beem/test_block.py @@ -10,7 +10,7 @@ from beem import Steem, exceptions from beem.block import Block, BlockHeader from datetime import datetime from beem.instance import set_shared_steem_instance -from beem.utils import get_node_list +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" nodes_appbase = ["https://api.steemitstage.com", "https://api.steem.house", "https://api.steemit.com"] @@ -19,9 +19,9 @@ nodes_appbase = ["https://api.steemitstage.com", "https://api.steem.house", "htt class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): - + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, keys={"active": wif}, num_retries=10 diff --git a/tests/beem/test_blockchain.py b/tests/beem/test_blockchain.py index c278a9a2755047b052ef46a75eb165f3f4508ced..3b9ad761650df3834c90631b3a4a38342c3e4a4e 100644 --- a/tests/beem/test_blockchain.py +++ b/tests/beem/test_blockchain.py @@ -13,7 +13,7 @@ from beem import Steem from beem.blockchain import Blockchain from beem.block import Block from beem.instance import set_shared_steem_instance -from beem.utils import get_node_list +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" nodes_appbase = ["https://api.steemitstage.com", "https://api.steem.house", "https://api.steemit.com"] @@ -22,8 +22,9 @@ nodes_appbase = ["https://api.steemitstage.com", "https://api.steem.house", "htt class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, keys={"active": wif}, num_retries=10 diff --git a/tests/beem/test_blockchain_batch.py b/tests/beem/test_blockchain_batch.py index 18891fd1dc19bb549ceae0cfeda986b2c58caa4d..5eab09002d399f6e5e3ddbe5e248d6c44ec19675 100644 --- a/tests/beem/test_blockchain_batch.py +++ b/tests/beem/test_blockchain_batch.py @@ -13,7 +13,8 @@ from beem import Steem from beem.blockchain import Blockchain from beem.block import Block from beem.instance import set_shared_steem_instance -from beem.utils import formatTimeString, get_node_list +from beem.utils import formatTimeString +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -21,8 +22,9 @@ wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=True, testing=True), + node=nodelist.get_nodes(normal=False, appbase=True, dev=True), nobroadcast=True, num_retries=10, use_condenser=False, diff --git a/tests/beem/test_blockchain_threading.py b/tests/beem/test_blockchain_threading.py index 2f25b45e79b3fcea05da4b74ba8af85c01c73074..e234d91c5ecded41c0434dfa2a4773a7e73ca479 100644 --- a/tests/beem/test_blockchain_threading.py +++ b/tests/beem/test_blockchain_threading.py @@ -13,7 +13,7 @@ from beem import Steem from beem.blockchain import Blockchain from beem.block import Block from beem.instance import set_shared_steem_instance -from beem.utils import get_node_list +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -21,8 +21,9 @@ wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10, keys={"active": wif}, diff --git a/tests/beem/test_cli.py b/tests/beem/test_cli.py index 87e8e794ddcd5510c2d36cf1b1921b5825b2672c..6f8ab86f65764865785cb4f51ff59551de6ff158 100644 --- a/tests/beem/test_cli.py +++ b/tests/beem/test_cli.py @@ -16,7 +16,7 @@ from beemgraphenebase.account import PrivateKey from beem.cli import cli, balance from beem.instance import set_shared_steem_instance, shared_steem_instance from beembase.operationids import getOperationNameForId -from beem.utils import get_node_list, get_test_node_list +from beem.nodelist import NodeList wif = "5Jt2wTfhUt5GkZHV1HYVfkEaJ6XnY8D2iA4qjtK9nnGXAhThM3w" posting_key = "5Jh1Gtu2j4Yi16TfhoDmg8Qj3ULcgRi7A49JXdfUUTVPkaFaRKz" @@ -27,6 +27,7 @@ pub_key = "STX52xMqKegLk4tdpNcUXU9Rw5DtdM9fxf3f12Gp55v1UjLX3ELZf" class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() stm = shared_steem_instance() stm.config.refreshBackup() runner = CliRunner() @@ -36,7 +37,7 @@ class Testcases(unittest.TestCase): result = runner.invoke(cli, ['-o', 'set', 'default_account', 'beem']) if result.exit_code != 0: raise AssertionError(str(result)) - result = runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + result = runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) if result.exit_code != 0: raise AssertionError(str(result)) result = runner.invoke(cli, ['createwallet', '--wipe'], input="test\ntest\n") @@ -59,13 +60,15 @@ class Testcases(unittest.TestCase): def test_balance(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['balance', 'beem', 'beem1']) self.assertEqual(result.exit_code, 0) def test_interest(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['interest', 'beem', 'beem1']) self.assertEqual(result.exit_code, 0) @@ -109,7 +112,8 @@ class Testcases(unittest.TestCase): def test_info(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['info']) self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['info', 'beem']) @@ -123,6 +127,7 @@ class Testcases(unittest.TestCase): def test_info2(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['info', '--', '-1:1']) self.assertEqual(result.exit_code, 0) @@ -130,7 +135,7 @@ class Testcases(unittest.TestCase): self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['info', "@gtg/witness-gtg-log"]) self.assertEqual(result.exit_code, 0) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) def test_changepassword(self): runner = CliRunner() @@ -167,19 +172,22 @@ class Testcases(unittest.TestCase): def test_transfer(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['transfer', 'beem1', '1', 'SBD', 'test'], input="test\n") self.assertEqual(result.exit_code, 0) def test_powerdownroute(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['powerdownroute', 'beem1'], input="test\n") self.assertEqual(result.exit_code, 0) def test_convert(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['convert', '1'], input="test\n") self.assertEqual(result.exit_code, 0) @@ -190,7 +198,8 @@ class Testcases(unittest.TestCase): def test_powerdown(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['powerdown', '1e3'], input="test\n") self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['powerdown', '0'], input="test\n") @@ -198,7 +207,8 @@ class Testcases(unittest.TestCase): def test_updatememokey(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['-d', 'updatememokey'], input="test\ntest\ntest\n") self.assertEqual(result.exit_code, 0) @@ -209,31 +219,36 @@ class Testcases(unittest.TestCase): def test_follower(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['follower', 'beem2']) self.assertEqual(result.exit_code, 0) def test_following(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['following', 'beem']) self.assertEqual(result.exit_code, 0) def test_muter(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['muter', 'beem2']) self.assertEqual(result.exit_code, 0) def test_muting(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['muting', 'beem']) self.assertEqual(result.exit_code, 0) def test_allow_disallow(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['-d', 'allow', '--account', 'beem', '--permission', 'posting', 'beem1'], input="test\n") self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['-d', 'disallow', '--account', 'beem', '--permission', 'posting', 'beem1'], input="test\n") @@ -246,7 +261,8 @@ class Testcases(unittest.TestCase): def test_votes(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['votes', '--direction', 'out']) self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['votes', '--direction', 'in']) @@ -254,19 +270,22 @@ class Testcases(unittest.TestCase): def test_approvewitness(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['-o', 'approvewitness', 'beem1'], input="test\n") self.assertEqual(result.exit_code, 0) def test_disapprovewitness(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['-o', 'disapprovewitness', 'beem1'], input="test\n") self.assertEqual(result.exit_code, 0) def test_newaccount(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['-d', 'newaccount', 'beem3'], input="test\ntest\ntest\n") self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['-d', 'newaccount', '--fee', '6 STEEM', 'beem3'], input="test\ntest\ntest\n") @@ -274,7 +293,8 @@ class Testcases(unittest.TestCase): def test_importaccount(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['importaccount', '--roles', '["owner", "active", "posting", "memo"]', 'beem2'], input="test\ntest\n") self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['delkey', '--confirm', 'STX7mLs2hns87f7kbf3o2HBqNoEaXiTeeU89eVF6iUCrMQJFzBsPo'], input="test\n") @@ -288,13 +308,14 @@ class Testcases(unittest.TestCase): def test_orderbook(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['orderbook']) self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['orderbook', '--show-date']) self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['orderbook', '--chart']) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) self.assertEqual(result.exit_code, 0) def test_buy(self): @@ -336,7 +357,8 @@ class Testcases(unittest.TestCase): def test_follow_unfollow(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['follow', 'beem1'], input="test\n") self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['unfollow', 'beem1'], input="test\n") @@ -344,7 +366,8 @@ class Testcases(unittest.TestCase): def test_mute_unmute(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['mute', 'beem1'], input="test\n") self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['unfollow', 'beem1'], input="test\n") @@ -352,7 +375,8 @@ class Testcases(unittest.TestCase): def test_witnesscreate(self): runner = CliRunner() - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + nodelist = NodeList() + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) result = runner.invoke(cli, ['-d', 'witnesscreate', 'beem', pub_key], input="test\n") self.assertEqual(result.exit_code, 0) @@ -382,10 +406,11 @@ class Testcases(unittest.TestCase): def test_nextnode(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['-o', 'nextnode']) self.assertEqual(result.exit_code, 0) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) def test_pingnode(self): runner = CliRunner() @@ -396,6 +421,7 @@ class Testcases(unittest.TestCase): def test_currentnode(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['currentnode']) self.assertEqual(result.exit_code, 0) @@ -403,24 +429,27 @@ class Testcases(unittest.TestCase): self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['currentnode', '--version']) self.assertEqual(result.exit_code, 0) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) def test_ticker(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['ticker']) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) self.assertEqual(result.exit_code, 0) def test_pricehistory(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['pricehistory']) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) self.assertEqual(result.exit_code, 0) def test_pending(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['pending', 'test']) self.assertEqual(result.exit_code, 0) @@ -434,10 +463,11 @@ class Testcases(unittest.TestCase): self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['pending', '--post', '--comment', '--curation', '--author', '--permlink', '--length', '30', 'test']) self.assertEqual(result.exit_code, 0) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) def test_rewards(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['rewards', 'test']) self.assertEqual(result.exit_code, 0) @@ -451,25 +481,28 @@ class Testcases(unittest.TestCase): self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['rewards', '--post', '--comment', '--curation', '--author', '--permlink', '--length', '30', 'test']) self.assertEqual(result.exit_code, 0) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) def test_curation(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['curation', "@gtg/witness-gtg-log"]) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) self.assertEqual(result.exit_code, 0) def test_verify(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['verify', '--trx', '0']) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) self.assertEqual(result.exit_code, 0) def test_tradehistory(self): runner = CliRunner() + nodelist = NodeList() runner.invoke(cli, ['-o', 'set', 'nodes', '']) result = runner.invoke(cli, ['tradehistory']) - runner.invoke(cli, ['-o', 'set', 'nodes', get_test_node_list()[1]]) + runner.invoke(cli, ['-o', 'set', 'nodes', str(nodelist.get_testnet())]) self.assertEqual(result.exit_code, 0) diff --git a/tests/beem/test_comment.py b/tests/beem/test_comment.py index 4eb831c14b04b9d549fb2d39ee7fb87e832d8d48..4c9948b77f62d95d8c375d43750f2682092d23a3 100644 --- a/tests/beem/test_comment.py +++ b/tests/beem/test_comment.py @@ -10,7 +10,8 @@ from beem import Steem, exceptions from beem.comment import Comment, RecentReplies, RecentByPath from beem.vote import Vote from beem.instance import set_shared_steem_instance -from beem.utils import get_node_list, resolve_authorperm +from beem.utils import resolve_authorperm +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -18,15 +19,16 @@ wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(appbase=False), use_condenser=True, nobroadcast=True, keys={"active": wif}, num_retries=10 ) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, keys={"active": wif}, num_retries=10 diff --git a/tests/beem/test_connection.py b/tests/beem/test_connection.py index d5a8166e7748d919447b4e3ab14612c658284df6..1e9c04aab265af98da37b17adc003a56b0b25f8c 100644 --- a/tests/beem/test_connection.py +++ b/tests/beem/test_connection.py @@ -3,7 +3,7 @@ from beem import Steem from beem.account import Account from beem.instance import set_shared_steem_instance, SharedInstance from beem.blockchainobject import BlockchainObject -from beem.utils import get_node_list, get_test_node_list +from beem.nodelist import NodeList import logging log = logging.getLogger() @@ -12,14 +12,15 @@ log = logging.getLogger() class Testcases(unittest.TestCase): def test_stm1stm2(self): + nodelist = NodeList() b1 = Steem( - node=get_test_node_list(), + node=nodelist.get_testnet(), nobroadcast=True, num_retries=10 ) b2 = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10 ) @@ -27,15 +28,16 @@ class Testcases(unittest.TestCase): self.assertNotEqual(b1.rpc.url, b2.rpc.url) def test_default_connection(self): + nodelist = NodeList() b1 = Steem( - node=get_test_node_list(), + node=nodelist.get_testnet(), nobroadcast=True, ) set_shared_steem_instance(b1) test = Account("test") b2 = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, ) set_shared_steem_instance(b2) diff --git a/tests/beem/test_constants.py b/tests/beem/test_constants.py index 197d7ec64b03e3d732ea373e4f77b1755f0fcaf3..99f3ecd1cab9efd0c07d0241170d899fe72ca07d 100644 --- a/tests/beem/test_constants.py +++ b/tests/beem/test_constants.py @@ -11,7 +11,7 @@ from datetime import datetime, timedelta from parameterized import parameterized from pprint import pprint from beem import Steem, exceptions, constants -from beem.utils import get_node_list +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -20,9 +20,9 @@ class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): - + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, bundle=False, # Overwrite wallet to use this list of wifs only @@ -30,7 +30,7 @@ class Testcases(unittest.TestCase): num_retries=10 ) cls.appbase = Steem( - node=get_node_list(appbase=True, testing=True), + node=nodelist.get_nodes(appbase=True, dev=True), nobroadcast=True, bundle=False, # Overwrite wallet to use this list of wifs only diff --git a/tests/beem/test_discussions.py b/tests/beem/test_discussions.py index fb170a9309e465e24e203f06f113d80387c4bb21..ba8419cec95fd0dd9c2dad04d5c0ebe1a22d4716 100644 --- a/tests/beem/test_discussions.py +++ b/tests/beem/test_discussions.py @@ -14,9 +14,9 @@ from beem.discussions import ( Discussions_by_children, Discussions_by_hot, Discussions_by_feed, Discussions_by_blog, Discussions_by_comments, Discussions_by_promoted ) -from beem.utils import get_node_list from datetime import datetime from beem.instance import set_shared_steem_instance +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -24,15 +24,16 @@ wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(appbase=False), use_condenser=True, nobroadcast=True, keys={"active": wif}, num_retries=10 ) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, keys={"active": wif}, num_retries=10 diff --git a/tests/beem/test_market.py b/tests/beem/test_market.py index 2af641e682af63985ce04b111156062538026b09..359cdb06068c00929cb366c59c0087af2a453e68 100644 --- a/tests/beem/test_market.py +++ b/tests/beem/test_market.py @@ -12,7 +12,7 @@ from beem.price import Price from beem.asset import Asset from beem.amount import Amount from beem.instance import set_shared_steem_instance -from beem.utils import get_node_list +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -21,14 +21,15 @@ class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, keys={"active": wif}, num_retries=10 ) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, keys={"active": wif}, num_retries=10 diff --git a/tests/beem/test_notify.py b/tests/beem/test_notify.py index e5b76c428a312cab49d521596dfb96614dbc2237..1a483a338b0e625311c39681dff6cb84cc342586 100644 --- a/tests/beem/test_notify.py +++ b/tests/beem/test_notify.py @@ -14,7 +14,7 @@ from beem import Steem from beemapi.websocket import SteemWebsocket from beem.notify import Notify from beem.instance import set_shared_steem_instance -from beem.utils import get_node_list +from beem.nodelist import NodeList # Py3 compatibility import sys @@ -38,9 +38,9 @@ class Testcases(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - + nodelist = NodeList() self.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(), nobroadcast=True, num_retries=10 ) diff --git a/tests/beem/test_objectcache.py b/tests/beem/test_objectcache.py index b93713141d5df11f146d1fd9e33ee75d759e55d6..d3b2c8c20e08e40cbb061a5a99e0cac2f5e156b8 100644 --- a/tests/beem/test_objectcache.py +++ b/tests/beem/test_objectcache.py @@ -10,7 +10,7 @@ from beem import Steem, exceptions from beem.instance import set_shared_steem_instance from beem.blockchainobject import ObjectCache from beem.account import Account -from beem.utils import get_node_list +from beem.nodelist import NodeList class Testcases(unittest.TestCase): diff --git a/tests/beem/test_price.py b/tests/beem/test_price.py index 0ba57a5a085767b3d925704d90f4bb32e6451625..1cf88da4faa65f9747f5b27b0fc0591f66dffa7f 100644 --- a/tests/beem/test_price.py +++ b/tests/beem/test_price.py @@ -8,14 +8,15 @@ from beem.amount import Amount from beem.price import Price, Order, FilledOrder from beem.asset import Asset import unittest -from beem.utils import get_node_list +from beem.nodelist import NodeList class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() steem = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, num_retries=10 ) diff --git a/tests/beem/test_steem.py b/tests/beem/test_steem.py index abf92736a1df6fdf037addbe4d928f0f478ae124..16e1dc13f3ced700ab1fc1061ba0c2db71e64039 100644 --- a/tests/beem/test_steem.py +++ b/tests/beem/test_steem.py @@ -20,7 +20,7 @@ from beem.witness import Witness from beem.account import Account from beemgraphenebase.account import PrivateKey from beem.instance import set_shared_steem_instance -from beem.utils import get_node_list +from beem.nodelist import NodeList # Py3 compatibility import sys core_unit = "STM" @@ -31,14 +31,15 @@ class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, @@ -107,14 +108,15 @@ class Testcases(unittest.TestCase): ("appbase"), ]) def test_create_account(self, node_param): + nodelist = NodeList() if node_param == "non_appbase": - bts = Steem(node=get_node_list(appbase=False), + bts = Steem(node=nodelist.get_nodes(appbase=False), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) elif node_param == "appbase": - bts = Steem(node=get_node_list(appbase=True), + bts = Steem(node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, @@ -184,14 +186,15 @@ class Testcases(unittest.TestCase): ("appbase"), ]) def test_create_account_password(self, node_param): + nodelist = NodeList() if node_param == "non_appbase": - bts = Steem(node=get_node_list(appbase=False), + bts = Steem(node=nodelist.get_nodes(appbase=False), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) elif node_param == "appbase": - bts = Steem(node=get_node_list(appbase=True), + bts = Steem(node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, @@ -244,14 +247,15 @@ class Testcases(unittest.TestCase): ("appbase"), ]) def test_create_account_with_delegation(self, node_param): + nodelist = NodeList() if node_param == "non_appbase": - bts = Steem(node=get_node_list(appbase=False), + bts = Steem(node=nodelist.get_nodes(appbase=False), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) elif node_param == "appbase": - bts = Steem(node=get_node_list(appbase=True), + bts = Steem(node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, @@ -520,7 +524,8 @@ class Testcases(unittest.TestCase): self.assertEqual("witness-gtg-log", op["permlink"]) def test_offline(self): - bts = Steem(node=get_node_list(appbase=False), + nodelist = NodeList() + bts = Steem(node=nodelist.get_nodes(appbase=False), offline=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}) @@ -549,14 +554,15 @@ class Testcases(unittest.TestCase): ("appbase"), ]) def test_properties(self, node_param): + nodelist = NodeList() if node_param == "non_appbase": - bts = Steem(node=get_node_list(appbase=False), + bts = Steem(node=nodelist.get_nodes(appbase=False), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10) elif node_param == "appbase": - bts = Steem(node=get_node_list(appbase=True), + bts = Steem(node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, data_refresh_time_seconds=900, keys={"active": wif, "owner": wif, "memo": wif}, diff --git a/tests/beem/test_storage.py b/tests/beem/test_storage.py index ec87b51014b5810c7a0d1ee0c12f3b031ec468a6..e68cd7e832baf9d12c121aff80984bbcf4e41fe0 100644 --- a/tests/beem/test_storage.py +++ b/tests/beem/test_storage.py @@ -20,7 +20,7 @@ from beem.witness import Witness from beem.account import Account from beemgraphenebase.account import PrivateKey from beem.instance import set_shared_steem_instance, shared_steem_instance -from beem.utils import get_node_list +from beem.nodelist import NodeList # Py3 compatibility import sys core_unit = "STM" @@ -32,9 +32,10 @@ class Testcases(unittest.TestCase): def setUpClass(cls): stm = shared_steem_instance() stm.config.refreshBackup() + nodelist = NodeList() cls.stm = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, # We want to bundle many operations into a single transaction bundle=True, @@ -42,7 +43,7 @@ class Testcases(unittest.TestCase): # Overwrite wallet to use this list of wifs only ) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, bundle=True, num_retries=10 diff --git a/tests/beem/test_testnet.py b/tests/beem/test_testnet.py index eb275cf869c48dbb5734f42747e63e4e850ca67a..30974b31c031e49271a681c9668955ac6ce8972f 100644 --- a/tests/beem/test_testnet.py +++ b/tests/beem/test_testnet.py @@ -19,8 +19,9 @@ from beem.block import Block from beem.transactionbuilder import TransactionBuilder from beembase.operations import Transfer from beemgraphenebase.account import PasswordKey, PrivateKey, PublicKey -from beem.utils import parse_time, formatTimedelta, get_test_node_list +from beem.utils import parse_time, formatTimedelta from beemapi.rpcutils import NumRetriesReached +from beem.nodelist import NodeList # Py3 compatibility import sys @@ -31,10 +32,11 @@ core_unit = "STX" class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() stm = shared_steem_instance() stm.config.refreshBackup() cls.bts = Steem( - node=get_test_node_list(), + node=nodelist.get_testnet(), nobroadcast=True, num_retries=10, expiration=120, @@ -239,11 +241,12 @@ class Testcases(unittest.TestCase): steem.wallet.addPrivateKey(self.active_private_key_of_elf) def test_transfer_2of2_wif(self): + nodelist = NodeList() # Send a 2 of 2 transaction from elf which needs steemfiles'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 steemfiles's key. steem = Steem( - node=get_test_node_list(), + node=nodelist.get_testnet(), num_retries=10, keys=[self.active_private_key_of_elf], expiration=120, @@ -265,7 +268,7 @@ class Testcases(unittest.TestCase): del tx steem = Steem( - node=get_test_node_list(), + node=nodelist.get_testnet(), num_retries=10, keys=[self.active_private_key_of_steemfiles], expiration=120, @@ -342,7 +345,8 @@ class Testcases(unittest.TestCase): "beem") def test_connect(self): - self.bts.connect(node=get_test_node_list()) + nodelist = NodeList() + self.bts.connect(node=nodelist.get_testnet()) bts = self.bts self.assertEqual(bts.prefix, "STX") diff --git a/tests/beem/test_txbuffers.py b/tests/beem/test_txbuffers.py index 046569008243c47c1eb1cd20a18957177bdf7a71..96deeb13e34ca727005f53f9d96da31bf3cbc832 100644 --- a/tests/beem/test_txbuffers.py +++ b/tests/beem/test_txbuffers.py @@ -22,8 +22,8 @@ from beem.exceptions import ( ) from beemapi import exceptions from beem.wallet import Wallet -from beem.utils import get_node_list, formatTimeFromNow - +from beem.utils import formatTimeFromNow +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -31,14 +31,15 @@ class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.stm = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), keys={"active": wif, "owner": wif, "memo": wif}, nobroadcast=True, num_retries=10 ) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, keys={"active": wif, "owner": wif, "memo": wif}, num_retries=10 @@ -165,7 +166,8 @@ class Testcases(unittest.TestCase): self.assertTrue(len(tx["signatures"]) > 0) def test_Transfer_broadcast(self): - stm = Steem(node=get_node_list(appbase=False), + nodelist = NodeList() + stm = Steem(node=nodelist.get_nodes(appbase=False), keys=[wif], num_retries=10) tx = TransactionBuilder(expiration=10, steem_instance=stm) @@ -181,7 +183,8 @@ class Testcases(unittest.TestCase): tx.broadcast() def test_Transfer_broadcast_appbase(self): - stm = Steem(node=get_node_list(appbase=True), + nodelist = NodeList() + stm = Steem(node=nodelist.get_nodes(normal=False, appbase=True), keys=[wif], num_retries=10) tx = TransactionBuilder(expiration=10, steem_instance=stm) diff --git a/tests/beem/test_vote.py b/tests/beem/test_vote.py index fb8b711dd572e1a0d72754d0f421d65c67af6bb7..60bec6957d0a0a96a070cd75cf86aababb6d44ec 100644 --- a/tests/beem/test_vote.py +++ b/tests/beem/test_vote.py @@ -10,7 +10,8 @@ from beem import Steem, exceptions from beem.comment import Comment from beem.vote import Vote, ActiveVotes, AccountVotes from beem.instance import set_shared_steem_instance -from beem.utils import get_node_list, construct_authorperm, resolve_authorperm, resolve_authorpermvoter, construct_authorpermvoter +from beem.utils import construct_authorperm, resolve_authorperm, resolve_authorpermvoter, construct_authorpermvoter +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -18,14 +19,15 @@ wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, keys={"active": wif}, num_retries=10 ) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, keys={"active": wif}, num_retries=10 diff --git a/tests/beem/test_wallet.py b/tests/beem/test_wallet.py index cb1dcd4406869fc18b07aa4f53e38e34d1519132..471690b1474f0099e343a06dafb8a1728934a061 100644 --- a/tests/beem/test_wallet.py +++ b/tests/beem/test_wallet.py @@ -13,7 +13,7 @@ from beem.amount import Amount from beem.asset import Asset from beem.wallet import Wallet from beem.instance import set_shared_steem_instance, shared_steem_instance -from beem.utils import get_node_list +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -23,9 +23,10 @@ class Testcases(unittest.TestCase): def setUpClass(cls): stm = shared_steem_instance() stm.config.refreshBackup() + nodelist = NodeList() cls.stm = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, # We want to bundle many operations into a single transaction bundle=True, @@ -33,7 +34,7 @@ class Testcases(unittest.TestCase): # Overwrite wallet to use this list of wifs only ) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, bundle=True, num_retries=10 diff --git a/tests/beem/test_witness.py b/tests/beem/test_witness.py index 639251ab5e96954f9d0214a1423eb89ee41c4ade..0085dcb67254418d2985e5710498766c81c9190d 100644 --- a/tests/beem/test_witness.py +++ b/tests/beem/test_witness.py @@ -9,7 +9,7 @@ from pprint import pprint from beem import Steem from beem.witness import Witness, Witnesses, WitnessesVotedByAccount, WitnessesRankedByVote from beem.instance import set_shared_steem_instance -from beem.utils import get_node_list +from beem.nodelist import NodeList wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -17,14 +17,15 @@ wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" class Testcases(unittest.TestCase): @classmethod def setUpClass(cls): + nodelist = NodeList() cls.bts = Steem( - node=get_node_list(appbase=False), + node=nodelist.get_nodes(appbase=False), nobroadcast=True, keys={"active": wif}, num_retries=10 ) cls.appbase = Steem( - node=get_node_list(appbase=True), + node=nodelist.get_nodes(normal=False, appbase=True), nobroadcast=True, keys={"active": wif}, num_retries=10 diff --git a/tests/beemapi/test_websocket.py b/tests/beemapi/test_websocket.py index a57f8717730279d2e8024733d8d5207ca6b30476..9b314bf54537a5d1309cfb8b5f9856ccd9aa7ce3 100644 --- a/tests/beemapi/test_websocket.py +++ b/tests/beemapi/test_websocket.py @@ -13,7 +13,7 @@ from pprint import pprint from beem import Steem from beemapi.websocket import SteemWebsocket from beem.instance import set_shared_steem_instance -from beem.utils import get_node_list +from beem.nodelist import NodeList # Py3 compatibility import sys @@ -25,8 +25,8 @@ class Testcases(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - - stm = Steem(node=get_node_list(appbase=False)) + nodelist = NodeList() + stm = Steem(node=nodelist.get_nodes(appbase=False)) self.ws = SteemWebsocket( urls=stm.rpc.nodes,