cfg, opt: improve parsing of regtest opts

This commit is contained in:
The MMGen Project 2026-10-07 16:40:39 +00:00
commit 2c4f96e6a4
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 7 additions and 15 deletions

View file

@ -491,23 +491,11 @@ class Config(Lockable):
# Step 4: finalize some non-cfg-file opts:
self.coin = self.coin.upper()
self.token = self.token.upper() if self.token else None
if (
self.regtest or
self.bob or
self.alice or
self.carol or
self.miner or
gc.prog_name == 'mmgen-regtest'):
if self.test_user or self.regtest:
if self.coin != 'XMR':
self.network = 'regtest'
if gc.prog_name == 'mmgen-regtest' and self.coin != 'BTC':
self.bdb_wallet = True
self.test_user = (
'bob' if self.bob else
'alice' if self.alice else
'carol' if self.carol else
'miner' if self.miner else
'')
if not self.test_suite: # could be set in environment
self._use_cfg_file = False
else:

View file

@ -58,7 +58,7 @@ opts_data = {
}
}
cfg = Config(opts_data=opts_data)
cfg = Config(opts_data=opts_data, init_opts={'regtest': True})
cmd_args = cfg._args

View file

@ -23,6 +23,8 @@ from collections import namedtuple
from .cfg import gc
test_users = ('bob', 'alice', 'carol', 'miner')
def negated_opts(opts, data={}):
if data:
return data
@ -75,6 +77,8 @@ def process_uopts(cfg, opts_data, opts, need_proto):
if parm:
die('CmdlineOptError', f'option --{_opt} requires no parameter')
yield (opts[_opt].name, True)
if _opt in test_users:
yield ('test_user', opts[_opt].name)
elif (
(_opt := opt) in negated_opts(opts)
or (_opt := get_opt_by_substring(_opt, negated_opts(opts)))):

View file

@ -183,7 +183,7 @@ class CmdTestXMRWallet(CmdTestBase):
kal_range,
add_coind_args) in self.user_data:
usr_cfg = Config({'_clone': self.cfg, user: True, 'wallet_rpc_password': 'abc'})
usr_cfg = Config({'_clone': self.cfg, 'test_user': user, 'wallet_rpc_password': 'abc'})
udir = usr_cfg._proto.network_datadir
md = CoinDaemon(