diff options
author | MarcoFalke <falke.marco@gmail.com> | 2016-04-27 22:29:52 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2016-05-06 12:43:34 +0200 |
commit | fabbf6bd62c1d8a290841b63fb1e5acec42ba3b0 (patch) | |
tree | 3f4a6a90e0d7db5d13ce126b3d854537c29409e2 /qa/rpc-tests/test_framework/util.py | |
parent | 77b637f20e8cb91cf007bf416b603ca362385cdb (diff) |
[qa] Refactor test_framework and pull tester
* log to stdout
* increase range for p2p and rpc ports
* UPPERCASE_CONSTANTS
* Stop nodes on CTRL+C
Diffstat (limited to 'qa/rpc-tests/test_framework/util.py')
-rw-r--r-- | qa/rpc-tests/test_framework/util.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index ea3931cef3..4c129b78b5 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -28,6 +28,13 @@ from .authproxy import AuthServiceProxy, JSONRPCException COVERAGE_DIR = None +# The maximum number of nodes a single test can spawn +MAX_NODES = 8 +# Don't assign rpc or p2p ports lower than this +PORT_MIN = 11000 +# The number of ports to "reserve" for p2p and rpc, each +PORT_RANGE = 5000 + #Set Mocktime default to OFF. #MOCKTIME is only needed for scripts that use the #cached version of the blockchain. If the cached @@ -82,9 +89,11 @@ def get_rpc_proxy(url, node_number, timeout=None): def p2p_port(n): - return 11000 + n + os.getpid()%999 + assert(n <= MAX_NODES) + return PORT_MIN + n + (MAX_NODES * os.getpid()) % (PORT_RANGE - 1 - MAX_NODES) + def rpc_port(n): - return 12000 + n + os.getpid()%999 + return PORT_MIN + PORT_RANGE + n + (MAX_NODES * os.getpid()) % (PORT_RANGE -1 - MAX_NODES) def check_json_precision(): """Make sure json library being used does not lose precision converting BTC values""" @@ -292,8 +301,8 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None): """ Start multiple bitcoinds, return RPC connections to them """ - if extra_args is None: extra_args = [ None for i in range(num_nodes) ] - if binary is None: binary = [ None for i in range(num_nodes) ] + if extra_args is None: extra_args = [ None for _ in range(num_nodes) ] + if binary is None: binary = [ None for _ in range(num_nodes) ] rpcs = [] try: for i in range(num_nodes): |