From 4453aaf355c2aca7964928e6b98641f8d78dd435 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 7 Oct 2021 13:12:10 +0000 Subject: [PATCH] minor fixes and cleanups --- mmgen/tw.py | 3 ++- mmgen/util.py | 2 +- test/test.py | 2 +- test/test_py_d/ts_cfg.py | 5 +++-- test/test_py_d/ts_ethdev.py | 2 +- test/test_py_d/ts_input.py | 2 +- test/test_py_d/ts_ref_3seed.py | 8 ++++---- test/test_py_d/ts_regtest.py | 16 ++++++++-------- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/mmgen/tw.py b/mmgen/tw.py index a413e5ea..0f2e9338 100755 --- a/mmgen/tw.py +++ b/mmgen/tw.py @@ -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)}') diff --git a/mmgen/util.py b/mmgen/util.py index a6cb2868..3df45539 100755 --- a/mmgen/util.py +++ b/mmgen/util.py @@ -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) diff --git a/test/test.py b/test/test.py index d0b83e95..32f1f8e5 100755 --- a/test/test.py +++ b/test/test.py @@ -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)) diff --git a/test/test_py_d/ts_cfg.py b/test/test_py_d/ts_cfg.py index 52d6c049..2f5917d7 100755 --- a/test/test_py_d/ts_cfg.py +++ b/test/test_py_d/ts_cfg.py @@ -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() diff --git a/test/test_py_d/ts_ethdev.py b/test/test_py_d/ts_ethdev.py index 40966394..3ff9d95f 100755 --- a/test/test_py_d/ts_ethdev.py +++ b/test/test_py_d/ts_ethdev.py @@ -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) diff --git a/test/test_py_d/ts_input.py b/test/test_py_d/ts_input.py index fdbbcde1..7ad17185 100755 --- a/test/test_py_d/ts_input.py +++ b/test/test_py_d/ts_input.py @@ -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 diff --git a/test/test_py_d/ts_ref_3seed.py b/test/test_py_d/ts_ref_3seed.py index a197c159..9dac42a3 100755 --- a/test/test_py_d/ts_ref_3seed.py +++ b/test/test_py_d/ts_ref_3seed.py @@ -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 diff --git a/test/test_py_d/ts_regtest.py b/test/test_py_d/ts_regtest.py index 5f1d2936..e783b226 100755 --- a/test/test_py_d/ts_regtest.py +++ b/test/test_py_d/ts_regtest.py @@ -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):