test.py: start Bitcoin daemon only when required

This commit is contained in:
The MMGen Project 2022-08-04 13:44:31 +00:00
commit d44f05ff57
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 8 additions and 3 deletions

View file

@ -657,7 +657,7 @@ class TestSuiteRunner(object):
if not quiet:
bmsg('Executing ' + m)
if not self.daemon_started and network_id not in ('eth','etc','xmr'):
if (not self.daemon_started) and self.gm.get_cls_by_gname(gname).need_daemon:
start_test_daemons(network_id,remove_datadir=True)
self.daemon_started = True
@ -943,10 +943,10 @@ try:
tr = TestSuiteRunner(data_dir,trash_dir)
tr.run_tests(usr_args)
tr.warn_skipped()
if network_id not in ('eth','etc','xmr'):
if tr.daemon_started:
stop_test_daemons(network_id)
except KeyboardInterrupt:
if network_id not in ('eth','etc','xmr'):
if tr.daemon_started:
stop_test_daemons(network_id)
tr.warn_skipped()
die(1,'\ntest.py exiting at user request')

View file

@ -34,6 +34,7 @@ class TestSuiteBase(object):
networks = ()
segwit_opts_ok = False
color = False
need_daemon = False
def __init__(self,trunner,cfgs,spawn):
from mmgen.protocol import init_proto_from_opts

View file

@ -72,6 +72,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
passthru_opts = ('daemon_data_dir','rpc_port','coin','testnet')
segwit_opts_ok = True
color = True
need_daemon = True
cmd_group = (
('walletgen_dfl_wallet', (15,'wallet generation (default wallet)',[[[],15]])),
('subwalletgen_dfl_wallet', (15,'subwallet generation (default wallet)',[[[pwfile],15]])),

View file

@ -34,6 +34,7 @@ class TestSuiteMisc(TestSuiteBase):
cmd_group = (
('rpc_backends', 'RPC backends'),
)
need_daemon = True
def rpc_backends(self):
backends = g.autoset_opts['rpc_backend'][1]
@ -173,6 +174,7 @@ class TestSuiteRefTX(TestSuiteMain,TestSuiteBase):
segwit_opts_ok = False
passthru_opts = ('daemon_data_dir','rpc_port','coin','testnet')
tmpdir_nums = [31,32,33,34]
need_daemon = True
cmd_group = (
('ref_tx_addrgen1', (31,'address generation (legacy)', [[[],1]])),
('ref_tx_addrgen2', (32,'address generation (compressed)', [[[],1]])),

View file

@ -37,6 +37,7 @@ class TestSuiteRef(TestSuiteBase,TestSuiteShared):
tmpdir_nums = [8]
networks = ('btc','btc_tn','ltc','ltc_tn')
passthru_opts = ('daemon_data_dir','rpc_port','coin','testnet')
need_daemon = True
sources = {
'ref_addrfile': '98831F3A{}[1,31-33,500-501,1010-1011]{}.addrs',
'ref_segwitaddrfile':'98831F3A{}-S[1,31-33,500-501,1010-1011]{}.addrs',