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
This commit is contained in:
The MMGen Project 2025-11-15 09:50:21 +00:00
commit 851335106f
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
7 changed files with 40 additions and 13 deletions

View file

@ -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'

View file

@ -1 +1 @@
16.1.dev13
16.1.dev14

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 [])

View file

@ -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="