From c205d2f7a67f3f90aeab8b63bb702874c2ac25bb Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 5 Feb 2022 13:32:55 +0000 Subject: [PATCH] test.py: remove superfluous calls to pexpect.read() --- test/test_py_d/ts_cfg.py | 1 - test/test_py_d/ts_ethdev.py | 21 ++++----------------- test/test_py_d/ts_input.py | 7 +------ test/test_py_d/ts_main.py | 4 ++-- test/test_py_d/ts_misc.py | 8 ++------ test/test_py_d/ts_opts.py | 2 -- test/test_py_d/ts_ref.py | 2 -- test/test_py_d/ts_ref_altcoin.py | 1 - test/test_py_d/ts_regtest.py | 11 +---------- test/test_py_d/ts_tool.py | 1 - test/test_py_d/ts_xmrwallet.py | 2 -- 11 files changed, 10 insertions(+), 50 deletions(-) diff --git a/test/test_py_d/ts_cfg.py b/test/test_py_d/ts_cfg.py index 6648de3d..d1f51208 100755 --- a/test/test_py_d/ts_cfg.py +++ b/test/test_py_d/ts_cfg.py @@ -198,7 +198,6 @@ class TestSuiteCfg(TestSuiteBase): t = self.spawn_test(args=['mnemonic_entry_modes']) modes = t.expect_getend('mnemonic_entry_modes: ') assert modes_chk == modes, f'{modes_chk} != {modes}' - t.read() return t txt = 'mnemonic_entry_modes mmgen:full bip39:short' diff --git a/test/test_py_d/ts_ethdev.py b/test/test_py_d/ts_ethdev.py index bb7fe6f0..ee6a59ec 100755 --- a/test/test_py_d/ts_ethdev.py +++ b/test/test_py_d/ts_ethdev.py @@ -478,7 +478,6 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): def addrgen(self,addrs='1-3,11-13,21-23'): t = self.spawn('mmgen-addrgen', self.eth_args + [dfl_words_file,addrs]) t.written_to_file('Addresses') - t.read() return t def addrimport(self,ext='21-23]{}.regtest.addrs',expect='9/9',add_args=[],bad_input=False): @@ -566,9 +565,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): def txview(self,ext_fs): ext = ext_fs.format('-α' if g.debug_utf8 else '') txfile = self.get_file_with_ext(ext,no_dot=True) - t = self.spawn( 'mmgen-tool',['--verbose','txview',txfile] ) - t.read() - return t + return self.spawn( 'mmgen-tool',['--verbose','txview',txfile] ) def fund_dev_address(self): """ @@ -657,7 +654,6 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): txfile = self.get_file_with_ext(ext,no_dot=True) t = self.spawn('mmgen-txbump', self.eth_args + add_args + ['--yes',txfile]) t.expect('or gas price: ',fee+'\n') - t.read() return t def txsign4(self): return self.txsign(ni=True,ext='.45495,50000]{}.regtest.rawtx') @@ -710,7 +706,6 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): t.expect(r'\n[0-9A-F]{8}: .*\D'+str(bal1),regex=True) t.expect(r'\nNon-MMGen: .*\D'+bal2,regex=True) total = strip_ansi_escapes(t.expect_getend(r'\nTOTAL:\s+',regex=True)).split()[0] - t.read() assert Decimal(bal1) + Decimal(bal2) == Decimal(total) return t @@ -931,15 +926,12 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): def token_bal1(self): return self.token_bal(n='1') def token_txcreate(self,args=[],token='',inputs='1',fee='50G'): - t = self.spawn('mmgen-txcreate', self.eth_args + ['--token='+token,'-B','--tx-fee='+fee] + args) - t = self.txcreate_ui_common( - t, + return self.txcreate_ui_common( + self.spawn('mmgen-txcreate', self.eth_args + ['--token='+token,'-B','--tx-fee='+fee] + args), menu = [], inputs = inputs, input_sels_prompt = 'to spend from', add_comment = tx_label_lat_cyr_gr ) - t.read() - return t def token_txsign(self,ext='',token=''): return self.txsign(ni=True,ext=ext,add_args=['--token='+token]) def token_txsend(self,ext='',token=''): @@ -985,9 +977,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): return self.token_bal(n='3') def del_dev_addr(self): - t = self.spawn('mmgen-tool', self.eth_args + ['remove_address',dfl_devaddr]) - t.read() # TODO - return t + return self.spawn('mmgen-tool', self.eth_args + ['remove_address',dfl_devaddr]) def bal1_getbalance(self): return self.bal_getbalance('1',etc_adj=True) @@ -1057,7 +1047,6 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): args = ['--tx-fee=20G','--cached-balances'] + add_args + [dfl_words_file] t = self.txcreate(args=args,acct=acct,caller='txdo',fee_res_data=fee_res_data,no_read=True) self._do_confirm_send(t,quiet=not g.debug,sure=False) - t.read() return t def txcreate_refresh_balances(self, @@ -1079,7 +1068,6 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): t.expect('Is this what you want? (y/N): ','y') t.expect('[R]efresh balance:\b','q') t.expect(rf'Total unspent:.*\D{total}\D.*{total_coin}',regex=True) - t.read() return t def bal10(self): return self.bal(n='10') @@ -1130,7 +1118,6 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): for p,r in zip((p1,p1),('M','q')): t.expect(p,r) t.expect('Total unspent:') - t.read() return t def edit_label1(self): diff --git a/test/test_py_d/ts_input.py b/test/test_py_d/ts_input.py index 5eb7ebdd..78a4d29e 100755 --- a/test/test_py_d/ts_input.py +++ b/test/test_py_d/ts_input.py @@ -121,8 +121,6 @@ class TestSuiteInput(TestSuiteBase): t.expect('passphrase for MMGen wallet: ','reference password\n') t.expect('[reference password][1][No Label]') - t.read() - return t def get_passphrase_cmdline(self): @@ -137,7 +135,7 @@ class TestSuiteInput(TestSuiteBase): cmd_dir = '.' ) for foo in range(4): t.expect('[reference password][1][MyLabel]') - t.read() + return t def get_passphrase_crypto(self): @@ -166,7 +164,6 @@ class TestSuiteInput(TestSuiteBase): t.expect('accept the default .*: ', '\n', regex=True) t.expect(f'[{g.dfl_hash_preset}]') - t.read() return t def password_entry(self,prompt,cmd_args): @@ -207,7 +204,6 @@ class TestSuiteInput(TestSuiteBase): assert mode == mne.em.name.lower(), f'{mode} != {mne.em.name.lower()}' stealth_mnemonic_entry(t,mne,mn,entry_mode=entry_mode,pad_entry=pad_entry) t.expect(sample_mn[fmt]['hex']) - t.read() return t def _user_seed_entry(self,fmt,usr_rand=False,out_fmt=None,entry_mode='full',mn=None): @@ -246,7 +242,6 @@ class TestSuiteInput(TestSuiteBase): sid = strip_ansi_escapes(sid.split(',')[0]) assert sid == sid_chk, f'Seed ID mismatch! {sid} != {sid_chk}' t.expect('to confirm: ','YES\n') - t.read() return t def mnemonic_entry_mmgen_minimal(self): diff --git a/test/test_py_d/ts_main.py b/test/test_py_d/ts_main.py index 59ad6a80..a30bcb13 100755 --- a/test/test_py_d/ts_main.py +++ b/test/test_py_d/ts_main.py @@ -644,7 +644,8 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): t.expect_getend(f'Valid {wcls.desc} for Seed ID ') vmsg('Comparing generated checksum with checksum from previous address file') chk = t.expect_getend(r'Checksum for address data .*?: ',regex=True) - if stdout: t.read() + if stdout: + t.read() verify_checksum_or_exit(self._get_addrfile_checksum(),chk) if in_fmt != 'seed': t.no_overwrite() @@ -837,7 +838,6 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): t.do_comment(False) t.expect('Save signed transaction? (Y/n): ','y') exit_val = 0 - t.read() t.req_exit_val = exit_val return t diff --git a/test/test_py_d/ts_misc.py b/test/test_py_d/ts_misc.py index 603f8ee9..23811a83 100755 --- a/test/test_py_d/ts_misc.py +++ b/test/test_py_d/ts_misc.py @@ -136,9 +136,7 @@ class TestSuiteOutput(TestSuiteBase): color = True def screen_output(self,lang): - t = self.spawn('test/misc/utf8_output.py',[lang],cmd_dir='.') - t.read() - return t + return self.spawn('test/misc/utf8_output.py',[lang],cmd_dir='.') def output_gr(self): return self.screen_output('gr') def output_ru(self): return self.screen_output('ru') @@ -195,9 +193,7 @@ class TestSuiteRefTX(TestSuiteMain,TestSuiteBase): def ref_tx_addrgen(self,atype): if atype not in self.proto.mmtypes: return - t = self.spawn('mmgen-addrgen',['--outdir='+self.tmpdir,'--type='+atype,dfl_words_file,'1-2']) - t.read() - return t + return self.spawn('mmgen-addrgen',['--outdir='+self.tmpdir,'--type='+atype,dfl_words_file,'1-2']) def ref_tx_addrgen1(self): return self.ref_tx_addrgen(atype='L') def ref_tx_addrgen2(self): return self.ref_tx_addrgen(atype='C') diff --git a/test/test_py_d/ts_opts.py b/test/test_py_d/ts_opts.py index 51caa6ff..6d537beb 100755 --- a/test/test_py_d/ts_opts.py +++ b/test/test_py_d/ts_opts.py @@ -35,13 +35,11 @@ class TestSuiteOpts(TestSuiteBase): t = self.spawn_prog(args) for k,v in vals: t.expect(rf'{k}:\s+{v}',regex=True) - t.read() return t def do_run(self,args,expect,exit_val,regex=False): t = self.spawn_prog(args) t.expect(expect,regex=regex) - t.read() t.req_exit_val = exit_val return t diff --git a/test/test_py_d/ts_ref.py b/test/test_py_d/ts_ref.py index f6beaa1a..409bc779 100755 --- a/test/test_py_d/ts_ref.py +++ b/test/test_py_d/ts_ref.py @@ -177,7 +177,6 @@ class TestSuiteRef(TestSuiteBase,TestSuiteShared): 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}' - t.read() return t def ref_subwallet_addrgen(self,ss_idx,target='addr'): @@ -232,7 +231,6 @@ class TestSuiteRef(TestSuiteBase,TestSuiteShared): t.expect(pat,regex=True) t.expect(chksum_pat,regex=True) m = t.p.match.group(0) - t.read() cmp_or_die(ref_chksum,m) return t diff --git a/test/test_py_d/ts_ref_altcoin.py b/test/test_py_d/ts_ref_altcoin.py index 8adb86fc..7f7bf665 100755 --- a/test/test_py_d/ts_ref_altcoin.py +++ b/test/test_py_d/ts_ref_altcoin.py @@ -131,7 +131,6 @@ class TestSuiteRefAltcoin(TestSuiteRef,TestSuiteBase): coin.lower(), coin_suf ) ] - t.read() cmp_or_die(chk,chk_ref,desc=f'{gen_what}list data checksum') return t diff --git a/test/test_py_d/ts_regtest.py b/test/test_py_d/ts_regtest.py index 38c997b7..4d4520f2 100755 --- a/test/test_py_d/ts_regtest.py +++ b/test/test_py_d/ts_regtest.py @@ -318,7 +318,6 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): def halving_calculator_bob(self): t = self.spawn('halving-calculator.py',['--bob'],cmd_dir='examples') t.expect('time until halving') - t.read() return t def walletgen(self,user): @@ -464,16 +463,13 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): t = self.spawn('mmgen-tool',['--'+user,'twview','sort='+sort]) if chk: t.expect(r'{}\b.*\D{}\b'.format(*chk),regex=True) - t.read() return t def bob_twview1(self): return self.user_twview('bob', chk = ('1',rtAmts[0]) ) def user_bal(self,user,bal,args=['showempty=1'],skip_check=False): t = self.spawn('mmgen-tool',['--'+user,'listaddresses'] + args) - if skip_check: - t.read() - else: + if not skip_check: cmp_or_die(f'{bal} {self.proto.coin}',strip_ansi_escapes(t.expect_getend('TOTAL: '))) return t @@ -590,7 +586,6 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): re.sub(rf'\s+{self.proto.coin}\s*',' ',ret).strip(), desc=k, ) - t.read() return t def bob_0conf0_getbalance(self): return self.bob_getbalance(rtBals_gb['0conf0'],confs=0) @@ -721,7 +716,6 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): else: t.expect('Save fee-bumped transaction? (y/N): ','y') t.written_to_file('Fee-bumped transaction') - t.read() return t def bob_rbf_bump(self): @@ -832,7 +826,6 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): t.expect("Type uppercase 'YES' to confirm: ",'YES\n') t.expect('Importing') t.expect('OK') - t.read() return t def bob_import_addr(self): @@ -959,7 +952,6 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): t = self.spawn('mmgen-tool',['--alice','listaddresses','showempty=1'] + args) expect_str = r'\D{}\D.*\b{}'.format(*expect) t.expect(expect_str,regex=True) - t.read() return t def alice_listaddresses1(self): @@ -986,7 +978,6 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): t = self.spawn('mmgen-tool',['--alice','twview'] + args) expect_str = r'\D{}\D.*\b{}'.format(*expect) t.expect(expect_str,regex=True) - t.read() return t def alice_twview1(self): diff --git a/test/test_py_d/ts_tool.py b/test/test_py_d/ts_tool.py index 6bae336a..10ca4a2a 100755 --- a/test/test_py_d/ts_tool.py +++ b/test/test_py_d/ts_tool.py @@ -88,5 +88,4 @@ class TestSuiteTool(TestSuiteMain,TestSuiteBase): def tool_api(self): t = self.spawn('tool_api_test.py',cmd_dir='test/misc') t.expect('legacy.*compressed.*segwit.*bech32',regex=True) - t.read() return t diff --git a/test/test_py_d/ts_xmrwallet.py b/test/test_py_d/ts_xmrwallet.py index 1545b409..2b319ff4 100755 --- a/test/test_py_d/ts_xmrwallet.py +++ b/test/test_py_d/ts_xmrwallet.py @@ -302,7 +302,6 @@ class TestSuiteXMRWallet(TestSuiteBase): t.expect('Check key-to-address validity? (y/N): ','n') for i in MMGenRange(wallet or data.kal_range).items: t.expect('Address: ') - t.read() return t async def mine_initial_coins(self): @@ -348,7 +347,6 @@ class TestSuiteXMRWallet(TestSuiteBase): t.expect('Chain height: ') t.expect('Wallet height: ') t.expect('Balance: ') - t.read() return t def do_op(self, op, user, arg2,