From 3b3d06fb511da6ff8cf09f406c25871921e66495 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 8 Oct 2024 12:55:58 +0000 Subject: [PATCH] cmdtest.py: remove unneeded opts from spawn cmdline --- test/cmdtest.py | 1 - test/cmdtest_py_d/ct_automount.py | 1 - test/cmdtest_py_d/ct_base.py | 2 +- test/cmdtest_py_d/ct_ethdev.py | 1 - test/cmdtest_py_d/ct_main.py | 15 +++++++++------ test/cmdtest_py_d/ct_misc.py | 10 ++++++---- test/cmdtest_py_d/ct_ref.py | 12 ++++++++++-- test/cmdtest_py_d/ct_ref_3seed.py | 2 +- test/cmdtest_py_d/ct_regtest.py | 11 +++++++---- test/cmdtest_py_d/ct_shared.py | 4 +++- test/include/common.py | 14 ++++++++++++++ 11 files changed, 51 insertions(+), 22 deletions(-) diff --git a/test/cmdtest.py b/test/cmdtest.py index 4f117129..5287914d 100755 --- a/test/cmdtest.py +++ b/test/cmdtest.py @@ -574,7 +574,6 @@ class CmdTestRunner: ([] if no_exec_wrapper else ['scripts/exec_wrapper.py']) + [cmd_path] + ([] if no_passthru_opts else self.passthru_opts) + - self.tg.extra_spawn_args + args ) try: diff --git a/test/cmdtest_py_d/ct_automount.py b/test/cmdtest_py_d/ct_automount.py index 3db6d6b3..dc09bca1 100755 --- a/test/cmdtest_py_d/ct_automount.py +++ b/test/cmdtest_py_d/ct_automount.py @@ -24,7 +24,6 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtestBDBWallet) networks = ('btc', 'bch', 'ltc') tmpdir_nums = [49] - extra_spawn_args = [] rtFundAmt = None # pylint rt_data = { diff --git a/test/cmdtest_py_d/ct_base.py b/test/cmdtest_py_d/ct_base.py index aec6a2a8..fe3be363 100755 --- a/test/cmdtest_py_d/ct_base.py +++ b/test/cmdtest_py_d/ct_base.py @@ -32,7 +32,6 @@ class CmdTestBase: 'initializer class for the cmdtest.py test suite' base_passthru_opts = ('data_dir','skip_cfg_file') passthru_opts = () - extra_spawn_args = [] networks = () segwit_opts_ok = False color = False @@ -56,6 +55,7 @@ class CmdTestBase: self.coin = self.proto.coin.lower() self.fork = 'btc' if self.coin == 'bch' and not cfg.cashaddr else self.coin self.altcoin_pfx = '' if self.fork == 'btc' else f'-{self.proto.coin}' + self.testnet_opt = [f'--testnet=1'] if cfg.testnet else [] if len(self.tmpdir_nums) == 1: self.tmpdir_num = self.tmpdir_nums[0] if self.tr: diff --git a/test/cmdtest_py_d/ct_ethdev.py b/test/cmdtest_py_d/ct_ethdev.py index c3f6f066..00670c6c 100755 --- a/test/cmdtest_py_d/ct_ethdev.py +++ b/test/cmdtest_py_d/ct_ethdev.py @@ -163,7 +163,6 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared): 'Ethereum transacting, token deployment and tracking wallet operations' networks = ('eth','etc') passthru_opts = ('coin','daemon_id','http_timeout','rpc_backend') - extra_spawn_args = ['--regtest=1'] tmpdir_nums = [22] color = True cmd_group_in = ( diff --git a/test/cmdtest_py_d/ct_main.py b/test/cmdtest_py_d/ct_main.py index f7ff88fb..709c68e0 100755 --- a/test/cmdtest_py_d/ct_main.py +++ b/test/cmdtest_py_d/ct_main.py @@ -374,7 +374,7 @@ class CmdTestMain(CmdTestBase,CmdTestShared): args += ['-d',self.tmpdir] if seed_len: args += ['-l',str(seed_len)] - t = self.spawn('mmgen-walletgen', args + [self.usr_rand_arg]) + t = self.spawn('mmgen-walletgen', self.testnet_opt + args + [self.usr_rand_arg], no_passthru_opts=True) t.license() t.usr_rand(self.usr_rand_chars) wcls = MMGenWallet @@ -390,7 +390,7 @@ class CmdTestMain(CmdTestBase,CmdTestShared): args = [self.usr_rand_arg,'-p1','-d',self.tr.trash_dir,'-L','Label'] if wf != 'default': args += [wf] - t = self.spawn('mmgen-subwalletgen', args + ['10s']) + t = self.spawn('mmgen-subwalletgen', self.testnet_opt + args + ['10s'], no_passthru_opts=True) t.license() wcls = MMGenWallet t.passphrase(wcls.desc,self.cfgs['1']['wpasswd']) @@ -406,7 +406,7 @@ class CmdTestMain(CmdTestBase,CmdTestShared): icls = get_wallet_cls(ext=get_extension(wf)) ocls = get_wallet_cls('words') args = [self.usr_rand_arg,'-p1','-d',self.tr.trash_dir,'-o',ocls.fmt_codes[0],wf,'3L'] - t = self.spawn('mmgen-subwalletgen', args) + t = self.spawn('mmgen-subwalletgen', self.testnet_opt + args, no_passthru_opts=True) t.license() t.passphrase(icls.desc,self.cfgs['1']['wpasswd']) t.expect(r'Generating subseed.*\D3L',regex=True) @@ -424,7 +424,10 @@ class CmdTestMain(CmdTestBase,CmdTestShared): 'keep': ['-d',self.tr.trash_dir,'--keep-label'], 'user': ['-d',self.tr.trash_dir] }[label_action] - t = self.spawn('mmgen-passchg', add_args + [self.usr_rand_arg, '-p2'] + ([wf] if wf else [])) + t = self.spawn( + 'mmgen-passchg', + self.testnet_opt + add_args + [self.usr_rand_arg, '-p2'] + ([wf] if wf else []), + no_passthru_opts = True) t.license() wcls = MMGenWallet t.passphrase(wcls.desc,self.cfgs['1']['wpasswd'],pwtype='old') @@ -712,7 +715,7 @@ class CmdTestMain(CmdTestBase,CmdTestShared): def _walletconv_export(self,wf,uargs=[],out_fmt='w',pf=None): opts = ['-d',self.tmpdir,'-o',out_fmt] + uargs + \ ([],[wf])[bool(wf)] + ([],['-P',pf])[bool(pf)] - t = self.spawn('mmgen-walletconv',opts) + t = self.spawn('mmgen-walletconv', self.testnet_opt + opts, no_passthru_opts=True) t.license() if not pf: @@ -888,7 +891,7 @@ class CmdTestMain(CmdTestBase,CmdTestShared): make_brainwallet_file(bwf) seed_len = str(self.seed_len) args = ['-d',self.tmpdir,'-p1',self.usr_rand_arg,'-l'+seed_len,'-ibw'] - t = self.spawn('mmgen-walletconv', args + [bwf]) + t = self.spawn('mmgen-walletconv', self.testnet_opt + args + [bwf], no_passthru_opts=True) t.license() wcls = MMGenWallet t.passphrase_new('new ' +wcls.desc,self.wpasswd) diff --git a/test/cmdtest_py_d/ct_misc.py b/test/cmdtest_py_d/ct_misc.py index 2da1f5d9..e9555ac5 100755 --- a/test/cmdtest_py_d/ct_misc.py +++ b/test/cmdtest_py_d/ct_misc.py @@ -24,7 +24,7 @@ import sys, os, re, time from mmgen.util import ymsg, die -from ..include.common import cfg, start_test_daemons, stop_test_daemons, imsg +from ..include.common import cfg, start_test_daemons, stop_test_daemons, imsg, proto_cmds from .common import get_file_with_ext, dfl_words_file from .ct_base import CmdTestBase from .ct_main import CmdTestMain @@ -197,7 +197,7 @@ class CmdTestHelp(CmdTestBase): ) def usage(self): - t = self.spawn('mmgen-walletgen', ['foo'], exit_val=1) + t = self.spawn('mmgen-walletgen', ['foo'], exit_val=1, no_passthru_opts=True) t.expect('USAGE: mmgen-walletgen') return t @@ -210,7 +210,8 @@ class CmdTestHelp(CmdTestBase): t = self.spawn( 'mmgen-walletconv', ['--stdout', '--in-fmt=hex', '--out-fmt=hex'], - env = {'MMGEN_NO_LICENSE':''} ) + env = {'MMGEN_NO_LICENSE':''}, + no_passthru_opts = True) t.expect('to continue: ', 'w') t.expect('TERMS AND CONDITIONS') # start of GPL text if cfg.pexpect_spawn: @@ -252,7 +253,8 @@ class CmdTestHelp(CmdTestBase): t = self.spawn( f'mmgen-{cmdname}', [arg], - extra_desc = f'(mmgen-{cmdname})') + extra_desc = f'(mmgen-{cmdname})', + no_passthru_opts = not cmdname in proto_cmds) t.expect(expect,regex=True) if pager and t.pexpect_spawn: time.sleep(0.2) diff --git a/test/cmdtest_py_d/ct_ref.py b/test/cmdtest_py_d/ct_ref.py index 53fb8376..91a2f153 100755 --- a/test/cmdtest_py_d/ct_ref.py +++ b/test/cmdtest_py_d/ct_ref.py @@ -188,14 +188,22 @@ class CmdTestRef(CmdTestBase,CmdTestShared): ocls = get_wallet_cls('words') args = ['-d',self.tr.trash_dir,'-o',ocls.fmt_codes[-1],wf,ss_idx] - t = self.spawn('mmgen-subwalletgen',args,extra_desc='(generate subwallet)') + t = self.spawn( + 'mmgen-subwalletgen', + self.testnet_opt + args, + extra_desc = '(generate subwallet)', + no_passthru_opts = True) t.expect(f'Generating subseed {ss_idx}') chk_sid = self.chk_data['ref_subwallet_sid'][f'98831F3A:{ss_idx}'] fn = t.written_to_file(capfirst(ocls.desc)) assert chk_sid in fn,f'incorrect filename: {fn} (does not contain {chk_sid})' ok() - t = self.spawn('mmgen-walletchk',[fn],extra_desc='(check subwallet)') + t = self.spawn( + 'mmgen-walletchk', + self.testnet_opt + [fn], + extra_desc = '(check subwallet)', + no_passthru_opts = True) t.expect(r'Valid MMGen native mnemonic data for Seed ID ([0-9A-F]*)\b',regex=True) sid = t.p.match.group(1) assert sid == chk_sid,f'subseed ID {sid} does not match expected value {chk_sid}' diff --git a/test/cmdtest_py_d/ct_ref_3seed.py b/test/cmdtest_py_d/ct_ref_3seed.py index ac7aa7bf..a87394e0 100755 --- a/test/cmdtest_py_d/ct_ref_3seed.py +++ b/test/cmdtest_py_d/ct_ref_3seed.py @@ -151,7 +151,7 @@ class CmdTestRef3Seed(CmdTestBase,CmdTestShared): args = ['-d',self.tmpdir,hp_arg,sl_arg,'-ibw','-L',label] self.write_to_tmpfile(bf,ref_wallet_brainpass) self.write_to_tmpfile(pwfile,self.wpasswd) - t = self.spawn('mmgen-walletconv', args + [self.usr_rand_arg]) + t = self.spawn('mmgen-walletconv', self.testnet_opt + args + [self.usr_rand_arg], no_passthru_opts=True) t.license() t.expect('Enter brainwallet: ', ref_wallet_brainpass+'\n') ocls = get_wallet_cls('mmgen') diff --git a/test/cmdtest_py_d/ct_regtest.py b/test/cmdtest_py_d/ct_regtest.py index 5191e3e9..a0206a0c 100755 --- a/test/cmdtest_py_d/ct_regtest.py +++ b/test/cmdtest_py_d/ct_regtest.py @@ -172,7 +172,6 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared): 'transacting and tracking wallet operations via regtest mode' networks = ('btc','ltc','bch') passthru_opts = ('coin','rpc_backend') - extra_spawn_args = ['--regtest=1'] tmpdir_nums = [17] color = True deterministic = False @@ -548,7 +547,7 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared): return t def walletgen(self,user): - t = self.spawn('mmgen-walletgen', ['-q', '-r0', '-p1', f'--{user}']) + t = self.spawn('mmgen-walletgen', ['-q', '-r0', '-p1', f'--{user}'], no_passthru_opts=True) t.passphrase_new(f'new {dfl_wcls.desc}', rt_pw) t.label() t.expect('move it to the data directory? (Y/n): ', 'y') @@ -1860,14 +1859,18 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared): def bob_walletconv_words(self): t = self.spawn( - 'mmgen-walletconv', [ '--bob', f'--outdir={self.tmpdir}', '--out-fmt=words' ] ) + 'mmgen-walletconv', + ['--bob', f'--outdir={self.tmpdir}', '--out-fmt=words'], + no_passthru_opts = True) t.passphrase(dfl_wcls.desc,rt_pw) t.written_to_file('data') return t def bob_subwalletgen_bip39(self): t = self.spawn( - 'mmgen-subwalletgen', [ '--bob', f'--outdir={self.tmpdir}', '--out-fmt=bip39', '29L' ] ) + 'mmgen-subwalletgen', + ['--bob', f'--outdir={self.tmpdir}', '--out-fmt=bip39', '29L'], + no_passthru_opts = True) t.passphrase(dfl_wcls.desc,rt_pw) t.written_to_file('data') return t diff --git a/test/cmdtest_py_d/ct_shared.py b/test/cmdtest_py_d/ct_shared.py index 7319ae92..53e1c99c 100755 --- a/test/cmdtest_py_d/ct_shared.py +++ b/test/cmdtest_py_d/ct_shared.py @@ -233,9 +233,11 @@ class CmdTestShared: t = self.spawn( 'mmgen-walletchk', ([] if dfl_wallet else ['-i',wcls.fmt_codes[0]]) + + self.testnet_opt + add_args + ['-p',hp] + ([wf] if wf else []), - extra_desc=extra_desc) + extra_desc = extra_desc, + no_passthru_opts = True) if wcls.type != 'incog_hidden': t.expect(f"Getting {wcls.desc} from file ‘") if wcls.enc and wcls.type != 'brain': diff --git a/test/include/common.py b/test/include/common.py index 118bc8ff..f96d307f 100755 --- a/test/include/common.py +++ b/test/include/common.py @@ -97,6 +97,20 @@ sample_mn = { ref_kafile_pass = 'kafile password' ref_kafile_hash_preset = '1' +proto_cmds = ( + 'addrimport', + 'autosign', + 'msg', + 'regtest', + 'tool', + 'txbump', + 'txcreate', + 'txdo', + 'txsend', + 'txsign', + 'xmrwallet', +) + def getrand(n): if cfg.test_suite_deterministic: from mmgen.test import fake_urandom