From 2fc54bd1e1737874365f9ad9c869e680477f5cf6 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 31 Oct 2022 15:42:10 +0000 Subject: [PATCH] test suite: pexpect_spawn fixes --- test/test_py_d/ts_cfg.py | 2 +- test/test_py_d/ts_misc.py | 11 +++++++++-- test/test_py_d/ts_opts.py | 14 ++++++++------ test/test_py_d/ts_regtest.py | 14 +++++++++++--- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/test/test_py_d/ts_cfg.py b/test/test_py_d/ts_cfg.py index 6bb5dcd0..ba1a5bd8 100755 --- a/test/test_py_d/ts_cfg.py +++ b/test/test_py_d/ts_cfg.py @@ -99,7 +99,7 @@ class TestSuiteCfg(TestSuiteBase): e = CfgFileSampleUsr.altered_by_user_fs.format(self.path('sample')) return self.bad_sample(s,e) - def old_sample_common(self,old_set=False,args=[],pexpect_spawn=None): + def old_sample_common(self,old_set=False,args=[],pexpect_spawn=False): s = read_from_file(self.path('sys')) d = s.replace('monero_','zcash_').splitlines() a1 = ['','# Uncomment to make foo true:','# foo true'] diff --git a/test/test_py_d/ts_misc.py b/test/test_py_d/ts_misc.py index 4d30c8fb..8db56ca6 100755 --- a/test/test_py_d/ts_misc.py +++ b/test/test_py_d/ts_misc.py @@ -86,12 +86,15 @@ class TestSuiteHelp(TestSuiteBase): expect = kwargs.pop('expect') t = self.spawn(*args,**kwargs) t.expect(expect) + if t.pexpect_spawn: + time.sleep(0.4) + t.send('q') t.read() t.ok() t.skip_ok = True return t - def helpscreens(self,arg='--help',scripts=(),expect='USAGE:.*OPTIONS:'): + def helpscreens(self,arg='--help',scripts=(),expect='USAGE:.*OPTIONS:',pager=True): scripts = list(scripts) or [s.replace('mmgen-','') for s in os.listdir('cmds')] @@ -104,6 +107,9 @@ class TestSuiteHelp(TestSuiteBase): for s in sorted(scripts): t = self.spawn(f'mmgen-{s}',[arg],extra_desc=f'(mmgen-{s})') t.expect(expect,regex=True) + if pager and t.pexpect_spawn: + time.sleep(0.2) + t.send('q') t.read() t.ok() t.skip_ok = True @@ -120,7 +126,8 @@ class TestSuiteHelp(TestSuiteBase): 'walletgen','walletconv','walletchk','passchg','subwalletgen', 'addrgen','keygen','passgen', 'txsign','txdo','txbump'), - expect = 'Available parameters.*Preset' ) + expect = 'Available parameters.*Preset', + pager = False ) def tool_help(self): diff --git a/test/test_py_d/ts_opts.py b/test/test_py_d/ts_opts.py index 6d537beb..f6b62450 100755 --- a/test/test_py_d/ts_opts.py +++ b/test/test_py_d/ts_opts.py @@ -44,12 +44,14 @@ class TestSuiteOpts(TestSuiteBase): return t def opt_helpscreen(self): - return self.do_run( - ['--help'], - r'OPTS.PY: Opts test.*USAGE:\s+opts.py.*--minconf.*' - + r'NOTES FOR THIS.*a note', - 0, - regex=True ) + expect = r'OPTS.PY: Opts test.*USAGE:\s+opts.py' + if not opt.pexpect_spawn: + expect += r'.*--minconf.*NOTES FOR THIS.*a note' + t = self.do_run( ['--help'], expect, 0, regex=True ) + if t.pexpect_spawn: + time.sleep(0.4) + t.send('q') + return t def opt_noargs(self): return self.check_vals( diff --git a/test/test_py_d/ts_regtest.py b/test/test_py_d/ts_regtest.py index fa9679ab..f0dc1ed3 100755 --- a/test/test_py_d/ts_regtest.py +++ b/test/test_py_d/ts_regtest.py @@ -708,8 +708,16 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): ['--bob',f'--outdir={self.tmpdir}','txhist','age_fmt=date_time','interactive=true'] ) for resp in ('u','i','t','a','m','T','A','r','r','D','D','D','D','p','P','b','V'): t.expect('draw:\b',resp,regex=True) - txnum,idx = (8,1) if self.proto.coin == 'BCH' else (9,3) - t.expect(f'\s{txnum}\).*Inputs:.*:L:{idx}.*Outputs \(3\):.*:C:2.*\s10\)','q',regex=True) + if t.pexpect_spawn: + t.expect(r'Block:.*\b394\b',regex=True) + time.sleep(1) + t.send('q') + time.sleep(0.2) + t.send('b') + t.expect('draw:\b','q',regex=True) + else: + txnum,idx = (8,1) if self.proto.coin == 'BCH' else (9,3) + t.expect(f'\s{txnum}\).*Inputs:.*:L:{idx}.*Outputs \(3\):.*:C:2.*\s10\)','q',regex=True) return t def bob_getbalance(self,bals,confs=1): @@ -1243,7 +1251,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): args = ['age_fmt=date_time'], expect = (rtAmts[0],pat_date_time) ) - def alice_txcreate_info(self,pexpect_spawn=None): + def alice_txcreate_info(self,pexpect_spawn=False): t = self.spawn('mmgen-txcreate',['--alice','-Bi'],pexpect_spawn=pexpect_spawn) pats = ( ( '\d+', 'w'),