aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-03-18 11:53:47 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-03-21 19:28:06 +0000
commitb2fc57194392eef601287f77147c679acb2f63c9 (patch)
tree7f968d3cfcfb5fda0cb7b36d527db1695f5560f7 /tests
parentfunctional_tests: add txpool RPC tests (diff)
downloadmonero-b2fc57194392eef601287f77147c679acb2f63c9.tar.xz
functional_tests: support several daemons/wallets
Diffstat (limited to 'tests')
-rwxr-xr-xtests/functional_tests/functional_tests_rpc.py63
-rw-r--r--tests/functional_tests/test_framework/daemon.py4
-rw-r--r--tests/functional_tests/test_framework/wallet.py4
3 files changed, 42 insertions, 29 deletions
diff --git a/tests/functional_tests/functional_tests_rpc.py b/tests/functional_tests/functional_tests_rpc.py
index 845781a49..db48844f3 100755
--- a/tests/functional_tests/functional_tests_rpc.py
+++ b/tests/functional_tests/functional_tests_rpc.py
@@ -33,35 +33,46 @@ try:
except:
tests = DEFAULT_TESTS
-monerod = [builddir + "/bin/monerod", "--regtest", "--fixed-difficulty", "1", "--offline", "--no-igd", "--non-interactive", "--disable-dns-checkpoints", "--check-updates", "disabled", "--rpc-ssl", "disabled", "--log-level", "1"]
-wallet = [builddir + "/bin/monero-wallet-rpc", "--wallet-dir", builddir + "/functional-tests-directory", "--rpc-bind-port", "18083", "--disable-rpc-login", "--rpc-ssl", "disabled", "--daemon-ssl", "disabled", "--log-level", "1"]
+N_MONERODS = 1
+N_WALLETS = 3
-monerod_output = open(builddir + '/tests/functional_tests/monerod.log', 'a+')
-wallet_output = open(builddir + '/tests/functional_tests/wallet.log', 'a+')
+monerod_base = [builddir + "/bin/monerod", "--regtest", "--fixed-difficulty", "1", "--offline", "--no-igd", "--p2p-bind-port", "monerod_p2p_port", "--rpc-bind-port", "monerod_rpc_port", "--zmq-rpc-bind-port", "monerod_zmq_port", "--non-interactive", "--disable-dns-checkpoints", "--check-updates", "disabled", "--rpc-ssl", "disabled", "--log-level", "1"]
+wallet_base = [builddir + "/bin/monero-wallet-rpc", "--wallet-dir", builddir + "/functional-tests-directory", "--rpc-bind-port", "wallet_port", "--disable-rpc-login", "--rpc-ssl", "disabled", "--daemon-ssl", "disabled", "--daemon-port", "18180", "--log-level", "1"]
+
+command_lines = []
+processes = []
+outputs = []
+ports = []
+
+for i in range(N_MONERODS):
+ command_lines.append([str(18180+i) if x == "monerod_rpc_port" else str(18280+i) if x == "monerod_p2p_port" else str(18380+i) if x == "monerod_zmq_port" else x for x in monerod_base])
+ outputs.append(open(builddir + '/tests/functional_tests/monerod' + str(i) + '.log', 'a+'))
+ ports.append(18180+i)
+
+for i in range(N_WALLETS):
+ command_lines.append([str(18090+i) if x == "wallet_port" else x for x in wallet_base])
+ outputs.append(open(builddir + '/tests/functional_tests/wallet' + str(i) + '.log', 'a+'))
+ ports.append(18090+i)
print('Starting servers...')
-monerod_process = None
-wallet_process = None
try:
- #print 'Running: ' + str(monerod)
- monerod_process = subprocess.Popen(monerod, stdout = monerod_output)
- #print 'Running: ' + str(wallet)
- wallet_process = subprocess.Popen(wallet, stdout = wallet_output)
+ for i in range(len(command_lines)):
+ #print('Running: ' + str(command_lines[i]))
+ processes.append(subprocess.Popen(command_lines[i], stdout = outputs[i]))
except Exception, e:
print('Error: ' + str(e))
sys.exit(1)
def kill():
- try: wallet_process.send_signal(SIGTERM)
- except: pass
- try: monerod_process.send_signal(SIGTERM)
- except: pass
+ for i in range(len(processes)):
+ try: processes[i].send_signal(SIGTERM)
+ except: pass
# wait for error/startup
for i in range(10):
time.sleep(1)
all_open = True
- for port in [18081, 18083]:
+ for port in ports:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1)
if s.connect_ex(('127.0.0.1', port)) != 0:
@@ -95,20 +106,22 @@ kill()
# wait for exit, the poll method does not work (https://bugs.python.org/issue2475) so we wait, possibly forever if the process hangs
if True:
- wallet_process.wait()
- monerod_process.wait()
+ for p in processes:
+ p.wait()
else:
for i in range(10):
- wallet_process.poll()
- monerod_process.poll()
- if wallet_process.returncode and monerod_process.returncode:
- print('Both done: ' + str(wallet_process.returncode) + ' and ' + str(monerod_process.returncode))
+ n_returncode = 0
+ for p in processes:
+ p.poll()
+ if p.returncode:
+ n_returncode += 1
+ if n_returncode == len(processes):
+ print('All done: ' + string.join([x.returncode for x in processes], ', '))
break
time.sleep(1)
- if not wallet_process.returncode:
- print('Failed to stop monero-wallet-rpc')
- if not monerod_process.returncode:
- print('Failed to stop monerod')
+ for p in processes:
+ if not p.returncode:
+ print('Failed to stop process')
if len(FAIL) == 0:
print('Done, ' + str(len(PASS)) + '/' + str(len(tests)) + ' tests passed')
diff --git a/tests/functional_tests/test_framework/daemon.py b/tests/functional_tests/test_framework/daemon.py
index ee1fcc0fc..0d0eda7dc 100644
--- a/tests/functional_tests/test_framework/daemon.py
+++ b/tests/functional_tests/test_framework/daemon.py
@@ -32,8 +32,8 @@ from .rpc import JSONRPC
class Daemon(object):
- def __init__(self, protocol='http', host='127.0.0.1', port=18081):
- self.rpc = JSONRPC('{protocol}://{host}:{port}'.format(protocol=protocol, host=host, port=port))
+ def __init__(self, protocol='http', host='127.0.0.1', port=0, idx=0):
+ self.rpc = JSONRPC('{protocol}://{host}:{port}'.format(protocol=protocol, host=host, port=port if port else 18180+idx))
def getblocktemplate(self, address):
getblocktemplate = {
diff --git a/tests/functional_tests/test_framework/wallet.py b/tests/functional_tests/test_framework/wallet.py
index e4f352e1d..4f2997cc4 100644
--- a/tests/functional_tests/test_framework/wallet.py
+++ b/tests/functional_tests/test_framework/wallet.py
@@ -32,8 +32,8 @@ from .rpc import JSONRPC
class Wallet(object):
- def __init__(self, protocol='http', host='127.0.0.1', port=18083):
- self.rpc = JSONRPC('{protocol}://{host}:{port}'.format(protocol=protocol, host=host, port=port))
+ def __init__(self, protocol='http', host='127.0.0.1', port=0, idx=0):
+ self.rpc = JSONRPC('{protocol}://{host}:{port}'.format(protocol=protocol, host=host, port=port if port else 18090+idx))
def make_uniform_destinations(self, address, transfer_amount, transfer_number_of_destinations=1):
destinations = []