add regtest user Carol (for tracking wallet testing)

This commit is contained in:
The MMGen Project 2022-05-28 19:41:44 +00:00
commit 9e8495fa2e
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 21 additions and 9 deletions

View file

@ -67,7 +67,7 @@ class MMGenRegtest(MMGenObject):
rpc_user = 'bobandalice'
rpc_password = 'hodltothemoon'
users = ('bob','alice','miner')
users = ('bob','alice','carol','miner')
coins = ('btc','bch','ltc')
usr_cmds = ('setup','generate','send','start','stop', 'state', 'balances','mempool','cli','wallet_cli')

View file

@ -164,7 +164,7 @@ class BitcoinRPCClient(RPCClient,metaclass=AsyncInit):
is created, False otherwise
"""
if called or self.chain == 'regtest':
if called or (self.chain == 'regtest' and g.regtest_user != 'carol'):
return False
twname = self.daemon.tracking_wallet_name
@ -173,7 +173,14 @@ class BitcoinRPCClient(RPCClient,metaclass=AsyncInit):
m = f'Please fix your {self.daemon.desc} wallet installation or cmdline options'
ret = False
if len(loaded_wnames) == 1:
if g.carol:
if 'carol' in loaded_wnames:
ret = True
elif wallet_create:
await self.icall('createwallet',wallet_name='carol')
ymsg(f'Created {self.daemon.coind_name} wallet {"carol"!r}')
ret = True
elif len(loaded_wnames) == 1:
loaded_wname = loaded_wnames[0]
if twname in wnames and loaded_wname != twname:
await self.call('unloadwallet',loaded_wname)

View file

@ -105,6 +105,8 @@ class GlobalContext(Lockable):
# regtest:
bob = False
alice = False
carol = False
regtest_user = None
# miscellaneous features:
use_internal_keccak_module = False
@ -165,8 +167,9 @@ class GlobalContext(Lockable):
common_opts = (
'accept_defaults',
'aiohttp_rpc_queue_len',
'alice',
'bob',
'alice',
'carol',
'coin',
'color',
'columns',
@ -189,7 +192,7 @@ class GlobalContext(Lockable):
init_opts = ('show_hash_presets','yes','verbose')
incompatible_opts = (
('help','longhelp'),
('bob','alice'),
('bob','alice','carol'),
('label','keep_label'),
('tx_id','info'),
('tx_id','terse_info'),

View file

@ -236,8 +236,9 @@ common_opts_data = {
--, --testnet=0|1 Disable or enable testnet
--, --skip-cfg-file Skip reading the configuration file
--, --version Print version information and exit
--, --bob Specify user "Bob" in MMGen regtest mode
--, --alice Specify user "Alice" in MMGen regtest mode
--, --bob Specify user Bob in MMGen regtest mode
--, --alice Specify user Alice in MMGen regtest mode
--, --carol Specify user Carol in MMGen regtest mode
""",
'code': lambda help_notes,proto,s: s.format(
pnm = g.proj_name,
@ -375,9 +376,10 @@ def init(
g.coin = g.coin.upper() or 'BTC'
g.token = g.token.upper() or None
if g.bob or g.alice or g.prog_name == 'mmgen-regtest':
if g.bob or g.alice or g.carol or g.prog_name == 'mmgen-regtest':
g.regtest_user = 'bob' if g.bob else 'alice' if g.alice else 'carol' if g.carol else None
g.regtest = True
g.data_dir = os.path.join(g.data_dir_root,'regtest',g.coin.lower(),('alice','bob')[g.bob])
g.data_dir = os.path.join(g.data_dir_root,'regtest',g.coin.lower(),(g.regtest_user or 'none'))
# === end global var initialization === #