minor changes and fixes
This commit is contained in:
parent
840b4d1d43
commit
365e31adb2
4 changed files with 49 additions and 34 deletions
15
mmgen/msg.py
15
mmgen/msg.py
|
|
@ -146,11 +146,11 @@ class coin_msg:
|
|||
def gen_entry(e):
|
||||
for k in labels:
|
||||
if e.get(k):
|
||||
yield fs2.format( labels[k], e[k] )
|
||||
yield fs_sig.format( labels[k], e[k] )
|
||||
|
||||
def gen_all():
|
||||
for k,v in hdr_data.items():
|
||||
yield fs1.format( v[0], v[1](self.data[k]) )
|
||||
yield fs_hdr.format( v[0], v[1](self.data[k]) )
|
||||
if self.sigs:
|
||||
yield ''
|
||||
yield 'Signatures:'
|
||||
|
|
@ -162,7 +162,7 @@ class coin_msg:
|
|||
|
||||
def gen_single():
|
||||
for k,v in hdr_data.items():
|
||||
yield fs1.format( v[0], v[1](self.data[k]) )
|
||||
yield fs_hdr.format( v[0], v[1](self.data[k]) )
|
||||
if self.sigs:
|
||||
yield 'Signature data:'
|
||||
k = (
|
||||
|
|
@ -190,17 +190,16 @@ class coin_msg:
|
|||
if req_addr or not self.data.get('failed_sids'):
|
||||
del hdr_data['failed_sids']
|
||||
|
||||
fs1 = '{:%s} {}' % max(len(v[0]) for v in hdr_data.values())
|
||||
fs2 = '{:%s} %s{}' % (
|
||||
fs_hdr = '{:%s} {}' % max(len(v[0]) for v in hdr_data.values())
|
||||
fs_sig = '%s{:%s} %s{}' % (
|
||||
' ' * (2 if req_addr else 5),
|
||||
max(len(labels[k]) for v in self.sigs.values() for k in v.keys()),
|
||||
self.msg_cls.sigdata_pfx or ''
|
||||
)
|
||||
) if self.sigs else None
|
||||
|
||||
if req_addr:
|
||||
fs2 = ' ' * 2 + fs2
|
||||
return '\n'.join(gen_single())
|
||||
else:
|
||||
fs2 = ' ' * 5 + fs2
|
||||
return (
|
||||
'{}SIGNED MESSAGE DATA:\n\n '.format('' if self.sigs else 'UN') +
|
||||
'\n '.join(gen_all()) )
|
||||
|
|
|
|||
36
test/test.py
36
test/test.py
|
|
@ -113,7 +113,7 @@ opts_data = {
|
|||
debugging only)
|
||||
-e, --exact-output Show the exact output of the MMGen script(s) being run
|
||||
-G, --exclude-groups=G Exclude the specified command groups (comma-separated)
|
||||
-l, --list-cmds List and describe the commands in the test suite
|
||||
-l, --list-cmds List the test script’s available commands
|
||||
-L, --list-cmd-groups Output a list of command groups with descriptions
|
||||
-g, --list-current-cmd-groups List command groups for current configuration
|
||||
-n, --names Display command names instead of descriptions
|
||||
|
|
@ -133,14 +133,16 @@ opts_data = {
|
|||
-u, --usr-random Get random data interactively from user
|
||||
-T, --pexpect-timeout=T Set the timeout for pexpect
|
||||
-v, --verbose Produce more verbose output
|
||||
-W, --no-dw-delete Don't remove default wallet from data dir after dw tests are done
|
||||
-W, --no-dw-delete Don't remove default wallet from data dir after dw tests
|
||||
are done
|
||||
-X, --exit-after=C Exit after command 'C'
|
||||
-y, --segwit Generate and use Segwit addresses
|
||||
-Y, --segwit-random Generate and use a random mix of Segwit and Legacy addrs
|
||||
""",
|
||||
'notes': """
|
||||
|
||||
If no command is given, the whole test suite is run.
|
||||
If no command is given, the whole test suite is run for the currently
|
||||
specified coin (default BTC).
|
||||
"""
|
||||
},
|
||||
'code': {
|
||||
|
|
@ -217,28 +219,37 @@ utils = {
|
|||
}
|
||||
|
||||
def list_cmds():
|
||||
|
||||
def gen_output():
|
||||
|
||||
gm = CmdGroupMgr()
|
||||
cw,d = 0,[]
|
||||
Msg(green('AVAILABLE COMMANDS:'))
|
||||
|
||||
yield green('AVAILABLE COMMANDS:')
|
||||
|
||||
for gname in gm.cmd_groups:
|
||||
ts = gm.gm_init_group(None,gname,None)
|
||||
ts = gm.gm_init_group(None,gname,None,None)
|
||||
desc = ts.__doc__.strip() if ts.__doc__ else type(ts).__name__
|
||||
d.append( (gname,desc,gm.cmd_list,gm.dpy_data) )
|
||||
cw = max(max(len(k) for k in gm.dpy_data),cw)
|
||||
|
||||
for gname,gdesc,clist,dpdata in d:
|
||||
Msg('\n'+green(f'{gname!r} - {gdesc}:'))
|
||||
yield '\n'+green(f'{gname!r} - {gdesc}:')
|
||||
for cmd in clist:
|
||||
data = dpdata[cmd]
|
||||
Msg(' {:{w}} - {}'.format(
|
||||
yield ' {:{w}} - {}'.format(
|
||||
cmd,
|
||||
(data if type(data) == str else data[1]),
|
||||
w = cw ))
|
||||
w = cw )
|
||||
|
||||
w = max(map(len,utils))
|
||||
Msg('\n'+green('AVAILABLE UTILITIES:'))
|
||||
|
||||
yield '\n'+green('AVAILABLE UTILITIES:')
|
||||
|
||||
for cmd in sorted(utils):
|
||||
Msg(' {:{w}} - {}'.format( cmd, utils[cmd], w=w ))
|
||||
yield ' {:{w}} - {}'.format( cmd, utils[cmd], w=w )
|
||||
|
||||
do_pager('\n'.join(gen_output()))
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
|
@ -426,10 +437,13 @@ class CmdGroupMgr(object):
|
|||
for gname in groups:
|
||||
clsname,kwargs = self.cmd_groups[gname]
|
||||
cls = self.load_mod(gname,kwargs['modname'] if 'modname' in kwargs else None)
|
||||
|
||||
if cmd in cls.cmd_group: # first search the class
|
||||
return gname
|
||||
|
||||
if cmd in dir(cls(None,None,None)): # then a throwaway instance
|
||||
return gname # cmd might exist in more than one group - we'll go with the first
|
||||
|
||||
return None
|
||||
|
||||
class TestSuiteRunner(object):
|
||||
|
|
@ -527,10 +541,10 @@ class TestSuiteRunner(object):
|
|||
os.environ['MMGEN_FORCE_COLOR'] = '1' if self.ts.color else ''
|
||||
|
||||
env = { 'EXEC_WRAPPER_SPAWN':'1' }
|
||||
env.update(os.environ)
|
||||
if 'exec_wrapper_init' in globals():
|
||||
# test.py itself is running under exec_wrapper, so disable traceback file writing for spawned script
|
||||
env.update({ 'EXEC_WRAPPER_NO_TRACEBACK':'1' }) # Python 3.9: OR the dicts
|
||||
env.update(os.environ)
|
||||
|
||||
from test.include.pexpect import MMGenPexpect
|
||||
return MMGenPexpect( args, no_output=no_output, env=env )
|
||||
|
|
|
|||
|
|
@ -1284,6 +1284,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
|
|||
|
||||
def bob_msgverify_raw(self):
|
||||
t = self.bob_msgverify(ext='rawmsg.json')
|
||||
t.expect('No signatures')
|
||||
t.req_exit_val = 1
|
||||
return t
|
||||
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ class TestSuiteShared(object):
|
|||
else:
|
||||
t.do_comment(False,has_label=has_label)
|
||||
t.expect('Save signed transaction? (Y/n): ','n')
|
||||
t.expect('not saved')
|
||||
t.req_exit_val = 1
|
||||
return t
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue