Browse Source

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

The MMGen Project 2 years ago
parent
commit
7a72deed9f
3 changed files with 6 additions and 5 deletions
  1. 2 1
      mmgen/daemon.py
  2. 3 3
      test/include/common.py
  3. 1 1
      test/test_py_d/ts_regtest.py

+ 2 - 1
mmgen/daemon.py

@@ -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])
 

+ 3 - 3
test/include/common.py

@@ -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):

+ 1 - 1
test/test_py_d/ts_regtest.py

@@ -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'])