daemon.py: for test suite, use separate dir trees for each network

This commit is contained in:
The MMGen Project 2022-03-30 15:49:44 +00:00
commit 7a72deed9f
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 6 additions and 5 deletions

View file

@ -311,6 +311,7 @@ class CoinDaemon(Daemon):
daemon_id + '_daemon' ))
assert network in me.networks, f'{network!r}: unsupported network for daemon {daemon_id}'
me.network_id = network_id
me.network = network
me.coin = coin
me.coin_name = cls.coins[coin].coin_name
@ -373,7 +374,7 @@ class CoinDaemon(Daemon):
def init_datadir(self):
if self.test_suite:
return os.path.join('test','daemons',self.coin.lower())
return os.path.join('test','daemons',self.network_id)
else:
return os.path.join(*self.datadirs[self.platform])

View file

@ -210,9 +210,9 @@ def start_test_daemons(*network_ids,remove_datadir=False):
if not opt.no_daemon_autostart:
return test_daemons_ops(*network_ids,op='start',remove_datadir=remove_datadir)
def stop_test_daemons(*network_ids):
if not opt.no_daemon_stop:
return test_daemons_ops(*network_ids,op='stop')
def stop_test_daemons(*network_ids,force=False,remove_datadir=False):
if force or not opt.no_daemon_stop:
return test_daemons_ops(*network_ids,op='stop',remove_datadir=remove_datadir)
def restart_test_daemons(*network_ids,remove_datadir=False):
if not stop_test_daemons(*network_ids):

View file

@ -314,7 +314,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
end_silence()
def setup(self):
stop_test_daemons(self.proto.network_id)
stop_test_daemons(self.proto.network_id,force=True,remove_datadir=True)
try: shutil.rmtree(joinpath(self.tr.data_dir,'regtest'))
except: pass
t = self.spawn('mmgen-regtest',['-n','setup'])