g.testnet -> g.network == 'testnet'

This commit is contained in:
The MMGen Project 2023-03-27 10:48:20 +00:00
commit 9cb02db5c0
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 18 additions and 15 deletions

View file

@ -165,7 +165,7 @@ async def check_daemons_running():
coins = ['BTC']
for coin in coins:
proto = init_proto(coin,testnet=g.testnet,need_amt=True)
proto = init_proto( coin, testnet=g.network=='testnet', need_amt=True )
if proto.sign_mode == 'daemon':
vmsg(f'Checking {coin} daemon')
from .exception import SocketError

View file

@ -367,7 +367,7 @@ def init(
cfgfile_autoset_opts = {}
if not (opt.skip_cfg_file or opt.bob or opt.alice or g.prog_name == 'mmgen-regtest'):
if not opt.skip_cfg_file:
from .cfgfile import mmgen_cfg_file
# check for changes in system template file - term must be initialized
mmgen_cfg_file('sample',g.data_dir_root)
@ -385,6 +385,17 @@ def init(
if val != None and hasattr(g,k):
setattr(g,k,set_for_type(val,getattr(g,k),'--'+k))
if g.regtest or g.bob or g.alice or g.carol or g.prog_name == 'mmgen-regtest':
g.network = 'regtest'
g.regtest_user = 'bob' if g.bob else 'alice' if g.alice else 'carol' if g.carol else None
else:
g.network = 'testnet' if g.testnet else 'mainnet'
g.coin = g.coin.upper() or 'BTC'
g.token = g.token.upper() or None
# === end global var initialization === #
"""
g.color is finalized, so initialize color
"""
@ -408,20 +419,13 @@ def init(
else:
setattr(opt,k,getattr(g,k))
g.coin = g.coin.upper() or 'BTC'
g.token = g.token.upper() or None
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
if g.network == 'regtest':
g.data_dir = os.path.join(
g.data_dir_root,
'regtest',
g.coin.lower(),
(g.regtest_user or 'none') )
# === end global var initialization === #
if need_proto:
from .protocol import warn_trustlevel
warn_trustlevel(g.coin)

View file

@ -273,8 +273,7 @@ def init_proto(coin=None,testnet=False,regtest=False,network=None,network_id=Non
def init_proto_from_opts(need_amt=False):
return init_proto(
coin = g.coin,
testnet = g.testnet,
regtest = g.regtest,
network = g.network,
tokensym = g.token,
need_amt = need_amt )

View file

@ -287,7 +287,7 @@ class MoneroWalletOps:
cls.check_uopts(self)
id_cur = id(cls.check_uopts)
self.proto = init_proto( 'xmr', testnet=g.testnet, need_amt=True )
self.proto = init_proto( 'xmr', network=g.network, need_amt=True )
def check_uopts(self):
@ -393,7 +393,7 @@ class MoneroWalletOps:
uopt.wallet_dir or '.','{}-{}-MoneroWallet{}{}'.format(
self.kal.al_id.sid,
d.idx,
'.testnet' if g.testnet else '',
f'.{g.network}' if g.network != 'mainnet' else '',
'' if g.debug_utf8 else '' ))
async def main(self):

View file

@ -328,7 +328,7 @@ class TestSuiteXMRWallet(TestSuiteBase):
[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 []) +
[ '--alice', 'new', data.kafile, spec ] )
[ 'new', data.kafile, spec ] )
res = strip_ansi_escapes(t.read()).replace('\r','')
m = re.search(expect,res,re.DOTALL)
assert m, m