minor fixes and cleanups
This commit is contained in:
parent
86863c72d5
commit
15eb13ae50
11 changed files with 37 additions and 21 deletions
|
|
@ -12,7 +12,7 @@
|
|||
altcoin.util: various altcoin-related utilities
|
||||
"""
|
||||
|
||||
from mmgen.util import die
|
||||
from ..util import die
|
||||
|
||||
def decrypt_keystore(data,passwd,mac_algo=None,mac_params={}):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -80,7 +80,9 @@ async def main():
|
|||
tx.file.write(ask_write_default_yes=True)
|
||||
|
||||
await tx.send(exit_on_fail=True)
|
||||
tx.file.write(ask_overwrite=False,ask_write=False)
|
||||
tx.file.write(
|
||||
ask_overwrite = False,
|
||||
ask_write = False)
|
||||
tx.print_contract_addr()
|
||||
|
||||
async_run(main())
|
||||
|
|
|
|||
|
|
@ -114,8 +114,8 @@ if not cfg.info and not cfg.terse_info:
|
|||
|
||||
from .tx.sign import txsign,get_tx_files,get_seed_files,get_keylist,get_keyaddrlist
|
||||
|
||||
tx_files = get_tx_files(infiles)
|
||||
seed_files = get_seed_files(cfg,infiles)
|
||||
tx_files = get_tx_files(cfg, infiles)
|
||||
seed_files = get_seed_files(cfg, infiles)
|
||||
|
||||
async def main():
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ def make_help(cfg,proto,opts_data,opt_filter):
|
|||
|
||||
pn = opts_data['prog_name']
|
||||
|
||||
from mmgen.help import help_notes_func
|
||||
from ..help import help_notes_func
|
||||
def help_notes(k):
|
||||
return help_notes_func(proto,cfg,k)
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,9 @@ async def _get_obj_async( _clsname, _modname, *args, **kwargs ):
|
|||
# (see twctl:import_token()).
|
||||
# No twctl required for the Unsigned and Signed(data=unsigned.__dict__) classes used during
|
||||
# signing.
|
||||
if proto and proto.tokensym and clsname in ('New','OnlineSigned'):
|
||||
if proto and proto.tokensym and clsname in (
|
||||
'New',
|
||||
'OnlineSigned'):
|
||||
from ..tw.ctl import TwCtl
|
||||
kwargs['twctl'] = await TwCtl(cfg,proto)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
"""
|
||||
tx.file: Transaction file operations for the MMGen suite
|
||||
"""
|
||||
import os
|
||||
|
||||
from ..util import ymsg,make_chksum_6,die
|
||||
from ..obj import MMGenObject,HexStr,MMGenTxID,CoinTxID,MMGenTxComment
|
||||
|
|
@ -113,7 +114,7 @@ class MMGenTxFile(MMGenObject):
|
|||
tx.proto.tokensym = tokensym
|
||||
|
||||
desc = 'metadata (4 items)'
|
||||
txid,send_amt,tx.timestamp,blockcount = metadata
|
||||
(txid, send_amt, tx.timestamp, blockcount) = metadata
|
||||
|
||||
desc = 'TxID in metadata'
|
||||
tx.txid = MMGenTxID(txid)
|
||||
|
|
@ -193,6 +194,7 @@ class MMGenTxFile(MMGenObject):
|
|||
|
||||
def write(self,
|
||||
add_desc = '',
|
||||
outdir = None,
|
||||
ask_write = True,
|
||||
ask_write_default_yes = False,
|
||||
ask_tty = True,
|
||||
|
|
@ -210,13 +212,14 @@ class MMGenTxFile(MMGenObject):
|
|||
from ..fileutil import write_data_to_file
|
||||
write_data_to_file(
|
||||
cfg = self.tx.cfg,
|
||||
outfile = self.filename,
|
||||
outfile = os.path.join((outdir or ''), self.filename),
|
||||
data = self.fmt_data,
|
||||
desc = self.tx.desc + add_desc,
|
||||
ask_overwrite = ask_overwrite,
|
||||
ask_write = ask_write,
|
||||
ask_tty = ask_tty,
|
||||
ask_write_default_yes = ask_write_default_yes )
|
||||
ask_write_default_yes = ask_write_default_yes,
|
||||
ignore_opt_outdir = outdir)
|
||||
|
||||
@classmethod
|
||||
def get_proto(cls,cfg,filename,quiet_open=False):
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ def add_keys(tx,src,infiles=None,saved_seeds=None,keyaddr_list=None):
|
|||
def _pop_matching_fns(args,cmplist): # strips found args
|
||||
return list(reversed([args.pop(args.index(a)) for a in reversed(args) if get_extension(a) in cmplist]))
|
||||
|
||||
def get_tx_files(args):
|
||||
def get_tx_files(cfg, args):
|
||||
from .unsigned import Unsigned
|
||||
ret = _pop_matching_fns(args,[Unsigned.ext])
|
||||
if not ret:
|
||||
|
|
|
|||
|
|
@ -614,6 +614,7 @@ class CmdTestRunner:
|
|||
timeout = None,
|
||||
pexpect_spawn = None,
|
||||
direct_exec = False,
|
||||
no_passthru_opts = False,
|
||||
env = {}):
|
||||
|
||||
desc = self.tg.test_name if cfg.names else self.gm.dpy_data[self.tg.test_name][1]
|
||||
|
|
@ -628,7 +629,7 @@ class CmdTestRunner:
|
|||
self.pre_args +
|
||||
([] if no_exec_wrapper else ['scripts/exec_wrapper.py']) +
|
||||
[cmd_path] +
|
||||
self.passthru_opts +
|
||||
([] if no_passthru_opts else self.passthru_opts) +
|
||||
self.tg.extra_spawn_args +
|
||||
args )
|
||||
|
||||
|
|
@ -968,9 +969,11 @@ class CmdTestRunner:
|
|||
self.cmd_total += 1
|
||||
elif ret == 'error':
|
||||
die(2,red(f'\nTest {self.tg.test_name!r} failed'))
|
||||
elif ret in ('skip','silent'):
|
||||
elif ret in ('skip','skip_msg','silent'):
|
||||
if ret == 'silent':
|
||||
self.cmd_total += 1
|
||||
elif ret == 'skip_msg':
|
||||
ok('SKIP')
|
||||
elif isinstance(ret,tuple) and ret[0] == 'skip_warn':
|
||||
self.skipped_warnings.append(
|
||||
'Test {!r} was skipped:\n {}'.format(cmd,'\n '.join(ret[1].split('\n'))))
|
||||
|
|
|
|||
|
|
@ -130,9 +130,10 @@ class CmdTestAutosignBase(CmdTestBase):
|
|||
|
||||
t = self.spawn(
|
||||
'mmgen-autosign',
|
||||
self.opts +
|
||||
([] if mn_desc == 'default' else [f'--mnemonic-fmt={mn_type}']) +
|
||||
['setup'] )
|
||||
self.opts
|
||||
+ ([] if mn_desc == 'default' else [f'--mnemonic-fmt={mn_type}'])
|
||||
+ ['setup'],
|
||||
no_passthru_opts = True)
|
||||
|
||||
if use_dfl_wallet:
|
||||
t.expect( 'Use default wallet for autosigning? (Y/n): ', 'y' )
|
||||
|
|
@ -177,7 +178,11 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
|
|||
|
||||
def autosign_start_thread(self):
|
||||
def run():
|
||||
t = self.spawn('mmgen-autosign', self.opts + ['--full-summary','wait'], direct_exec=True)
|
||||
t = self.spawn(
|
||||
'mmgen-autosign',
|
||||
self.opts + ['--full-summary','wait'],
|
||||
direct_exec = True,
|
||||
no_passthru_opts = True)
|
||||
self.write_to_tmpfile('autosign_thread_pid',str(t.ep.pid))
|
||||
import threading
|
||||
threading.Thread(target=run, name='Autosign wait loop').start()
|
||||
|
|
@ -213,6 +218,7 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
|
|||
oqmsg(gray('..done'))
|
||||
break
|
||||
time.sleep(0.5)
|
||||
imsg('')
|
||||
self.remove_device()
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -171,13 +171,13 @@ def read_from_tmpfile(cfg,fn,binary=False):
|
|||
def joinpath(*args,**kwargs):
|
||||
return os.path.join(*args,**kwargs)
|
||||
|
||||
def ok():
|
||||
def ok(text='OK'):
|
||||
if cfg.profile:
|
||||
return
|
||||
if cfg.verbose or cfg.exact_output:
|
||||
gmsg('OK')
|
||||
gmsg(text)
|
||||
else:
|
||||
msg(' OK')
|
||||
msg(f' {text}')
|
||||
|
||||
def cmp_or_die(s,t,desc=None):
|
||||
if s != t:
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ init_tests() {
|
|||
t_bch="- $cmdtest_py --coin=bch --exclude regtest"
|
||||
|
||||
d_bch_tn="overall operations with emulated RPC data (Bitcoin Cash Node testnet)"
|
||||
t_bch_tn="- $cmdtest_py --coin=bch --testnet=1 --exclude regtest"
|
||||
t_bch_tn="- $cmdtest_py --coin=bch --testnet=1"
|
||||
|
||||
d_bch_rt="overall operations using the regtest network (Bitcoin Cash Node)"
|
||||
t_bch_rt="- $cmdtest_py --coin=bch regtest"
|
||||
|
|
@ -200,7 +200,7 @@ init_tests() {
|
|||
|
||||
d_ltc_tn="overall operations with emulated RPC data (Litecoin testnet)"
|
||||
t_ltc_tn="
|
||||
- $cmdtest_py --coin=ltc --testnet=1 --exclude regtest
|
||||
- $cmdtest_py --coin=ltc --testnet=1
|
||||
- $cmdtest_py --coin=ltc --testnet=1 --segwit
|
||||
- $cmdtest_py --coin=ltc --testnet=1 --segwit-random
|
||||
- $cmdtest_py --coin=ltc --testnet=1 --bech32
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue