From 86193229b6238cd583e2db760a2efe5d6e5acac0 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 1 Aug 2021 20:54:51 +0000 Subject: [PATCH] start-coin-daemons.py: support multiple daemons per coin --- test/start-coin-daemons.py | 46 +++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/test/start-coin-daemons.py b/test/start-coin-daemons.py index 9cc1b174..1e70def6 100755 --- a/test/start-coin-daemons.py +++ b/test/start-coin-daemons.py @@ -3,7 +3,7 @@ import sys from include.tests_header import repo_root from mmgen.common import * -from mmgen.daemon import CoinDaemon +from mmgen.daemon import * network_ids = CoinDaemon.get_network_ids() @@ -38,29 +38,15 @@ Valid network IDs: {nid}, all, or no_xmr cmd_args = opts.init(opts_data) -if 'all' in cmd_args or 'no_xmr' in cmd_args: - if len(cmd_args) != 1: - die(1,"'all' or 'no_xmr' must be the sole argument") - else: - ids = list(network_ids) - if cmd_args[0] == 'no_xmr': - ids.remove('xmr') -else: - ids = cmd_args - if not ids: - opts.usage() - for i in ids: - if i not in network_ids: - die(1,f'{i!r}: invalid network ID') - -for network_id in ids: - network_id = network_id.lower() +def run(network_id=None,proto=None,daemon_id=None): d = CoinDaemon( - network_id, + network_id = network_id, + proto = proto, test_suite = True, opts = ['no_daemonize'] if opt.no_daemonize else None, port_shift = int(opt.port_shift or 0), - datadir = opt.datadir ) + datadir = opt.datadir, + daemon_id = daemon_id ) d.debug = d.debug or opt.debug d.wait = not opt.no_wait if opt.get_state: @@ -69,3 +55,23 @@ for network_id in ids: print(' '.join(getattr(d,action+'_cmd'))) else: d.cmd(action) + +if 'all' in cmd_args or 'no_xmr' in cmd_args: + if len(cmd_args) != 1: + die(1,"'all' or 'no_xmr' must be the sole argument") + from mmgen.protocol import init_proto + for coin,data in CoinDaemon.coins.items(): + if coin == 'XMR' and cmd_args[0] == 'no_xmr': + continue + for daemon_id in data.daemon_ids: + for network in globals()[daemon_id+'_daemon'].networks: + run(proto=init_proto(coin=coin,network=network),daemon_id=daemon_id) +else: + ids = cmd_args + if not ids: + opts.usage() + for i in ids: + if i not in network_ids: + die(1,f'{i!r}: invalid network ID') + for network_id in ids: + run(network_id=network_id.lower())