cmdtest.py: cleanups, whitespace
This commit is contained in:
parent
5c419c802b
commit
2cb00192d9
9 changed files with 94 additions and 40 deletions
|
|
@ -119,7 +119,9 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtestBDBWallet)
|
|||
|
||||
def _alice_txsend_abort(self, err=False, user_exit=False, del_expect=[]):
|
||||
self.insert_device_online()
|
||||
t = self.spawn('mmgen-txsend', ['--quiet', '--abort'])
|
||||
t = self.spawn(
|
||||
'mmgen-txsend',
|
||||
['--quiet', '--abort'])
|
||||
if err:
|
||||
t.expect('No unsent transactions')
|
||||
t.req_exit_val = 2
|
||||
|
|
@ -187,7 +189,9 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtestBDBWallet)
|
|||
|
||||
def _alice_txstatus(self, expect, exit_val=None):
|
||||
self.insert_device_online()
|
||||
t = self.spawn('mmgen-txsend', ['--alice', '--autosign', '--status', '--verbose'])
|
||||
t = self.spawn(
|
||||
'mmgen-txsend',
|
||||
['--alice', '--autosign', '--status', '--verbose'])
|
||||
t.expect(expect)
|
||||
self.remove_device_online()
|
||||
if exit_val:
|
||||
|
|
@ -233,7 +237,9 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtestBDBWallet)
|
|||
if cfg.coin == 'BCH':
|
||||
return 'skip'
|
||||
self.insert_device_online()
|
||||
t = self.spawn('mmgen-txbump', ['--alice', '--autosign'])
|
||||
t = self.spawn(
|
||||
'mmgen-txbump',
|
||||
['--alice', '--autosign'])
|
||||
if bad_tx_desc:
|
||||
t.expect('Only sent transactions')
|
||||
t.expect(bad_tx_desc)
|
||||
|
|
|
|||
|
|
@ -634,7 +634,9 @@ class CmdTestAutosign(CmdTestAutosignBase):
|
|||
|
||||
def do_sign(self, args, have_msg=False):
|
||||
tx_desc = Signable.transaction.desc
|
||||
t = self.spawn('mmgen-autosign', self.opts + args)
|
||||
t = self.spawn(
|
||||
'mmgen-autosign',
|
||||
self.opts + args)
|
||||
t.expect(
|
||||
f'{self.tx_count} {tx_desc}{suf(self.tx_count)} signed' if self.tx_count else
|
||||
f'No unsigned {tx_desc}s')
|
||||
|
|
@ -799,12 +801,15 @@ class CmdTestAutosignLive(CmdTestAutosignBTC):
|
|||
self.do_umount()
|
||||
prompt_remove()
|
||||
omsg('\n' + cyan(indent(info_msg)))
|
||||
|
||||
t = self.spawn(
|
||||
'mmgen-autosign',
|
||||
self.opts + (led_opts or []) + ['--quiet', '--no-summary', 'wait'],
|
||||
no_msg = True)
|
||||
|
||||
if not cfg.exact_output:
|
||||
omsg('')
|
||||
|
||||
prompt_insert_sign(t)
|
||||
|
||||
self.do_mount() # race condition due to device insertion detection
|
||||
|
|
@ -814,6 +819,7 @@ class CmdTestAutosignLive(CmdTestAutosignBTC):
|
|||
imsg(purple('\nKilling wait loop!'))
|
||||
t.kill(2) # 2 = SIGINT
|
||||
t.req_exit_val = 1
|
||||
|
||||
if self.simulate_led and led_opts:
|
||||
t.expect('Stopping LED')
|
||||
return t
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ class CmdTestCfgFile(CmdTestBase):
|
|||
return self.spawn(
|
||||
'test/misc/cfg.py',
|
||||
[f'--data-dir={self.path("data_dir")}'] + args,
|
||||
cmd_dir = '.',
|
||||
extra_desc = extra_desc,
|
||||
pexpect_spawn = pexpect_spawn )
|
||||
cmd_dir = '.',
|
||||
extra_desc = extra_desc,
|
||||
pexpect_spawn = pexpect_spawn)
|
||||
|
||||
def path(self,id_str):
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -596,7 +596,12 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
t.written_to_file('Addresses')
|
||||
return t
|
||||
|
||||
def addrimport(self,ext='21-23]{}.regtest.addrs',expect='9/9',add_args=[],bad_input=False):
|
||||
def addrimport(
|
||||
self,
|
||||
ext = '21-23]{}.regtest.addrs',
|
||||
expect = '9/9',
|
||||
add_args = [],
|
||||
bad_input = False):
|
||||
ext = ext.format('-α' if cfg.debug_utf8 else '')
|
||||
fn = self.get_file_with_ext(ext,no_dot=True,delete=False)
|
||||
t = self.spawn('mmgen-addrimport', self.eth_args[1:-1] + add_args + [fn])
|
||||
|
|
@ -743,7 +748,9 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
def tx_status(self,ext,expect_str,expect_str2='',add_args=[],exit_val=0):
|
||||
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 + ['--status',txfile])
|
||||
t = self.spawn(
|
||||
'mmgen-txsend',
|
||||
self.eth_args + add_args + ['--status', txfile])
|
||||
t.expect(expect_str)
|
||||
if expect_str2:
|
||||
t.expect(expect_str2)
|
||||
|
|
@ -1109,13 +1116,19 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
return self.addrgen(addrs='21-23')
|
||||
|
||||
def token_addrimport_badaddr1(self):
|
||||
t = self.addrimport(ext='[11-13]{}.regtest.addrs',add_args=['--token=abc'],bad_input=True)
|
||||
t = self.addrimport(
|
||||
ext = '[11-13]{}.regtest.addrs',
|
||||
add_args = ['--token=abc'],
|
||||
bad_input = True)
|
||||
t.expect('could not be resolved')
|
||||
t.req_exit_val = 2
|
||||
return t
|
||||
|
||||
def token_addrimport_badaddr2(self):
|
||||
t = self.addrimport(ext='[11-13]{}.regtest.addrs',add_args=['--token='+'00deadbeef'*4],bad_input=True)
|
||||
t = self.addrimport(
|
||||
ext = '[11-13]{}.regtest.addrs',
|
||||
add_args = ['--token='+'00deadbeef'*4],
|
||||
bad_input = True)
|
||||
t.expect('could not be resolved')
|
||||
t.req_exit_val = 2
|
||||
return t
|
||||
|
|
|
|||
|
|
@ -781,7 +781,7 @@ class CmdTestMain(CmdTestBase,CmdTestShared):
|
|||
'mmgen-addrgen',
|
||||
(['-S'] if stdout else []) +
|
||||
self.segwit_arg +
|
||||
[ '-i' + in_fmt, '-d', self.tmpdir, wf, self.addr_idx_list ] )
|
||||
['-i' + in_fmt, '-d', self.tmpdir, wf, self.addr_idx_list])
|
||||
t.license()
|
||||
t.expect_getend(f'Valid {wcls.desc} for Seed ID ')
|
||||
vmsg('Comparing generated checksum with checksum from previous address file')
|
||||
|
|
@ -800,8 +800,13 @@ class CmdTestMain(CmdTestBase,CmdTestShared):
|
|||
return self.addrgen_seed(wf,_,in_fmt='words')
|
||||
|
||||
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 = self.spawn(
|
||||
'mmgen-addrgen',
|
||||
args
|
||||
+ self.segwit_arg
|
||||
+ ['-i'+in_fmt, '-d', self.tmpdir]
|
||||
+ ([wf] if wf else [])
|
||||
+ [self.addr_idx_list])
|
||||
t.license()
|
||||
t.expect_getend('Incog Wallet ID: ')
|
||||
wcls = get_wallet_cls(fmt_code=in_fmt)
|
||||
|
|
@ -966,7 +971,9 @@ class CmdTestMain(CmdTestBase,CmdTestShared):
|
|||
|
||||
def txsign5(self,wf,txf,bad_vsize=True,add_args=[]):
|
||||
non_mm_file = joinpath(self.tmpdir,non_mmgen_fn)
|
||||
t = self.spawn('mmgen-txsign', add_args + ['-d',self.tmpdir,'-k',non_mm_file,txf,wf])
|
||||
t = self.spawn(
|
||||
'mmgen-txsign',
|
||||
add_args + ['-d', self.tmpdir, '-k', non_mm_file, txf, wf])
|
||||
t.license()
|
||||
t.view_tx('n')
|
||||
wcls = get_wallet_cls(ext=get_extension(wf))
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class CmdTestHelp(CmdTestBase):
|
|||
)
|
||||
|
||||
def usage(self):
|
||||
t = self.spawn('mmgen-walletgen',['foo'])
|
||||
t = self.spawn('mmgen-walletgen', ['foo'])
|
||||
t.expect('USAGE: mmgen-walletgen')
|
||||
t.req_exit_val = 1
|
||||
return t
|
||||
|
|
|
|||
|
|
@ -943,8 +943,16 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared):
|
|||
cmp_or_die(rtBals[6],ret)
|
||||
return t
|
||||
|
||||
def user_txsend_status(self,user,tx_file,exp1='',exp2='',extra_args=[]):
|
||||
t = self.spawn('mmgen-txsend',['-d',self.tmpdir,'--'+user,'--status'] + extra_args + [tx_file])
|
||||
def user_txsend_status(
|
||||
self,
|
||||
user,
|
||||
tx_file,
|
||||
exp1 = '',
|
||||
exp2 = '',
|
||||
extra_args = []):
|
||||
t = self.spawn(
|
||||
'mmgen-txsend',
|
||||
['-d', self.tmpdir, '--'+user, '--status'] + extra_args + [tx_file])
|
||||
if exp1:
|
||||
t.expect(exp1,regex=True)
|
||||
if exp2:
|
||||
|
|
@ -956,7 +964,8 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared):
|
|||
'gettransaction’s ‘timereceived’ field')
|
||||
return t
|
||||
|
||||
def user_txdo( self,
|
||||
def user_txdo(
|
||||
self,
|
||||
user,
|
||||
fee,
|
||||
outputs_cl,
|
||||
|
|
@ -970,10 +979,13 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared):
|
|||
skip_passphrase = False,
|
||||
used_chg_addr_resp = None):
|
||||
|
||||
t = self.spawn('mmgen-txdo',
|
||||
['-d',self.tmpdir,'-B','--'+user] +
|
||||
(['--fee='+fee] if fee else []) +
|
||||
extra_args + ([],[wf])[bool(wf)] + outputs_cl)
|
||||
t = self.spawn(
|
||||
'mmgen-txdo',
|
||||
['-d',self.tmpdir,'-B','--'+user]
|
||||
+ (['--fee='+fee] if fee else [])
|
||||
+ extra_args
|
||||
+ ([],[wf])[bool(wf)]
|
||||
+ outputs_cl)
|
||||
|
||||
self.txcreate_ui_common(
|
||||
t,
|
||||
|
|
@ -1120,12 +1132,12 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared):
|
|||
self.write_to_tmpfile('rbf_txid',mp[0]+'\n')
|
||||
return 'ok'
|
||||
|
||||
def bob_rbf_status(self,fee,exp1,exp2=''):
|
||||
def bob_rbf_status(self, fee, exp1, exp2=''):
|
||||
if not self.proto.cap('rbf'):
|
||||
return 'skip'
|
||||
ext = ',{}]{x}.regtest.sigtx'.format(fee[:-1],x='-α' if cfg.debug_utf8 else '')
|
||||
txfile = self.get_file_with_ext(ext,delete=False,no_dot=True)
|
||||
return self.user_txsend_status('bob',txfile,exp1,exp2)
|
||||
return self.user_txsend_status('bob', txfile, exp1, exp2)
|
||||
|
||||
def bob_rbf_status1(self):
|
||||
if not self.proto.cap('rbf'):
|
||||
|
|
@ -1148,8 +1160,10 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared):
|
|||
if not self.proto.cap('rbf'):
|
||||
return 'skip'
|
||||
new_txid = self.read_from_tmpfile('rbf_txid2').strip()
|
||||
return self.bob_rbf_status(rtFee[1],
|
||||
'Transaction has been replaced',f'{new_txid} in mempool')
|
||||
return self.bob_rbf_status(
|
||||
rtFee[1],
|
||||
'Transaction has been replaced',
|
||||
f'{new_txid} in mempool')
|
||||
|
||||
def bob_rbf_status3(self):
|
||||
if not self.proto.cap('rbf'):
|
||||
|
|
@ -1540,7 +1554,9 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared):
|
|||
if os.getenv('PYTHONOPTIMIZE'):
|
||||
omsg(yellow(f'PYTHONOPTIMIZE set, skipping test {self.test_name!r}'))
|
||||
return 'skip'
|
||||
t = self.spawn('mmgen-tool',['--alice','add_label',addr,'(none)'])
|
||||
t = self.spawn(
|
||||
'mmgen-tool',
|
||||
['--alice','add_label',addr,'(none)'])
|
||||
t.expect(reply,regex=True)
|
||||
t.req_exit_val = exit_val
|
||||
return t
|
||||
|
|
@ -1788,7 +1804,12 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared):
|
|||
fn2 = get_file_with_ext(self.tmpdir,'bip39')
|
||||
return self.bob_msgsign([fn2,fn1])
|
||||
|
||||
def bob_msgverify(self,addr=None,ext='sigmsg.json',cmd='verify',msgfile=None):
|
||||
def bob_msgverify(
|
||||
self,
|
||||
addr = None,
|
||||
ext = 'sigmsg.json',
|
||||
cmd = 'verify',
|
||||
msgfile = None):
|
||||
return self.spawn(
|
||||
'mmgen-msg', [
|
||||
'--bob',
|
||||
|
|
@ -1926,7 +1947,7 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared):
|
|||
def _usr_auto_chg_bad(self,user,al_id,expect):
|
||||
t = self.spawn(
|
||||
'mmgen-txcreate',
|
||||
['-d',self.tr.trash_dir,'-B',f'--{user}', self.burn_addr+',0.01', al_id] )
|
||||
['-d', self.tr.trash_dir, '-B', f'--{user}', self.burn_addr+', 0.01', al_id])
|
||||
t.req_exit_val = 2
|
||||
t.expect(expect)
|
||||
return t
|
||||
|
|
|
|||
|
|
@ -130,11 +130,11 @@ class CmdTestSeedSplit(CmdTestBase):
|
|||
tdir,
|
||||
ofmt,
|
||||
in_exts,
|
||||
add_args = [],
|
||||
sid = None,
|
||||
add_args = [],
|
||||
sid = None,
|
||||
bad_invocation = False,
|
||||
master = None,
|
||||
id_str = None):
|
||||
master = None,
|
||||
id_str = None):
|
||||
td = self.get_tmp_subdir(tdir)
|
||||
shares = [get_file_with_ext(td,f) for f in in_exts]
|
||||
if not sid:
|
||||
|
|
@ -248,14 +248,12 @@ class CmdTestSeedSplit(CmdTestBase):
|
|||
|
||||
def ss_3way_join_dfl_bad_invocation(self):
|
||||
t = self.ss_join('3way_dfl','mmhex',
|
||||
['mmwords','mmincox','bip39'],
|
||||
id_str='foo',
|
||||
bad_invocation=True)
|
||||
['mmwords','mmincox','bip39'],
|
||||
id_str = 'foo',
|
||||
bad_invocation = True)
|
||||
t.expect('option meaningless')
|
||||
t.req_exit_val = 1
|
||||
return t
|
||||
|
||||
|
||||
def ss_bad_invocation1(self):
|
||||
return self.ss_bad_invocation(
|
||||
'mmgen-seedsplit',[],1,'MMGenSystemExit(1)')
|
||||
|
|
|
|||
|
|
@ -195,7 +195,10 @@ class CmdTestShared:
|
|||
view = 'n',
|
||||
dfl_wallet = False):
|
||||
opts = extra_opts + ['-d',self.tmpdir,txfile] + ([wf] if wf else [])
|
||||
t = self.spawn('mmgen-txsign', opts, extra_desc)
|
||||
t = self.spawn(
|
||||
'mmgen-txsign',
|
||||
opts,
|
||||
extra_desc)
|
||||
t.license()
|
||||
t.view_tx(view)
|
||||
wcls = get_wallet_cls( ext = 'mmdat' if dfl_wallet else get_extension(wf) )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue