test.py: remove superfluous calls to pexpect.read()

This commit is contained in:
The MMGen Project 2022-02-05 13:32:55 +00:00
commit c205d2f7a6
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
11 changed files with 10 additions and 50 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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,