From 851335106f2bb306596dfcafa369af2f8558dd7d Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 15 Nov 2025 09:50:21 +0000 Subject: [PATCH] cmdtest.py xmr_autosign: support compat mode testing Testing: # Compat mode is now enabled by default: $ test/cmdtest.py -ne xmr_autosign # The old testing behavior is also supported: $ test/cmdtest.py -ne xmr_autosign_nocompat --- mmgen/cfg.py | 5 ++++- mmgen/data/version | 2 +- mmgen/opts.py | 1 + test/cmdtest_d/include/cfg.py | 1 + test/cmdtest_d/xmr_autosign.py | 24 ++++++++++++++++++------ test/cmdtest_d/xmrwallet.py | 18 +++++++++++++----- test/test-release.d/cfg.sh | 2 ++ 7 files changed, 40 insertions(+), 13 deletions(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index 694c4c1b..80ab8df8 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -231,6 +231,7 @@ class Config(Lockable): bob = False alice = False carol = False + miner = False test_user = '' # altcoin: @@ -284,7 +285,7 @@ class Config(Lockable): _incompatible_opts = ( ('help', 'longhelp'), - ('bob', 'alice', 'carol'), + ('bob', 'alice', 'carol', 'miner'), ('label', 'keep_label'), ('tx_id', 'info'), ('tx_id', 'terse_info'), @@ -559,6 +560,7 @@ class Config(Lockable): self.bob or self.alice or self.carol or + self.miner or gc.prog_name == f'{gc.proj_id}-regtest'): if self.coin != 'XMR': self.network = 'regtest' @@ -566,6 +568,7 @@ class Config(Lockable): 'bob' if self.bob else 'alice' if self.alice else 'carol' if self.carol else + 'miner' if self.miner else '') else: self.network = 'testnet' if self.testnet else 'mainnet' diff --git a/mmgen/data/version b/mmgen/data/version index 1b938cdc..4d738446 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -16.1.dev13 +16.1.dev14 diff --git a/mmgen/opts.py b/mmgen/opts.py index 5fc548b6..d689facd 100755 --- a/mmgen/opts.py +++ b/mmgen/opts.py @@ -320,6 +320,7 @@ class UserOpts(Opts): x- --bob Specify user ‘Bob’ in MMGen regtest or test mode x- --alice Specify user ‘Alice’ in MMGen regtest or test mode x- --carol Specify user ‘Carol’ in MMGen regtest or test mode + x- --miner Specify user ‘Miner’ in MMGen regtest or test mode rr COIN-SPECIFIC OPTIONS: rr For descriptions, refer to the non-prefixed versions of these options above rr Prefixed options override their non-prefixed counterparts diff --git a/test/cmdtest_d/include/cfg.py b/test/cmdtest_d/include/cfg.py index d8c63d2d..0cee7ce9 100755 --- a/test/cmdtest_d/include/cfg.py +++ b/test/cmdtest_d/include/cfg.py @@ -61,6 +61,7 @@ cmd_groups_extra = { 'autosign_live': gd('CmdTestAutosignLive', {'modname': 'autosign'}), 'autosign_live_simulate': gd('CmdTestAutosignLiveSimulate', {'modname': 'autosign'}), 'create_ref_tx': gd('CmdTestRefTX', {'modname': 'misc', 'full_data': True}), + 'xmr_autosign_nocompat': gd('CmdTestXMRAutosignNoCompat', {'modname': 'xmr_autosign'}), } cfgs = { # addr_idx_lists (except 31, 32, 33, 34) must contain exactly 8 addresses diff --git a/test/cmdtest_d/xmr_autosign.py b/test/cmdtest_d/xmr_autosign.py index 9d41db50..23e19243 100755 --- a/test/cmdtest_d/xmr_autosign.py +++ b/test/cmdtest_d/xmr_autosign.py @@ -33,7 +33,7 @@ def make_burn_addr(cfg): class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded): """ - Monero autosigning operations + Monero autosigning operations (xmrwallet compat mode) """ tmpdir_nums = [39] @@ -46,6 +46,7 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded): # autosign attrs: coins = ['xmr'] + compat = True cmd_group = ( ('daemon_version', 'checking daemon version'), @@ -109,10 +110,14 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded): self.alice_cfg = Config({ 'coin': 'XMR', 'outdir': self.users['alice'].udir, - 'wallet_dir': self.users['alice'].udir, 'wallet_rpc_password': 'passwOrd', 'test_suite': True, - }) + } | ({ + 'alice': True, + 'compat': True + } if self.compat else { + 'wallet_dir': self.users['alice'].udir + })) self.burn_addr = make_burn_addr(cfg) @@ -178,7 +183,7 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded): t = self.spawn( 'mmgen-xmrwallet', self.extra_opts - + [f'--wallet-dir={data.udir}'] + + (['--alice', '--compat'] if self.compat else [f'--wallet-dir={data.udir}']) + [f'--daemon=localhost:{data.md.rpc_port}'] + (self.autosign_opts if autosign else []) + ['dump'] @@ -191,8 +196,9 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded): def _delete_files(self, *ext_list): data = self.users['alice'] self.spawn(msg_only=True) + wdir = data.wd.wallet_dir if self.compat else data.udir for ext in ext_list: - get_file_with_ext(data.udir, ext, no_dot=True, delete_all=True) + get_file_with_ext(wdir, ext, no_dot=True, delete_all=True) return 'ok' def delete_tmp_wallets(self): @@ -312,7 +318,7 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded): args = ( self.extra_opts + self.autosign_opts - + [f'--wallet-dir={data.udir}'] + + (['--alice', '--compat'] if self.compat else [f'--wallet-dir={data.udir}']) + [f'--daemon=localhost:{data.md.rpc_port}'] + add_opts + [op] @@ -472,3 +478,9 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded): def listview(self): return self.sync_wallets('alice', op='listview', wallets='2') + +class CmdTestXMRAutosignNoCompat(CmdTestXMRAutosign): + """ + Monero autosigning operations (non-xmrwallet compat mode) + """ + compat = False diff --git a/test/cmdtest_d/xmrwallet.py b/test/cmdtest_d/xmrwallet.py index 74318515..67af91b7 100755 --- a/test/cmdtest_d/xmrwallet.py +++ b/test/cmdtest_d/xmrwallet.py @@ -72,6 +72,7 @@ class CmdTestXMRWallet(CmdTestBase): ) tx_relay_user = 'bob' daemon_datadir_base = os.path.join('test', 'daemons', 'xmrtest') + compat = False cmd_group = ( ('daemon_version', 'checking daemon version'), @@ -183,6 +184,13 @@ class CmdTestXMRWallet(CmdTestBase): udir = os.path.join(tmpdir, user) daemon_datadir = os.path.join(self.daemon_datadir_base, user) + if self.compat: + from mmgen.tw.ctl import TwCtl + twctl_cls = self.proto.base_proto_subclass(TwCtl, 'tw.ctl') + wallet_dir = os.path.join(self.tr.data_dir, user, 'altcoins', 'xmr', twctl_cls.tw_subdir) + else: + wallet_dir = udir + md = CoinDaemon( cfg = self.cfg, proto = self.proto, @@ -205,7 +213,7 @@ class CmdTestXMRWallet(CmdTestBase): cfg = self.cfg, proto = self.proto, test_suite = True, - wallet_dir = udir, + wallet_dir = wallet_dir, user = 'foo', passwd = 'bar', port_shift = shift, @@ -294,7 +302,7 @@ class CmdTestXMRWallet(CmdTestBase): t = self.spawn( 'mmgen-xmrwallet', self.extra_opts - + [f'--wallet-dir={data.udir}'] + + ([f'--{user}', '--compat'] if self.compat else [f'--wallet-dir={data.udir}']) + (self.autosign_opts if data.autosign else []) + add_opts + [op] @@ -313,7 +321,7 @@ class CmdTestXMRWallet(CmdTestBase): t = self.spawn( 'mmgen-xmrwallet', self.extra_opts - + [f'--wallet-dir={data.udir}'] + + (['--alice', '--compat'] if self.compat else [f'--wallet-dir={data.udir}']) + [f'--daemon=localhost:{data.md.rpc_port}'] + (['--no-start-wallet-daemon'] if cfg in ('continue', 'stop') else []) + (['--no-stop-wallet-daemon'] if cfg in ('start', 'continue') else []) @@ -415,7 +423,7 @@ class CmdTestXMRWallet(CmdTestBase): t = self.spawn( 'mmgen-xmrwallet', self.extra_opts - + [f'--wallet-dir={data.udir}'] + + ([f'--{user}', '--compat'] if self.compat else [f'--wallet-dir={data.udir}']) + [f'--daemon=localhost:{data.md.rpc_port}'] + (self.autosign_opts if data.autosign else []) + add_opts @@ -466,7 +474,7 @@ class CmdTestXMRWallet(CmdTestBase): t = self.spawn( 'mmgen-xmrwallet', self.extra_opts - + [f'--wallet-dir={data.udir}'] + + ([f'--{user}', '--compat'] if self.compat else [f'--wallet-dir={data.udir}']) + cmd_opts + add_opts + (self.autosign_opts if data.autosign else []) diff --git a/test/test-release.d/cfg.sh b/test/test-release.d/cfg.sh index 0fd37bd6..29c54280 100755 --- a/test/test-release.d/cfg.sh +++ b/test/test-release.d/cfg.sh @@ -295,7 +295,9 @@ init_tests() { d_xmr="Monero xmrwallet operations" t_xmr=" - $xmr_env1$xmr_env2$xmr_env3$cmdtest_py --coin=xmr --exclude help + s $xmr_env1$xmr_env2$xmr_env3$cmdtest_py --coin=xmr xmr_autosign_nocompat " + [ "$FAST" ] && t_xmr_skip='s' d_tool2="'mmgen-tool' utility with data check" t_tool2="