From 775e596ddad05e33ff63e3b6966f1895f3682077 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 11 Oct 2023 12:58:52 +0000 Subject: [PATCH] pylint (test suite) - unused variables --- test/gentest.py | 2 +- test/hashfunc.py | 6 +-- test/include/pexpect.py | 7 ++-- test/overlay/fakemods/mmgen/tw/unspent.py | 2 +- test/overlay/fakemods/mmgen/tx/new.py | 2 +- test/test.py | 6 +-- test/test_py_d/input.py | 2 +- test/test_py_d/ts_autosign.py | 2 +- test/test_py_d/ts_ethdev.py | 2 +- test/test_py_d/ts_input.py | 4 +- test/test_py_d/ts_main.py | 50 +++++++++++------------ test/test_py_d/ts_ref.py | 7 ++-- test/test_py_d/ts_ref_3seed.py | 9 ++-- test/test_py_d/ts_regtest.py | 10 ++--- test/test_py_d/ts_shared.py | 12 ++---- test/test_py_d/ts_tool.py | 1 - test/test_py_d/ts_wallet.py | 22 ++++------ test/test_py_d/ts_xmr_autosign.py | 1 - test/test_py_d/ts_xmrwallet.py | 4 +- test/tooltest.py | 8 ++-- test/tooltest2.py | 12 +++--- test/unit_tests_d/ut_daemon.py | 2 +- test/unit_tests_d/ut_dep.py | 6 +-- test/unit_tests_d/ut_mn_entry.py | 1 - test/unit_tests_d/ut_testdep.py | 8 ++-- test/unit_tests_d/ut_tx.py | 2 +- 26 files changed, 86 insertions(+), 104 deletions(-) diff --git a/test/gentest.py b/test/gentest.py index 706721e7..c6c56b2a 100755 --- a/test/gentest.py +++ b/test/gentest.py @@ -321,7 +321,7 @@ def do_ab_test(proto,scfg,addr_type,gen1,kg2,ag,tool,cache_data): for privbytes in tuple(tool.data)[len(edgecase_sks):]: yield privbytes else: - for i in range(scfg.rounds): + for _ in range(scfg.rounds): yield getrand(32) kg1 = KeyGenerator( cfg, proto, addr_type.pubkey_type, gen1 ) diff --git a/test/hashfunc.py b/test/hashfunc.py index 048c2d41..e0d32f03 100755 --- a/test/hashfunc.py +++ b/test/hashfunc.py @@ -48,7 +48,7 @@ class TestHashFunc: die(3,m.format([hex(n) for n in self.K_ref],[hex(n) for n in h.K])) msg('OK\n') - def compare_hashes(self,dlen,data,chk=None): + def compare_hashes(self,data,chk=None): if chk is None: chk = getattr(self.hashlib,self.desc)(data).hexdigest() res = self.t_cls(data).hexdigest() @@ -59,7 +59,7 @@ class TestHashFunc: def test_ref(self): for i,data in enumerate(self.vectors): msg(f'\rTesting reference input data: {i+1:4}/{len(self.vectors)} ') - self.compare_hashes( len(data), data.encode(), chk=self.vectors[data] ) + self.compare_hashes(data.encode(), chk=self.vectors[data]) msg('OK\n') def test_random(self,rounds): @@ -69,7 +69,7 @@ class TestHashFunc: if i+1 in (1,rounds) or not (i+1) % 10: msg(f'\rTesting random input data: {i+1:4}/{rounds} ') dlen = int(getrand(4).hex(),16) >> 18 - self.compare_hashes(dlen,getrand(dlen)) + self.compare_hashes(getrand(dlen)) msg('OK\n') class TestKeccak(TestHashFunc): diff --git a/test/include/pexpect.py b/test/include/pexpect.py index 744a6de9..a7c89595 100755 --- a/test/include/pexpect.py +++ b/test/include/pexpect.py @@ -72,7 +72,6 @@ class MMGenPexpect: def do_decrypt_ka_data( self, - hp, pw, desc = 'key-address data', check = True, @@ -124,7 +123,7 @@ class MMGenPexpect: while rand_chars: ch = rand_chars.pop(0) msg_r(yellow(ch)+' ' if cfg.verbose else '+') - ret = self.expect('left: ',ch,delay=0.005) + self.expect('left: ',ch,delay=0.005) self.expect('ENTER to continue: ','\n') def passphrase_new(self,desc,passphrase): @@ -140,7 +139,7 @@ class MMGenPexpect: self.expect(f'Enter hash preset for {desc}') self.expect('or hit ENTER .*?:',str(preset)+'\n',regex=True) - def written_to_file(self,desc,overwrite_unlikely=False,query='Overwrite? ',oo=False): + def written_to_file(self,desc,overwrite_unlikely=False,query='Overwrite? '): s1 = f'{desc} written to file ' s2 = query + "Type uppercase 'YES' to confirm: " ret = self.expect(([s1,s2],s1)[overwrite_unlikely]) @@ -168,7 +167,7 @@ class MMGenPexpect: self.expect('Exiting at user request') def expect_getend(self,s,regex=False): - ret = self.expect(s,regex=regex,nonl=True) + self.expect(s,regex=regex,nonl=True) if cfg.debug_pexpect: debug_pexpect_msg(self.p) # readline() of partial lines doesn't work with PopenSpawn, so do this instead: diff --git a/test/overlay/fakemods/mmgen/tw/unspent.py b/test/overlay/fakemods/mmgen/tw/unspent.py index efcb3f7e..ca508f03 100644 --- a/test/overlay/fakemods/mmgen/tw/unspent.py +++ b/test/overlay/fakemods/mmgen/tw/unspent.py @@ -5,7 +5,7 @@ if overlay_fake_os.getenv('MMGEN_BOGUS_UNSPENT_DATA'): class overlay_fake_data: - async def set_dates(foo,us): + async def set_dates(_,us): for o in us: o.date = 1831006505 - int(9.7 * 60 * (o.confs - 1)) diff --git a/test/overlay/fakemods/mmgen/tx/new.py b/test/overlay/fakemods/mmgen/tx/new.py index 0d3a877c..98867fe0 100644 --- a/test/overlay/fakemods/mmgen/tx/new.py +++ b/test/overlay/fakemods/mmgen/tx/new.py @@ -5,7 +5,7 @@ if overlay_fake_os.getenv('MMGEN_BOGUS_UNSPENT_DATA'): class overlay_fake_data: - async def warn_chg_addr_used(foo,us): + async def warn_chg_addr_used(_,us): from ..util import ymsg ymsg('Bogus unspent data: skipping change address is used check') diff --git a/test/test.py b/test/test.py index f55d6ed1..9e9386b1 100755 --- a/test/test.py +++ b/test/test.py @@ -846,7 +846,7 @@ class TestSuiteRunner: fns = [] if force_delete or not root: # does cmd produce a needed dependency(ies)? - ret = self.get_num_exts_for_cmd(cmd,dpy) + ret = self.get_num_exts_for_cmd(cmd) if ret: for ext in ret[1]: fn = get_file_with_ext(cfgs[ret[0]]['tmpdir'],ext,delete=build) @@ -972,7 +972,7 @@ class TestSuiteRunner: if not cfg.quiet: omsg(f'Checking dependencies for {cmd!r}') - self.check_needs_rerun(self.ts,cmd,build=False) + self.check_needs_rerun(self.ts,cmd) w = max(map(len,self.rebuild_list)) + 1 for cmd in self.rebuild_list: @@ -986,7 +986,7 @@ class TestSuiteRunner: def generate_cmd_deps(self,fdeps): return [cfgs[str(n)]['dep_generators'][ext] for n,ext in fdeps] - def get_num_exts_for_cmd(self,cmd,dpy=False): # dpy ignored here + def get_num_exts_for_cmd(self,cmd): try: num = str(self.gm.dpy_data[cmd][0]) except KeyError: diff --git a/test/test_py_d/input.py b/test/test_py_d/input.py index c475d9d9..3095b853 100755 --- a/test/test_py_d/input.py +++ b/test/test_py_d/input.py @@ -19,7 +19,7 @@ def stealth_mnemonic_entry(t,mne,mn,entry_mode,pad_entry=False): def pad_mnemonic(mn,ss_len): def get_pad_chars(n): ret = '' - for i in range(n): + for _ in range(n): m = int.from_bytes(getrand(1),'big') % 32 ret += r'123579!@#$%^&*()_+-=[]{}"?/,.<>|'[m] return ret diff --git a/test/test_py_d/ts_autosign.py b/test/test_py_d/ts_autosign.py index 043a8333..8928d396 100755 --- a/test/test_py_d/ts_autosign.py +++ b/test/test_py_d/ts_autosign.py @@ -226,7 +226,7 @@ class TestSuiteAutosignBase(TestSuiteBase): t.expect('Type a number.*: ',str(mne.entry_modes.index(entry_mode)+1),regex=True) stealth_mnemonic_entry(t,mne,mn,entry_mode) - wf = t.written_to_file('Autosign wallet') + t.written_to_file('Autosign wallet') return t def copy_tx_files(self): diff --git a/test/test_py_d/ts_ethdev.py b/test/test_py_d/ts_ethdev.py index d79e8bcd..8a8443e5 100755 --- a/test/test_py_d/ts_ethdev.py +++ b/test/test_py_d/ts_ethdev.py @@ -643,7 +643,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): + [txfile, dfl_words_file]) return self.txsign_ui_common(t,ni=ni,has_label=True) - def txsend(self,ni=False,ext='{}.regtest.sigtx',add_args=[]): + def txsend(self,ext='{}.regtest.sigtx',add_args=[]): ext = ext.format('-α' if cfg.debug_utf8 else '') txfile = self.get_file_with_ext(ext,no_dot=True) t = self.spawn('mmgen-txsend', self.eth_args + add_args + [txfile]) diff --git a/test/test_py_d/ts_input.py b/test/test_py_d/ts_input.py index b79f96a5..4f5dbb46 100755 --- a/test/test_py_d/ts_input.py +++ b/test/test_py_d/ts_input.py @@ -113,7 +113,7 @@ class TestSuiteInput(TestSuiteBase): run_env['MMGEN_TEST_SUITE'] = '' # the test can fail the first time if cfg file has changed, so run it twice if necessary: - for i in range(2): + for _ in range(2): cp = run( cmd, input=mn.encode(), stdout=PIPE, stderr=PIPE, env=run_env ) if b'written to file' in cp.stderr: break @@ -204,7 +204,7 @@ class TestSuiteInput(TestSuiteBase): '--hash-preset=1', 'seed' ], cmd_dir = '.' ) - for foo in range(4): + for _ in range(4): t.expect('[reference password][1][MyLabel]') return t diff --git a/test/test_py_d/ts_main.py b/test/test_py_d/ts_main.py index 8ffbd489..fb14445f 100755 --- a/test/test_py_d/ts_main.py +++ b/test/test_py_d/ts_main.py @@ -124,10 +124,10 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): ) ), ('walletchk_newpass',(5,'wallet check with new pw, label and hash preset', [[['mmdat',pwfile],5]])), - ('addrgen', (1,'address generation', [[['mmdat',pwfile],1]])), + ('addrgen', (1,'address generation', [[['mmdat'],1]])), ('txcreate', (1,'transaction creation', [[['addrs'],1]])), ('txbump', (1,'transaction fee bumping (no send)', [[['rawtx'],1]])), - ('txsign', (1,'transaction signing', [[['mmdat','rawtx',pwfile,'txbump'],1]])), + ('txsign', (1,'transaction signing', [[['mmdat','rawtx'],1]])), ('txsend', (1,'transaction sending', [[['sigtx'],1]])), # txdo must go after txsign ('txdo', (1,'online transaction', [[['sigtx','mmdat'],1]])), @@ -147,7 +147,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): ('addrgen_incog_hex',(1,'address generation from mmincog hex file', [[['mmincox','addrs'],1]])), ('addrgen_incog_hidden',(1,'address generation from hidden mmincog file', [[[hincog_fn,'addrs'],1]])), - ('keyaddrgen', (1,'key-address file generation', [[['mmdat',pwfile],1]])), + ('keyaddrgen', (1,'key-address file generation', [[['mmdat'],1]])), ('txsign_keyaddr',(1,'transaction signing with key-address file', [[['akeys.mmenc','rawtx'],1]])), ('txcreate_ni', (1,'transaction creation (non-interactive)', [[['addrs'],1]])), @@ -338,13 +338,13 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): return self.export_seed(wf=None,out_fmt=out_fmt,pf=pf) def addrgen_dfl_wallet(self,pf=None,check_ref=False): - return self.addrgen(wf=None,pf=pf,check_ref=check_ref,dfl_wallet=True) + return self.addrgen(wf=None,check_ref=check_ref,dfl_wallet=True) def txcreate_dfl_wallet(self,addrfile): return self.txcreate_common(sources=['15']) def txsign_dfl_wallet(self,txfile,pf='',save=True,has_label=False): - return self.txsign(None,txfile,pf=pf,save=save,has_label=has_label,dfl_wallet=True) + return self.txsign(None,txfile,save=save,has_label=has_label,dfl_wallet=True) def passchg_dfl_wallet(self,pf): return self.passchg(wf=None,pf=pf,dfl_wallet=True) @@ -452,7 +452,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): return self.passchg(wf,pf,label_action='user') def walletchk_newpass(self,wf,pf,wcls=None,dfl_wallet=False): - return self.walletchk(wf,pf,wcls=wcls,dfl_wallet=dfl_wallet) + return self.walletchk(wf,wcls=wcls,dfl_wallet=dfl_wallet) def _write_fake_data_to_file(self,d): write_data_to_file(cfg,self.unspent_data_file,d,'Unspent outputs',quiet=True,ignore_opt_outdir=True) @@ -657,7 +657,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): tweaks = tweaks ) if txdo_args and add_args: # txdo4 - t.do_decrypt_ka_data(hp='1',pw=self.cfgs['14']['kapasswd']) + t.do_decrypt_ka_data(pw=self.cfgs['14']['kapasswd']) return t @@ -671,7 +671,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): args = prepend_args + ['--quiet','--outdir='+self.tmpdir,txfile] + seed_args t = self.spawn('mmgen-txbump',args) if seed_args: - t.do_decrypt_ka_data(hp='1',pw=self.cfgs['14']['kapasswd']) + t.do_decrypt_ka_data(pw=self.cfgs['14']['kapasswd']) t.expect('deduct the fee from (Hit ENTER for the change output): ','1\n') # Fee must be > tx_fee + network relay fee (currently 0.00001) t.expect('OK? (Y/n): ','\n') @@ -733,7 +733,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): elif ocls.type == 'mmgen': t.label() - return t.written_to_file(capfirst(ocls.desc),oo=True),t + return t.written_to_file(capfirst(ocls.desc)), t def export_seed(self,wf,out_fmt='seed',pf=None): f,t = self._walletconv_export(wf,out_fmt=out_fmt,pf=pf) @@ -757,7 +757,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): def export_incog(self,wf,out_fmt='i',add_args=[]): uargs = ['-p1',self.usr_rand_arg] + add_args - f,t = self._walletconv_export(wf,out_fmt=out_fmt,uargs=uargs) + _,t = self._walletconv_export(wf,out_fmt=out_fmt,uargs=uargs) return t def export_incog_hex(self,wf): @@ -769,7 +769,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): add_args = ['-J',f'{rf},{hincog_offset}'] return self.export_incog(wf,out_fmt='hi',add_args=add_args) - def addrgen_seed(self,wf,foo,in_fmt='seed'): + def addrgen_seed(self,wf,_,in_fmt='seed'): wcls = get_wallet_cls(fmt_code=in_fmt) stdout = wcls.type == 'seed' # capture output to screen once t = self.spawn( @@ -788,13 +788,13 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): t.req_exit_val = 1 return t - def addrgen_hex(self,wf,foo,in_fmt='mmhex'): - return self.addrgen_seed(wf,foo,in_fmt=in_fmt) + def addrgen_hex(self,wf,_,in_fmt='mmhex'): + return self.addrgen_seed(wf,_,in_fmt=in_fmt) - def addrgen_mnemonic(self,wf,foo): - return self.addrgen_seed(wf,foo,in_fmt='words') + def addrgen_mnemonic(self,wf,_): + return self.addrgen_seed(wf,_,in_fmt='words') - def addrgen_incog(self,wf=[],foo='',in_fmt='i',args=[]): + def addrgen_incog(self,wf=[],_='',in_fmt='i',args=[]): t = self.spawn('mmgen-addrgen', args + self.segwit_arg + ['-i'+in_fmt,'-d',self.tmpdir]+ ([],[wf])[bool(wf)] + [self.addr_idx_list]) t.license() @@ -809,10 +809,10 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): t.req_exit_val = 1 return t - def addrgen_incog_hex(self,wf,foo): + def addrgen_incog_hex(self,wf,_): return self.addrgen_incog(wf,'',in_fmt='xi') - def addrgen_incog_hidden(self,wf,foo): + def addrgen_incog_hidden(self,wf,_): rf = joinpath(self.tmpdir,hincog_fn) return self.addrgen_incog([],'',in_fmt='hi', args=['-H',f'{rf},{hincog_offset}','-l',str(hincog_seedlen)]) @@ -821,7 +821,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): t = self.spawn('mmgen-txsign', ['-d',self.tmpdir,'-p1','-M',keyaddr_file,txfile]) t.license() t.view_tx('n') - t.do_decrypt_ka_data(hp='1',pw=self.kapasswd) + t.do_decrypt_ka_data(pw=self.kapasswd) self.txsign_end(t) return t @@ -832,7 +832,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): return self.walletgen(seed_len=128) def addrgen2(self,wf): - return self.addrgen(wf,pf='') + return self.addrgen(wf) def txcreate2(self,addrfile): return self.txcreate_common(sources=['2']) @@ -854,7 +854,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): return self.walletgen() def addrgen3(self,wf): - return self.addrgen(wf,pf='') + return self.addrgen(wf) def txcreate3(self,addrfile1,addrfile2): return self.txcreate_common(sources=['1','3']) @@ -888,7 +888,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): return t def addrgen4(self,wf): - return self.addrgen(wf,pf='') + return self.addrgen(wf) def txcreate4(self,f1,f2,f3,f4,f5,f6): return self.txcreate_common( @@ -911,7 +911,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): t = self.spawn('mmgen-txsign',add_args) t.license() t.view_tx('t') - t.do_decrypt_ka_data(hp='1',pw=self.cfgs['14']['kapasswd']) + t.do_decrypt_ka_data(pw=self.cfgs['14']['kapasswd']) for cnum,wcls in (('1',IncogWallet),('3',MMGenWallet)): t.passphrase(wcls.desc,self.cfgs[cnum]['wpasswd']) @@ -950,7 +950,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): return self.walletgen() def addrgen5(self,wf): - return self.addrgen(wf,pf='') + return self.addrgen(wf) def txcreate5(self,addrfile): return self.txcreate_common( @@ -981,7 +981,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared): return self.walletgen() def addrgen6(self,wf): - return self.addrgen(wf,pf='') + return self.addrgen(wf) def txcreate6(self,addrfile): return self.txcreate_common( diff --git a/test/test_py_d/ts_ref.py b/test/test_py_d/ts_ref.py index 69501f2f..1dedc7b5 100755 --- a/test/test_py_d/ts_ref.py +++ b/test/test_py_d/ts_ref.py @@ -244,7 +244,7 @@ class TestSuiteRef(TestSuiteBase,TestSuiteShared): tool_cmd = ftype.replace('segwit','').replace('bech32','')+'file_chksum' t = self.spawn( 'mmgen-tool', coin_arg + ['--verbose','-p1',tool_cmd,af] ) if ftype == 'keyaddr': - t.do_decrypt_ka_data(hp=ref_kafile_hash_preset,pw=ref_kafile_pass,have_yes_opt=True) + t.do_decrypt_ka_data(pw=ref_kafile_pass,have_yes_opt=True) chksum_key = '_'.join([af_key,'chksum'] + ([coin.lower()] if coin else []) + ([mmtype] if mmtype else [])) rc = self.chk_data[chksum_key] ref_chksum = rc if (ftype == 'passwd' or coin) else rc[self.proto.base_coin.lower()][self.proto.testnet] @@ -303,15 +303,14 @@ class TestSuiteRef(TestSuiteBase,TestSuiteShared): tf = joinpath(ref_dir,self.ref_subdir,fn) wf = dfl_words_file self.write_to_tmpfile(pwfile,wpasswd) - pf = joinpath(self.tmpdir,pwfile) - return self.txsign(wf,tf,pf,save=False,has_label=True,view='y') + return self.txsign(wf,tf,save=False,has_label=True,view='y') def ref_brain_chk_spc3(self): return self.ref_brain_chk(bw_file=ref_bw_file_spc) def ref_dieroll_chk_seedtruncate(self): wf = joinpath(ref_dir,'overflow128.b6d') - return self.walletchk(wf,None,sid='8EC6D4A2') + return self.walletchk(wf,sid='8EC6D4A2') def ref_tool_decrypt(self): f = joinpath(ref_dir,ref_enc_fn) diff --git a/test/test_py_d/ts_ref_3seed.py b/test/test_py_d/ts_ref_3seed.py index 6cc52cfa..910e88ad 100755 --- a/test/test_py_d/ts_ref_3seed.py +++ b/test/test_py_d/ts_ref_3seed.py @@ -80,7 +80,7 @@ class TestSuiteRef3Seed(TestSuiteBase,TestSuiteShared): ) def __init__(self,trunner,cfgs,spawn): - for k,j in self.cmd_group: + for k,_ in self.cmd_group: for n in (1,2,3): # 128,192,256 bits setattr(self,f'{k}_{n}',getattr(self,k)) if cfgs: @@ -91,13 +91,12 @@ class TestSuiteRef3Seed(TestSuiteBase,TestSuiteShared): def ref_wallet_chk(self): wf = joinpath(ref_dir,TestSuiteWalletConv.sources[str(self.seed_len)]['ref_wallet']) - return self.walletchk(wf,pf=None,sid=self.seed_id) + return self.walletchk(wf,sid=self.seed_id) def ref_ss_chk(self,ss_type): ss = get_wallet_cls(ss_type) return self.walletchk( wf = joinpath(ref_dir,f'{self.seed_id}.{ss.ext}'), - pf = None, wcls = ss, sid = self.seed_id ) @@ -373,8 +372,7 @@ class TestSuiteRef3Addr(TestSuiteRef3Seed): def call_addrgen(self,mmtype,pfx='addr'): wf = self.get_file_with_ext('mmdat') - pf = joinpath(self.tmpdir,pwfile) - return getattr(self,pfx+'gen')(wf,pf=pf,check_ref=True,mmtype=mmtype) + return getattr(self,pfx+'gen')(wf,check_ref=True,mmtype=mmtype) def refaddrgen_legacy(self): return self.call_addrgen('legacy') @@ -401,7 +399,6 @@ class TestSuiteRef3Addr(TestSuiteRef3Seed): pwlen = (['--passwd-len='+str(pwlen)] if pwlen else []) return self.addrgen( wf, - pf, check_ref = True, ftype = ftype, id_str = id_str, diff --git a/test/test_py_d/ts_regtest.py b/test/test_py_d/ts_regtest.py index 6043b525..9ddc208c 100755 --- a/test/test_py_d/ts_regtest.py +++ b/test/test_py_d/ts_regtest.py @@ -616,7 +616,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): 'mmgen-addrimport', [ '--bob', '--rescan', '--quiet', f'--address={self.miner_addr}' ] ) - def fund_wallet_deterministic(self,user,addr,utxo_nums,skip_passphrase=False): + def fund_wallet_deterministic(self,addr,utxo_nums,skip_passphrase=False): """ the deterministic funding method using specific inputs """ @@ -639,7 +639,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): sid = self._user_sid('alice') mmtype = ('L','S')[self.proto.cap('segwit')] addr = self.get_addr_from_addrlist('alice',sid,mmtype,0,addr_range='1-5') - return self.fund_wallet_deterministic( 'alice', addr, '1-11', skip_passphrase=True ) + return self.fund_wallet_deterministic( addr, '1-11', skip_passphrase=True ) def generate_extra_deterministic(self): if not self.deterministic: @@ -914,7 +914,6 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): extra_args = [], wf = None, bad_locktime = False, - full_tx_view = False, menu = ['M'], skip_passphrase = False, used_chg_addr_resp = None): @@ -949,7 +948,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): def bob_split1(self): sid = self._user_sid('bob') outputs_cl = [sid+':C:1,100', sid+':L:2,200',sid+':'+rtBobOp3] - return self.user_txdo('bob',rtFee[0],outputs_cl,'1',do_label=True,full_tx_view=True) + return self.user_txdo('bob',rtFee[0],outputs_cl,'1') def get_addr_from_addrlist(self,user,sid,mmtype,idx,addr_range='1-5'): id_str = { 'L':'', 'S':'-S', 'C':'-C', 'B':'-B' }[mmtype] @@ -1244,7 +1243,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): taddr = 35 if self.proto.cap('segwit') else 25 t.expect(f'Exporting {taddr-npruned} addresses') - fn = t.written_to_file('JSON data') + t.written_to_file('JSON data') return t def bob_twprune_noask(self): @@ -1772,7 +1771,6 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): idx, by_mmtype = False, include_dest = True, - by_addrtype = False, ignore_labels = False): if mmtype in ('S','B') and not self.proto.cap('segwit'): return 'skip' diff --git a/test/test_py_d/ts_shared.py b/test/test_py_d/ts_shared.py index efb57264..04d046ef 100755 --- a/test/test_py_d/ts_shared.py +++ b/test/test_py_d/ts_shared.py @@ -168,15 +168,13 @@ class TestSuiteShared: t.expect('Signing transaction') t.do_comment(False,has_label=has_label) t.expect(r'Save signed transaction.*?\? \(Y/n\): ','y',regex=True) - t.written_to_file('Signed transaction' + (' #' + tnum if tnum else ''), oo=True) + t.written_to_file('Signed transaction' + (' #' + tnum if tnum else '')) return t def txsign( self, wf, txfile, - pf = '', - bumpf = '', save = True, has_label = False, extra_opts = [], @@ -202,12 +200,11 @@ class TestSuiteShared: def ref_brain_chk(self,bw_file=ref_bw_file): wf = joinpath(ref_dir,bw_file) add_args = [f'-l{self.seed_len}', f'-p{ref_bw_hash_preset}'] - return self.walletchk(wf,pf=None,add_args=add_args,sid=self.ref_bw_seed_id) + return self.walletchk(wf,add_args=add_args,sid=self.ref_bw_seed_id) def walletchk( self, wf, - pf, wcls = None, add_args = [], sid = None, @@ -233,7 +230,6 @@ class TestSuiteShared: def addrgen( self, wf, - pf = None, check_ref = False, ftype = 'addr', id_str = None, @@ -270,7 +266,7 @@ class TestSuiteShared: cmp_or_die(chk,chk_ref,desc=f'{ftype}list data checksum') return t - def keyaddrgen(self,wf,pf=None,check_ref=False,mmtype=None): + def keyaddrgen(self,wf,check_ref=False,mmtype=None): if not mmtype: mmtype = self.segwit_mmtype args = ['-d',self.tmpdir,self.usr_rand_arg,wf,self.addr_idx_list] @@ -288,7 +284,7 @@ class TestSuiteShared: t.usr_rand(self.usr_rand_chars) t.hash_preset('new key-address list','1') t.passphrase_new('new key-address list',self.kapasswd) - t.written_to_file('Encrypted secret keys',oo=True) + t.written_to_file('Encrypted secret keys') return t def _do_confirm_send(self,t,quiet=False,confirm_send=True,sure=True): diff --git a/test/test_py_d/ts_tool.py b/test/test_py_d/ts_tool.py index eb72de06..32e1299c 100755 --- a/test/test_py_d/ts_tool.py +++ b/test/test_py_d/ts_tool.py @@ -47,7 +47,6 @@ class TestSuiteTool(TestSuiteMain,TestSuiteBase): ) def tool_rand2file(self): - outfile = os.path.join(self.tmpdir,'rand2file.out') from mmgen.util2 import parse_bytespec for nbytes in ('1','1023','1K','1048575','1M','1048577','123M'): t = self.spawn( diff --git a/test/test_py_d/ts_wallet.py b/test/test_py_d/ts_wallet.py index 24a34e7c..68421021 100755 --- a/test/test_py_d/ts_wallet.py +++ b/test/test_py_d/ts_wallet.py @@ -89,14 +89,14 @@ class TestSuiteWalletConv(TestSuiteBase,TestSuiteShared): ) def __init__(self,trunner,cfgs,spawn): - for k,j in self.cmd_group: + for k,_ in self.cmd_group: for n in (1,2,3): setattr(self,f'{k}_{n}',getattr(self,k)) - return TestSuiteBase.__init__(self,trunner,cfgs,spawn) + TestSuiteBase.__init__(self,trunner,cfgs,spawn) def ref_wallet_conv(self): wf = joinpath(ref_dir,self.sources[str(self.seed_len)]['ref_wallet']) - return self.walletconv_in(wf,oo=True) + return self.walletconv_in(wf) def ref_mn_conv(self,ext='mmwords'): wf = joinpath(ref_dir,self.seed_id+'.'+ext) @@ -115,12 +115,12 @@ class TestSuiteWalletConv(TestSuiteBase,TestSuiteShared): def ref_brain_conv(self): uopts = ['-i','bw','-p','1','-l',str(self.seed_len)] - return self.walletconv_in(None,uopts,oo=True,icls=get_wallet_cls('brain')) + return self.walletconv_in(None,uopts,icls=get_wallet_cls('brain')) def ref_incog_conv(self,wfk='ic_wallet',in_fmt='i'): uopts = ['-i',in_fmt,'-p','1','-l',str(self.seed_len)] wf = joinpath(ref_dir,self.sources[str(self.seed_len)][wfk]) - return self.walletconv_in(wf,uopts,oo=True) + return self.walletconv_in(wf,uopts) def ref_incox_conv(self): return self.ref_incog_conv(in_fmt='xi',wfk='ic_wallet_hex') @@ -132,7 +132,6 @@ class TestSuiteWalletConv(TestSuiteBase,TestSuiteShared): return self.walletconv_in( None, uopts + hi_opt, - oo = True, icls = get_wallet_cls('incog_hidden') ) def ref_hincog_conv_old(self): @@ -190,7 +189,7 @@ class TestSuiteWalletConv(TestSuiteBase,TestSuiteShared): return 'ok' # wallet conversion tests - def walletconv_in(self,infile,uopts=[],oo=False,icls=None): + def walletconv_in(self,infile,uopts=[],icls=None): ocls = get_wallet_cls('words') opts = ['-d',self.tmpdir,'-o',ocls.fmt_codes[0],self.usr_rand_arg] if_arg = [infile] if infile else [] @@ -206,13 +205,12 @@ class TestSuiteWalletConv(TestSuiteBase,TestSuiteShared): t.expect('Is the Seed ID correct? (Y/n): ','\n') else: t.expect(['Passphrase is OK',' are correct']) - wf = t.written_to_file(capfirst(ocls.desc),oo=oo) + wf = t.written_to_file(capfirst(ocls.desc)) t.p.wait() # back check of result msg('' if cfg.profile else ' OK') return self.walletchk( wf, - pf = None, extra_desc = '(check)', sid = self.seed_id) @@ -228,14 +226,13 @@ class TestSuiteWalletConv(TestSuiteBase,TestSuiteShared): t.passphrase_new('new '+wcls.desc,self.wpasswd) t.usr_rand(self.usr_rand_chars) if wcls.type.startswith('incog'): - for i in (1,2,3): + for _ in (1,2,3): t.expect('Encrypting random data from your operating system with ephemeral key') if wcls.type == 'incog_hidden': t.hincog_create(hincog_bytes) if out_fmt == 'w': t.label() - wf = t.written_to_file(capfirst(wcls.desc),oo=True) - pf = None + wf = t.written_to_file(capfirst(wcls.desc)) if wcls.type == 'incog_hidden': add_args += uopts_chk @@ -243,7 +240,6 @@ class TestSuiteWalletConv(TestSuiteBase,TestSuiteShared): msg('' if cfg.profile else ' OK') return self.walletchk( wf, - pf = pf, wcls = wcls, extra_desc = '(check)', sid = self.seed_id, diff --git a/test/test_py_d/ts_xmr_autosign.py b/test/test_py_d/ts_xmr_autosign.py index 940db10b..a35c436f 100755 --- a/test/test_py_d/ts_xmr_autosign.py +++ b/test/test_py_d/ts_xmr_autosign.py @@ -347,7 +347,6 @@ class TestSuiteXMRAutosign(TestSuiteXMRWallet,TestSuiteAutosignBase): return self._submit_transfer_tx( relay_parm=self.tx_relay_daemon_parm ) def _submit_transfer_tx(self,relay_parm=None,ext=None,op='submit',check_bal=True): - data = self.users['alice'] t = self._xmr_autosign_op( op = op, add_opts = [f'--tx-relay-daemon={relay_parm}'] if relay_parm else [], diff --git a/test/test_py_d/ts_xmrwallet.py b/test/test_py_d/ts_xmrwallet.py index beab396b..0d96c6ec 100755 --- a/test/test_py_d/ts_xmrwallet.py +++ b/test/test_py_d/ts_xmrwallet.py @@ -693,7 +693,7 @@ class TestSuiteXMRWallet(TestSuiteBase): async def _get_height(self): u = self.users['miner'] - for i in range(20): + for _ in range(20): try: return u.md_rpc.call('get_last_block_header')['block_header']['height'] except Exception as e: @@ -735,7 +735,7 @@ class TestSuiteXMRWallet(TestSuiteBase): data = self.users['miner'] addr = read_from_file(data.addrfile_fs.format(1)) # mine to wallet #1, account 0 - for i in range(20): + for _ in range(20): ret = data.md_rpc.call_raw( 'start_mining', do_background_mining = False, # run mining in background or foreground diff --git a/test/tooltest.py b/test/tooltest.py index 691cc96b..e77f4a79 100755 --- a/test/tooltest.py +++ b/test/tooltest.py @@ -381,7 +381,7 @@ class MMGenToolTestCmds: (f1,f2,''), (f3,f4,compressed)): ao = ['--type='+k] if k else [] - ret = tu.run_cmd_chk(name,fi,fo,add_opts=ao) + tu.run_cmd_chk(name,fi,fo,add_opts=ao) def addr2pubhash(self,name,f1,f2,f3,f4): for n,f,m,ao in ( (1,f1,'',[]), @@ -391,7 +391,7 @@ class MMGenToolTestCmds: addr = read_from_file(f).split()[-1] tu.run_cmd_out(name,addr,fn_idx=n,add_opts=ao,extra_msg=m) def pubhash2addr(self,name,f1,f2,f3,f4,f5,f6,f7,f8): - for n,fi,fo,m,ao in ( + for _,fi,fo,m,ao in ( (1,f1,f2,'',[]), (2,f3,f4,'from {}'.format( compressed or 'uncompressed' ),[]), (4,f7,f8,'',type_bech32_arg) @@ -463,7 +463,7 @@ class MMGenToolTestCmds: start_time = int(time.time()) mk_tmpdir(tcfg['tmpdir']) -def gen_deps_for_cmd(cmd,cdata): +def gen_deps_for_cmd(cdata): fns = [] if cdata: name,code = cdata @@ -480,7 +480,7 @@ def do_cmds(cmd_group): tc = MMGenToolTestCmds() gdata = cmd_data[cmd_group]['cmd_data'] for cmd in gdata: - fns = gen_deps_for_cmd(cmd,gdata[cmd]) + fns = gen_deps_for_cmd(gdata[cmd]) cmdline = [cmd] + [os.path.join(tcfg['tmpdir'],fn) for fn in fns] getattr(tc,cmd)(*cmdline) diff --git a/test/tooltest2.py b/test/tooltest2.py index a0de6935..1ab24d1a 100755 --- a/test/tooltest2.py +++ b/test/tooltest2.py @@ -751,7 +751,7 @@ tests = { coin_dependent_groups = ('Coin','File') -def fork_cmd(cmd_name,args,out,opts,stdin_input): +def fork_cmd(cmd_name,args,opts,stdin_input): cmd = ( tool_cmd_preargs + tool_cmd + @@ -778,7 +778,7 @@ def fork_cmd(cmd_name,args,out,opts,stdin_input): return cmd_out.strip() -async def call_method(cls,method,cmd_name,args,out,opts,mmtype,stdin_input): +async def call_method(cls,method,cmd_name,args,mmtype,stdin_input): vmsg('{}: {}{}'.format(purple('Running'), ' '.join([cmd_name]+[repr(e) for e in args]), ' '+mmtype if mmtype else '' )) @@ -809,7 +809,7 @@ async def call_method(cls,method,cmd_name,args,out,opts,mmtype,stdin_input): cfg.quiet = oq_save return ret -def tool_api(cls,cmd_name,args,out,opts): +def tool_api(cls,cmd_name,args,opts): from mmgen.tool.api import tool_api tool = tool_api(cfg) if opts: @@ -883,15 +883,15 @@ async def run_test(cls,gid,cmd_name): if cfg.tool_api: if args and args[0 ]== '-': continue - cmd_out = tool_api(cls,cmd_name,args,out,opts) + cmd_out = tool_api(cls,cmd_name,args,opts) elif cfg.fork: - cmd_out = fork_cmd(cmd_name,args,out,opts,stdin_input) + cmd_out = fork_cmd(cmd_name,args,opts,stdin_input) else: if stdin_input and gc.platform == 'win': msg('Skipping for MSWin - no os.fork()') continue method = getattr(cls(cfg,cmdname=cmd_name,proto=proto,mmtype=mmtype),cmd_name) - cmd_out = await call_method(cls,method,cmd_name,args,out,opts,mmtype,stdin_input) + cmd_out = await call_method(cls,method,cmd_name,args,mmtype,stdin_input) try: vmsg(f'Output:\n{cmd_out}\n') diff --git a/test/unit_tests_d/ut_daemon.py b/test/unit_tests_d/ut_daemon.py index c46ea56b..b1545bcf 100755 --- a/test/unit_tests_d/ut_daemon.py +++ b/test/unit_tests_d/ut_daemon.py @@ -68,7 +68,7 @@ class unit_tests: args = ['python3', f'test/{args_in[0]}-coin-daemons.py'] + list(args_in[1:]) + self.daemon_ctrl_args vmsg('\n' + orange(f"Running '{' '.join(args)}':")) pipe = None if cfg.verbose else PIPE - cp = run( args, stdout=pipe, stderr=pipe, check=True ) + run( args, stdout=pipe, stderr=pipe, check=True ) qmsg('OK') return True diff --git a/test/unit_tests_d/ut_dep.py b/test/unit_tests_d/ut_dep.py index cb5d856a..cee7e917 100755 --- a/test/unit_tests_d/ut_dep.py +++ b/test/unit_tests_d/ut_dep.py @@ -82,13 +82,13 @@ class unit_tests: from cryptography.hazmat.backends import default_backend c = Cipher(algorithms.AES(b'deadbeef'*4),modes.CTR(b'deadbeef'*2),backend=default_backend()) encryptor = c.encryptor() - enc_data = encryptor.update(b'foo') + encryptor.finalize() + encryptor.update(b'foo') + encryptor.finalize() return True def ecdsa(self,name,ut): import ecdsa pko = ecdsa.SigningKey.from_secret_exponent(12345678901234,curve=ecdsa.SECP256k1) - pubkey = pko.get_verifying_key().to_string().hex() + pko.get_verifying_key().to_string().hex() return True def ripemd160(self,name,ut): @@ -110,7 +110,7 @@ class unit_tests: async with aiohttp.ClientSession( headers = { 'Content-Type': 'application/json' }, connector = aiohttp.TCPConnector(), - ) as session: + ): pass asyncio.run(do()) return True diff --git a/test/unit_tests_d/ut_mn_entry.py b/test/unit_tests_d/ut_mn_entry.py index 63e6deb1..a65d0d56 100755 --- a/test/unit_tests_d/ut_mn_entry.py +++ b/test/unit_tests_d/ut_mn_entry.py @@ -47,7 +47,6 @@ class unit_test: from mmgen.mn_entry import mn_entry msg_r('\nTesting computed wordlist constants...') - usl = {} for wl_id in self.vectors: for j,k in (('uniq_ss_len','usl'),('shortest_word','sw'),('longest_word','lw')): a = getattr(mn_entry( cfg, wl_id ),j) diff --git a/test/unit_tests_d/ut_testdep.py b/test/unit_tests_d/ut_testdep.py index bb3ab7ff..526b353a 100755 --- a/test/unit_tests_d/ut_testdep.py +++ b/test/unit_tests_d/ut_testdep.py @@ -34,20 +34,20 @@ class unit_tests: network = nfnc('btc') key = network.keys.private(secret_exponent=int(sec,16),is_compressed=True) hash160_c = key.hash160(is_compressed=True) - addr = network.address.for_p2pkh_wit(hash160_c) + network.address.for_p2pkh_wit(hash160_c) return True def monero_python(self,name,ut): from monero.seed import Seed - res = Seed('deadbeef' * 8).public_address() + Seed('deadbeef' * 8).public_address() return True def keyconv(self,name,ut): - res = run(['keyconv','-G','ltc'],stdout=PIPE,stderr=PIPE,check=True) + run(['keyconv','-G','ltc'],stdout=PIPE,stderr=PIPE,check=True) return True def zcash_mini(self,name,ut): - res = run(['zcash-mini'],stdout=PIPE,check=True) + run(['zcash-mini'],stdout=PIPE,check=True) return True def ethkey(self,name,ut): diff --git a/test/unit_tests_d/ut_tx.py b/test/unit_tests_d/ut_tx.py index a01d879b..15e8fd2f 100755 --- a/test/unit_tests_d/ut_tx.py +++ b/test/unit_tests_d/ut_tx.py @@ -62,7 +62,7 @@ class unit_tests: d.start() proto = init_proto( cfg, 'btc', need_amt=True ) - tx = await NewTX( cfg=cfg, proto=proto ) + await NewTX( cfg=cfg, proto=proto ) d.stop() qmsg(' OK')