minor changes/fixes
This commit is contained in:
parent
a4eee3ef4b
commit
ffa49545e4
5 changed files with 25 additions and 20 deletions
|
|
@ -208,7 +208,10 @@ class Daemon(MMGenObject):
|
|||
|
||||
def remove_datadir(self):
|
||||
if self.state == 'stopped':
|
||||
run(['/bin/rm','-rf',self.datadir])
|
||||
try: # exception handling required for MSWin/MSYS2
|
||||
run(['/bin/rm','-rf',self.datadir])
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
msg(f'Cannot remove {self.datadir!r} - daemon is not stopped')
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ class GlobalContext(Lockable):
|
|||
debug_utf8 = False
|
||||
traceback = False
|
||||
test_suite = False
|
||||
test_suite_regtest = False
|
||||
test_suite_popen_spawn = False
|
||||
terminal_width = 0
|
||||
|
||||
|
|
@ -197,6 +198,7 @@ class GlobalContext(Lockable):
|
|||
'MMGEN_DEBUG_ALL', # special: there is no g.debug_all var
|
||||
|
||||
'MMGEN_TEST_SUITE',
|
||||
'MMGEN_TEST_SUITE_REGTEST',
|
||||
'MMGEN_TEST_SUITE_POPEN_SPAWN',
|
||||
'MMGEN_TERMINAL_WIDTH',
|
||||
'MMGEN_BOGUS_WALLET_DATA',
|
||||
|
|
|
|||
|
|
@ -551,15 +551,15 @@ def check_usr_opts(usr_opts): # Raises an exception if any check fails
|
|||
# m = '--rbf requested, but {} does not support replace-by-fee transactions'
|
||||
# raise UserOptError(m.format(proto.coin))
|
||||
|
||||
def chk_bob(key,val,desc):
|
||||
m = "Regtest (Bob and Alice) mode not set up yet. Run '{}-regtest setup' to initialize."
|
||||
from .regtest import MMGenRegtest
|
||||
try:
|
||||
os.stat(os.path.join(MMGenRegtest(g.coin).d.datadir,'regtest','debug.log'))
|
||||
except:
|
||||
raise UserOptError(m.format(g.proj_name.lower()))
|
||||
|
||||
chk_alice = chk_bob
|
||||
# def chk_bob(key,val,desc):
|
||||
# m = "Regtest (Bob and Alice) mode not set up yet. Run '{}-regtest setup' to initialize."
|
||||
# from .regtest import MMGenRegtest
|
||||
# try:
|
||||
# os.stat(os.path.join(MMGenRegtest(g.coin).d.datadir,'regtest','debug.log'))
|
||||
# except:
|
||||
# raise UserOptError(m.format(g.proj_name.lower()))
|
||||
#
|
||||
# chk_alice = chk_bob
|
||||
|
||||
def chk_locktime(key,val,desc):
|
||||
opt_is_int(val,desc)
|
||||
|
|
|
|||
|
|
@ -81,8 +81,7 @@ class MMGenRegtest(MMGenObject):
|
|||
def __init__(self,coin):
|
||||
self.coin = coin.lower()
|
||||
self.proto = init_proto(self.coin,regtest=True)
|
||||
self.test_suite = os.getenv('MMGEN_TEST_SUITE_REGTEST')
|
||||
self.d = CoinDaemon(self.coin+'_rt',test_suite=self.test_suite)
|
||||
self.d = CoinDaemon(self.coin+'_rt',test_suite=g.test_suite_regtest)
|
||||
|
||||
assert self.coin in self.coins,'{!r}: invalid coin for regtest'.format(user)
|
||||
|
||||
|
|
@ -118,18 +117,16 @@ class MMGenRegtest(MMGenObject):
|
|||
return self.test_daemon().state
|
||||
|
||||
def daemon_shared_args(self):
|
||||
return ['--rpcuser={}'.format(self.rpc_user),
|
||||
'--rpcpassword={}'.format(self.rpc_password),
|
||||
'--regtest' ]
|
||||
return [f'--rpcuser={self.rpc_user}', f'--rpcpassword={self.rpc_password}', '--regtest']
|
||||
|
||||
def daemon_coind_args(self,user):
|
||||
return ['--wallet=wallet.dat.{}'.format(user)]
|
||||
return [f'--wallet={user}']
|
||||
|
||||
def test_daemon(self,user=None,reindex=False):
|
||||
|
||||
assert user is None or user in self.users,'{!r}: invalid user for regtest'.format(user)
|
||||
|
||||
d = CoinDaemon(self.coin+'_rt',test_suite=self.test_suite)
|
||||
d = CoinDaemon(self.coin+'_rt',test_suite=g.test_suite_regtest)
|
||||
|
||||
type(d).generate = RegtestDaemon.generate
|
||||
|
||||
|
|
@ -163,7 +160,7 @@ class MMGenRegtest(MMGenObject):
|
|||
cmdout = run(cmd,stdout=PIPE).stdout.decode()
|
||||
if cmdout:
|
||||
for k in self.users:
|
||||
if 'wallet.dat.'+k in cmdout:
|
||||
if '--wallet='+k in cmdout:
|
||||
return k
|
||||
return None
|
||||
|
||||
|
|
@ -182,7 +179,7 @@ class MMGenRegtest(MMGenObject):
|
|||
|
||||
lines = reversed(get_log_tail(40_000).decode().splitlines())
|
||||
|
||||
pat = re.compile(r'\bwallet\.dat\.([a-z]+)')
|
||||
pat = re.compile(r'\b(alice|bob|miner)\b')
|
||||
for ss in ( 'BerkeleyEnvironment::Open',
|
||||
'Wallet completed loading in',
|
||||
'Using wallet wallet' ):
|
||||
|
|
|
|||
|
|
@ -224,7 +224,10 @@ def check_or_create_dir(path):
|
|||
except:
|
||||
if os.getenv('MMGEN_TEST_SUITE'):
|
||||
from subprocess import run
|
||||
run(['/bin/rm','-rf',path])
|
||||
try: # exception handling required for MSWin/MSYS2
|
||||
run(['/bin/rm','-rf',path])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
os.makedirs(path,0o700)
|
||||
except:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue