minor fixes and cleanups

This commit is contained in:
The MMGen Project 2021-10-07 13:12:10 +00:00
commit 4453aaf355
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
8 changed files with 21 additions and 19 deletions

View file

@ -406,7 +406,8 @@ Actions: [q]uit view, [p]rint to file, pager [v]iew, [w]ide view, add [l]abel:
msg('')
while True:
ret = line_input(f'Enter {self.item_desc} number (or RETURN to return to main menu): ')
if ret == '': return (None,None) if action == 'a_lbl_add' else None
if ret == '':
return (None,None) if action == 'a_lbl_add' else None
n = get_obj(AddrIdx,n=ret,silent=True)
if not n or n < 1 or n > len(self.unspent):
msg(f'Choice must be a single number between 1 and {len(self.unspent)}')

View file

@ -797,7 +797,7 @@ def line_input(prompt,echo=True,insert_txt=''):
if g.test_suite_popen_spawn:
msg(prompt)
sys.stderr.flush()
reply = os.read(0,4096).decode()
reply = os.read(0,4096).decode().rstrip('\n') # strip NL to mimic behavior of input()
elif echo or not sys.stdin.isatty():
clear_buffer = init_readline() if sys.stdin.isatty() else False
reply = input(prompt)

View file

@ -608,7 +608,7 @@ class CmdGroupMgr(object):
and g[0] in tuple(self.cmd_groups_dfl) + tuple(usr_args) ]
for name,cls in ginfo:
msg(f'{name:17} - {cls.__doc__}')
msg(f'{name:17} - {cls.__doc__.strip()}')
Die(0,'\n'+' '.join(e[0] for e in ginfo))

View file

@ -118,9 +118,12 @@ class TestSuiteCfg(TestSuiteBase):
t.expect(s)
cp = CfgFileSampleUsr.details_confirm_prompt + ' (y/N): '
t.expect(cp,'y')
for s in ('CHANGES','Removed','# zcash_','# foo','# bar','Added','# monero_'):
t.expect(s)
t.expect(cp,'n')
if old_set:
@ -131,8 +134,6 @@ class TestSuiteCfg(TestSuiteBase):
t.expect('parsed chunks: 29')
t.expect('usr cfg: testnet=true rpc_password=passwOrd')
t.read()
if not old_set:
self.check_replaced_sample()

View file

@ -1076,7 +1076,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
t = self.spawn('mmgen-txcreate', self.eth_args + args)
for n in bals:
t.expect('[R]efresh balance:\b','R')
t.expect(' main menu): ',n)
t.expect(' main menu): ',n+'\n')
t.expect('Is this what you want? (y/N): ','y')
t.expect('[R]efresh balance:\b','q')
t.expect(f'Total unspent:.*\D{total}\D.*{total_coin}',regex=True)

View file

@ -158,7 +158,7 @@ class TestSuiteInput(TestSuiteBase):
def password_entry(self,prompt,cmd_args):
t = self.spawn('test/misc/password_entry.py',cmd_args,cmd_dir='.')
pw = 'abc-α'
t.expect(prompt,pw)
t.expect(prompt,pw+'\n')
ret = t.expect_getend('Entered: ')
assert ret == pw, f'Password mismatch! {ret} != {pw}'
return t

View file

@ -108,8 +108,9 @@ class TestSuiteRef3Seed(TestSuiteBase,TestSuiteShared):
def ref_hincog_chk(self,desc='hidden incognito data'):
source = TestSuiteWalletConv.sources[str(self.seed_len)]
for wtype,edesc,of_arg in ('hic_wallet','',[]), \
('hic_wallet_old','(old format)',['-O']):
for wtype,edesc,of_arg in (
('hic_wallet', '', []),
('hic_wallet_old','(old format)',['-O']) ):
ic_arg = ['-H{},{}'.format(
joinpath(ref_dir,source[wtype]),
ref_wallet_incog_offset )
@ -120,11 +121,10 @@ class TestSuiteRef3Seed(TestSuiteBase,TestSuiteShared):
t = self.spawn('mmgen-walletchk',
slarg + hparg + of_arg + ic_arg,
extra_desc=edesc)
t.passphrase(desc,self.wpasswd)
t.passphrase(desc,self.wpasswd+'\n')
if wtype == 'hic_wallet_old':
t.expect('Is the Seed ID correct? (Y/n): ','\n')
chk = t.expect_getend('Seed ID: ')
t.close()
cmp_or_die(self.seed_id,chk)
ok_msg()
t.skip_ok = True

View file

@ -1019,18 +1019,18 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
def alice_txcreate_info(self,args=[]):
t = self.spawn('mmgen-txcreate',['--alice','-Bi'])
for d,s in (
( '\d+', 'D'),
( '\d+', 'D'),
( '\d+', 'D'),
( pat_date, 'w'),
( '\d+\s+\d+\s+'+pat_date_time,'q'),
):
pats = (
( '\d+', 'D'),
( '\d+', 'D'),
( '\d+', 'D'),
( pat_date, 'w'),
( '\d+\s+\d+\s+'+pat_date_time,'q'),
)
for d,s in pats:
t.expect(
r'\D{}\D.*\b{}\b'.format( rtAmts[0], d ),
s,
regex=True )
t.read()
return t
def stop(self):