cmdtest.py: autosign_eth, ethdev: cleanups
This commit is contained in:
parent
75051cd831
commit
fddb5b73b2
2 changed files with 27 additions and 21 deletions
|
|
@ -59,7 +59,7 @@ class CmdTestAutosignETH(CmdTestAutosignThreaded, CmdTestEthdev):
|
|||
CmdTestAutosignThreaded.__init__(self, trunner, cfgs, spawn)
|
||||
CmdTestEthdev.__init__(self, trunner, cfgs, spawn)
|
||||
|
||||
self.txcreate_args = ['--quiet']
|
||||
self.txop_opts = ['--autosign', '--regtest=1', '--quiet']
|
||||
|
||||
def fund_mmgen_address(self):
|
||||
keyfile = os.path.join(self.tmpdir, parity_devkey_fn)
|
||||
|
|
@ -80,11 +80,15 @@ class CmdTestAutosignETH(CmdTestAutosignThreaded, CmdTestEthdev):
|
|||
|
||||
def create_tx(self):
|
||||
self.insert_device_online()
|
||||
t = self.txcreate(
|
||||
args = ['--autosign', '98831F3A:E:11,54.321'],
|
||||
menu = [],
|
||||
print_listing = False,
|
||||
acct = '1')
|
||||
t = self.spawn('mmgen-txcreate', self.txop_opts + ['-B', '98831F3A:E:11,54.321'])
|
||||
t = self.txcreate_ui_common(
|
||||
t,
|
||||
caller = 'txcreate',
|
||||
input_sels_prompt = 'to spend from',
|
||||
inputs = '1',
|
||||
file_desc = 'transaction',
|
||||
interactive_fee = '50G',
|
||||
fee_desc = 'transaction fee or gas price')
|
||||
t.read()
|
||||
self.remove_device_online()
|
||||
return t
|
||||
|
|
@ -95,7 +99,7 @@ class CmdTestAutosignETH(CmdTestAutosignThreaded, CmdTestEthdev):
|
|||
def send_tx(self, add_args=[]):
|
||||
self._wait_signed('transaction')
|
||||
self.insert_device_online()
|
||||
t = self.spawn('mmgen-txsend', ['--quiet', '--autosign'] + add_args)
|
||||
t = self.spawn('mmgen-txsend', self.txop_opts + add_args)
|
||||
t.view_tx('t')
|
||||
t.expect('(y/N): ', 'n')
|
||||
self._do_confirm_send(t, quiet=True)
|
||||
|
|
@ -117,17 +121,20 @@ class CmdTestAutosignETH(CmdTestAutosignThreaded, CmdTestEthdev):
|
|||
return self.token_bal(pat=r':E:11\s+998.76544\s+54.318\d+\s+.*:E:12\s+1\.23456\s+')
|
||||
|
||||
def token_bal(self, pat):
|
||||
t = self.spawn('mmgen-tool', ['--quiet', '--token=mm1', 'twview', 'wide=1'])
|
||||
t = self.spawn('mmgen-tool', ['--regtest=1', '--token=mm1', 'twview', 'wide=1'])
|
||||
text = t.read(strip_color=True)
|
||||
assert re.search(pat, text, re.DOTALL), f'output failed to match regex {pat}'
|
||||
return t
|
||||
|
||||
def create_token_tx(self):
|
||||
self.insert_device_online()
|
||||
t = self.token_txcreate(
|
||||
args = ['--autosign', '98831F3A:E:12,1.23456'],
|
||||
token = 'MM1',
|
||||
file_desc = 'Unsigned automount transaction')
|
||||
t = self.txcreate_ui_common(
|
||||
self.spawn(
|
||||
'mmgen-txcreate',
|
||||
self.txop_opts + ['--token=MM1', '-B', '--fee=50G', '98831F3A:E:12,1.23456']),
|
||||
inputs = '1',
|
||||
input_sels_prompt = 'to spend from',
|
||||
file_desc = 'Unsigned automount transaction')
|
||||
t.read()
|
||||
self.remove_device_online()
|
||||
return t
|
||||
|
|
|
|||
|
|
@ -402,9 +402,8 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
if trunner is None:
|
||||
return
|
||||
|
||||
self.txcreate_args = [f'--outdir={self.tmpdir}', '--quiet']
|
||||
self.eth_args = [f'--outdir={self.tmpdir}', '--quiet']
|
||||
self.eth_args_noquiet = [f'--outdir={self.tmpdir}']
|
||||
self.eth_args = [f'--outdir={self.tmpdir}', '--regtest=1', '--quiet']
|
||||
self.eth_args_noquiet = [f'--outdir={self.tmpdir}', '--regtest=1']
|
||||
|
||||
from mmgen.protocol import init_proto
|
||||
self.proto = init_proto( cfg, cfg.coin, network='regtest', need_amt=True )
|
||||
|
|
@ -611,7 +610,7 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
exit_val = None):
|
||||
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], exit_val=exit_val)
|
||||
t = self.spawn('mmgen-addrimport', ['--regtest=1'] + add_args + [fn], exit_val=exit_val)
|
||||
if bad_input:
|
||||
return t
|
||||
t.expect('Importing')
|
||||
|
|
@ -619,7 +618,7 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
return t
|
||||
|
||||
def addrimport_one_addr(self,addr=None,extra_args=[]):
|
||||
t = self.spawn('mmgen-addrimport', self.eth_args[1:] + extra_args + ['--address='+addr])
|
||||
t = self.spawn('mmgen-addrimport', ['--regtest=1', '--quiet', f'--address={addr}'] + extra_args)
|
||||
t.expect('OK')
|
||||
return t
|
||||
|
||||
|
|
@ -641,7 +640,7 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
print_listing = True,
|
||||
tweaks = []):
|
||||
fee_info_pat = r'\D{}\D.*{c} .*\D{}\D.*gas price in Gwei'.format( *fee_info_data, c=self.proto.coin )
|
||||
t = self.spawn('mmgen-'+caller, self.txcreate_args + ['-B'] + args)
|
||||
t = self.spawn(f'mmgen-{caller}', self.eth_args + ['-B'] + args)
|
||||
if print_listing:
|
||||
t.expect(r'add \[l\]abel, .*?:.','p', regex=True)
|
||||
t.written_to_file('Account balances listing')
|
||||
|
|
@ -1160,7 +1159,7 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
|
||||
def token_txcreate(self,args=[],token='',inputs='1',fee='50G',file_desc='Unsigned transaction'):
|
||||
return self.txcreate_ui_common(
|
||||
self.spawn('mmgen-txcreate', self.txcreate_args + [f'--token={token}', '-B', f'--fee={fee}'] + args),
|
||||
self.spawn('mmgen-txcreate', self.eth_args + [f'--token={token}', '-B', f'--fee={fee}'] + args),
|
||||
menu = [],
|
||||
inputs = inputs,
|
||||
input_sels_prompt = 'to spend from',
|
||||
|
|
@ -1311,7 +1310,7 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
if total_coin is None:
|
||||
total_coin = self.proto.coin
|
||||
|
||||
t = self.spawn('mmgen-txcreate', self.txcreate_args + args)
|
||||
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+'\n')
|
||||
|
|
@ -1375,7 +1374,7 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
changed = False,
|
||||
pexpect_spawn = None):
|
||||
|
||||
t = self.spawn('mmgen-txcreate', self.txcreate_args + args + ['-B', '-i'], pexpect_spawn=pexpect_spawn)
|
||||
t = self.spawn('mmgen-txcreate', self.eth_args + args + ['-B', '-i'], pexpect_spawn=pexpect_spawn)
|
||||
|
||||
menu_prompt = 'efresh balance:\b'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue