aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/test_framework/util.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2016-05-09 19:55:49 +0200
committerMarcoFalke <falke.marco@gmail.com>2016-05-09 19:56:24 +0200
commitccccc591a456f9a8fcf5f8e68a5bacdbbaeb0937 (patch)
tree4453a25fb7afb0d124671d58a72416b90ebdcc91 /qa/rpc-tests/test_framework/util.py
parentfa494dec79b9d469b7eb38d2f0b8cf9832cdc398 (diff)
downloadbitcoin-ccccc591a456f9a8fcf5f8e68a5bacdbbaeb0937.tar.xz
[qa] Add option --portseed to test_framework
Diffstat (limited to 'qa/rpc-tests/test_framework/util.py')
-rw-r--r--qa/rpc-tests/test_framework/util.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py
index 6dc685ea1b..6784177aaa 100644
--- a/qa/rpc-tests/test_framework/util.py
+++ b/qa/rpc-tests/test_framework/util.py
@@ -8,7 +8,6 @@
# Helpful routines for regression testing
#
-# Add python-bitcoinrpc to module search path:
import os
import sys
@@ -36,6 +35,11 @@ PORT_MIN = 11000
# The number of ports to "reserve" for p2p and rpc, each
PORT_RANGE = 5000
+
+class PortSeed:
+ # Must be initialized with a unique integer for each process
+ n = None
+
#Set Mocktime default to OFF.
#MOCKTIME is only needed for scripts that use the
#cached version of the blockchain. If the cached
@@ -91,10 +95,10 @@ def get_rpc_proxy(url, node_number, timeout=None):
def p2p_port(n):
assert(n <= MAX_NODES)
- return PORT_MIN + n + (MAX_NODES * os.getpid()) % (PORT_RANGE - 1 - MAX_NODES)
+ return PORT_MIN + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES)
def rpc_port(n):
- return PORT_MIN + PORT_RANGE + n + (MAX_NODES * os.getpid()) % (PORT_RANGE -1 - MAX_NODES)
+ return PORT_MIN + PORT_RANGE + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES)
def check_json_precision():
"""Make sure json library being used does not lose precision converting BTC values"""