From 78bd55b3bbd36e5f3a1e7b2d9690c94fff3a2dfa Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 1 Dec 2025 16:54:35 +0000 Subject: [PATCH] CmdTestBase: new `extra_daemons` attribute --- test/cmdtest_d/autosign.py | 4 ++-- test/cmdtest_d/base.py | 1 + test/cmdtest_d/xmrwallet.py | 6 ++++++ test/include/common.py | 18 +++++++++--------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/test/cmdtest_d/autosign.py b/test/cmdtest_d/autosign.py index 4b489474..6ec25d21 100755 --- a/test/cmdtest_d/autosign.py +++ b/test/cmdtest_d/autosign.py @@ -181,12 +181,12 @@ class CmdTestAutosignBase(CmdTestBase): def start_daemons(self): self.spawn(msg_only=True) - start_test_daemons(*self.network_ids) + start_test_daemons(*(self.network_ids + self.extra_daemons)) return 'ok' def stop_daemons(self): self.spawn(msg_only=True) - stop_test_daemons(*self.network_ids, remove_datadir=True) + stop_test_daemons(*(self.network_ids + self.extra_daemons), remove_datadir=True) return 'ok' def run_setup( diff --git a/test/cmdtest_d/base.py b/test/cmdtest_d/base.py index 70a0d708..d90f9b0b 100755 --- a/test/cmdtest_d/base.py +++ b/test/cmdtest_d/base.py @@ -41,6 +41,7 @@ class CmdTestBase: skip_cmds = () test_name = None is_helper = False + extra_daemons = [] def __init__(self, cfg, trunner, cfgs, spawn): if hasattr(self, 'name'): # init may called multiple times diff --git a/test/cmdtest_d/xmrwallet.py b/test/cmdtest_d/xmrwallet.py index 5727053d..606d05a7 100755 --- a/test/cmdtest_d/xmrwallet.py +++ b/test/cmdtest_d/xmrwallet.py @@ -39,6 +39,8 @@ from ..include.common import ( read_from_file, silence, end_silence, + start_test_daemons, + stop_test_daemons, strip_ansi_escapes ) from .include.common import get_file_with_ext @@ -49,6 +51,8 @@ from .base import CmdTestBase def stop_daemons(self): for v in self.users.values(): v.md.stop() + if self.extra_daemons: + stop_test_daemons(*self.extra_daemons, remove_datadir=True, verbose=True) def stop_miner_wallet_daemon(self): asyncio.run(self.users['miner'].wd_rpc.stop_daemon()) @@ -843,6 +847,8 @@ class CmdTestXMRWallet(CmdTestBase): for v in self.users.values(): run(['mkdir', '-p', v.daemon_datadir]) v.md.start() + if self.extra_daemons: + start_test_daemons(*self.extra_daemons, verbose=True) def stop_daemons(self): self.spawn(msg_only=True) diff --git a/test/include/common.py b/test/include/common.py index 09ddaad4..2ad80961 100755 --- a/test/include/common.py +++ b/test/include/common.py @@ -288,23 +288,23 @@ def end_msg(t): ('' if cfg.test_suite_deterministic else f', elapsed time: {t//60:02d}:{t%60:02d}') )) -def start_test_daemons(*network_ids, remove_datadir=False): +def start_test_daemons(*network_ids, remove_datadir=False, verbose=False): if not cfg.no_daemon_autostart: - return test_daemons_ops(*network_ids, op='start', remove_datadir=remove_datadir) + return test_daemons_ops(*network_ids, op='start', remove_datadir=remove_datadir, verbose=verbose) -def stop_test_daemons(*network_ids, force=False, remove_datadir=False): +def stop_test_daemons(*network_ids, force=False, remove_datadir=False, verbose=False): if force or not cfg.no_daemon_stop: - return test_daemons_ops(*network_ids, op='stop', remove_datadir=remove_datadir) + return test_daemons_ops(*network_ids, op='stop', remove_datadir=remove_datadir, verbose=verbose) -def restart_test_daemons(*network_ids, remove_datadir=False): - if not stop_test_daemons(*network_ids, remove_datadir=remove_datadir): +def restart_test_daemons(*network_ids, remove_datadir=False, verbose=False): + if not stop_test_daemons(*network_ids, remove_datadir=remove_datadir, verbose=verbose): return False - return start_test_daemons(*network_ids, remove_datadir=remove_datadir) + return start_test_daemons(*network_ids, remove_datadir=remove_datadir, verbose=verbose) -def test_daemons_ops(*network_ids, op, remove_datadir=False): +def test_daemons_ops(*network_ids, op, remove_datadir=False, verbose=False): if not cfg.no_daemon_autostart: from mmgen.daemon import CoinDaemon - silent = not (cfg.verbose or cfg.exact_output) + silent = not (verbose or cfg.verbose or cfg.exact_output) ret = False for network_id in network_ids: d = CoinDaemon(cfg, network_id=network_id, test_suite=True)