f-strings, whitespace (test files) [44 files patched]
This commit is contained in:
parent
2872d4b683
commit
6692a43d59
44 changed files with 431 additions and 341 deletions
|
|
@ -21,18 +21,20 @@ def test_color():
|
|||
ret = get_terminfo_colors(t)
|
||||
if ret == None:
|
||||
set_vt100()
|
||||
ymsg('Warning: unable to get info for terminal {!r}'.format(t))
|
||||
ymsg(f'Warning: unable to get info for terminal {t!r}')
|
||||
continue
|
||||
msg('{}: {}'.format(t,ret))
|
||||
assert c == ret, "'colors' value for terminal {} ({}) does not match expected value of {}".format(t,ret,c)
|
||||
msg(f'{t}: {ret}')
|
||||
assert c == ret, f"'colors' value for terminal {t} ({ret}) does not match expected value of {c}"
|
||||
|
||||
ret = get_terminfo_colors()
|
||||
msg('This terminal ({}): {}'.format(os.getenv('TERM'),ret))
|
||||
msg(f'This terminal ({os.getenv("TERM")}): {ret}')
|
||||
set_vt100()
|
||||
gmsg("Terminal display:")
|
||||
|
||||
for desc,n in (('auto','auto'),('8-color',8),('256-color',256)):
|
||||
init_color(num_colors=n)
|
||||
msg('{:9}: {}'.format(desc,' '.join([globals()[c](c) for c in sorted(_colors)])))
|
||||
msg('{:9}: {}'.format(
|
||||
desc,
|
||||
' '.join(globals()[c](c) for c in sorted(_colors)) ))
|
||||
|
||||
test_color()
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ class GenToolPycoin(GenTool):
|
|||
network = self.nfnc(vcoin)
|
||||
key = network.keys.private(secret_exponent=int(sec,16),is_compressed=addr_type.name != 'legacy')
|
||||
if key is None:
|
||||
die(1,"can't parse {}".format(sec))
|
||||
die(1,f'can’t parse {sec}')
|
||||
if addr_type.name in ('segwit','bech32'):
|
||||
hash160_c = key.hash160(is_compressed=True)
|
||||
if addr_type.name == 'segwit':
|
||||
|
|
@ -214,7 +214,7 @@ class GenToolMoneropy(GenTool):
|
|||
def get_tool(arg):
|
||||
|
||||
if arg not in ext_progs + ['ext']:
|
||||
die(1,'{!r}: unsupported tool for network {}'.format(arg,proto.network))
|
||||
die(1,f'{arg!r}: unsupported tool for network {proto.network}')
|
||||
|
||||
if opt.all:
|
||||
if arg == 'ext':
|
||||
|
|
@ -268,7 +268,7 @@ def gentool_test(kg_a,kg_b,ag,rounds):
|
|||
def do_compare_test(n,trounds,in_bytes):
|
||||
global last_t
|
||||
if opt.verbose or time.time() - last_t >= 0.1:
|
||||
qmsg_r('\rRound {}/{} '.format(i+1,trounds))
|
||||
qmsg_r(f'\rRound {i+1}/{trounds} ')
|
||||
last_t = time.time()
|
||||
sec = PrivKey(proto,in_bytes,compressed=addr_type.compressed,pubkey_type=addr_type.pubkey_type)
|
||||
a_ph = kg_a.to_pubhex(sec)
|
||||
|
|
@ -286,7 +286,7 @@ def gentool_test(kg_a,kg_b,ag,rounds):
|
|||
b_addr = ag.to_addr(kg_b.to_pubhex(sec))
|
||||
test_equal('addresses',a_addr,b_addr,*tinfo)
|
||||
vmsg(fs.format(b=in_bytes.hex(),k=sec.wif,v=a_vk,a=a_addr))
|
||||
qmsg_r('\rRound {}/{} '.format(n+1,trounds))
|
||||
qmsg_r(f'\rRound {n+1}/{trounds} ')
|
||||
|
||||
fs = ( '\ninput: {b}\n%-9s {k}\naddr: {a}\n',
|
||||
'\ninput: {b}\n%-9s {k}\nviewkey: {v}\naddr: {a}\n')[
|
||||
|
|
@ -317,37 +317,39 @@ def speed_test(kg,ag,rounds):
|
|||
from struct import pack,unpack
|
||||
seed = os.urandom(28)
|
||||
qmsg('Incrementing key with each round')
|
||||
qmsg('Starting key: {}'.format((seed + pack('I',0)).hex()))
|
||||
qmsg('Starting key: {}'.format(
|
||||
(seed + pack('I',0)).hex()
|
||||
))
|
||||
import time
|
||||
start = last_t = time.time()
|
||||
|
||||
for i in range(rounds):
|
||||
if time.time() - last_t >= 0.1:
|
||||
qmsg_r('\rRound {}/{} '.format(i+1,rounds))
|
||||
qmsg_r(f'\rRound {i+1}/{rounds} ')
|
||||
last_t = time.time()
|
||||
sec = PrivKey(proto,seed+pack('I',i),compressed=addr_type.compressed,pubkey_type=addr_type.pubkey_type)
|
||||
addr = ag.to_addr(kg.to_pubhex(sec))
|
||||
vmsg('\nkey: {}\naddr: {}\n'.format(sec.wif,addr))
|
||||
qmsg_r('\rRound {}/{} '.format(i+1,rounds))
|
||||
qmsg('\n{} addresses generated in {:.2f} seconds'.format(rounds,time.time()-start))
|
||||
vmsg(f'\nkey: {sec.wif}\naddr: {addr}\n')
|
||||
qmsg_r(f'\rRound {i+1}/{rounds} ')
|
||||
qmsg(f'\n{rounds} addresses generated in {time.time()-start:.2f} seconds')
|
||||
|
||||
def dump_test(kg,ag,fh):
|
||||
|
||||
dump = [[*(e.split()[0] for e in line.split('addr='))] for line in fh.readlines() if 'addr=' in line]
|
||||
if not dump:
|
||||
die(1,'File {!r} appears not to be a wallet dump'.format(fh.name))
|
||||
die(1,f'File {fh.name!r} appears not to be a wallet dump')
|
||||
|
||||
m = 'Comparing output of address generator {!r} against wallet dump {!r}'
|
||||
qmsg(green(m.format(kg.desc,fh.name)))
|
||||
|
||||
for count,(b_wif,b_addr) in enumerate(dump,1):
|
||||
qmsg_r('\rKey {}/{} '.format(count,len(dump)))
|
||||
qmsg_r(f'\rKey {count}/{len(dump)} ')
|
||||
try:
|
||||
b_sec = PrivKey(proto,wif=b_wif)
|
||||
except:
|
||||
die(2,'\nInvalid {} WIF address in dump file: {}'.format(proto.network,b_wif))
|
||||
die(2,f'\nInvalid {proto.network} WIF address in dump file: {b_wif}')
|
||||
a_addr = ag.to_addr(kg.to_pubhex(b_sec))
|
||||
vmsg('\nwif: {}\naddr: {}\n'.format(b_wif,b_addr))
|
||||
vmsg(f'\nwif: {b_wif}\naddr: {b_addr}\n')
|
||||
tinfo = (bytes.fromhex(b_sec),b_sec,b_wif,kg.desc,fh.name)
|
||||
test_equal('addresses',a_addr,b_addr,*tinfo)
|
||||
qmsg(green(('\n','')[bool(opt.verbose)] + 'OK'))
|
||||
|
|
@ -362,7 +364,7 @@ def parse_arg1(arg,arg_id):
|
|||
|
||||
def check_gen_num(n):
|
||||
if not (1 <= int(n) <= len(g.key_generators)):
|
||||
die(1,'{}: invalid generator ID'.format(n))
|
||||
die(1,f'{n}: invalid generator ID')
|
||||
return int(n)
|
||||
|
||||
if arg_id == 'a':
|
||||
|
|
@ -432,7 +434,7 @@ elif a and b and type(arg2) == int:
|
|||
init_genonly_altcoins(testnet=proto.testnet)
|
||||
for coin in ci.external_tests[proto.network][b.desc]:
|
||||
if coin.lower() not in CoinProtocol.coins:
|
||||
# ymsg('Coin {} not configured'.format(coin))
|
||||
# ymsg(f'Coin {coin} not configured')
|
||||
continue
|
||||
proto = init_proto(coin)
|
||||
if addr_type not in proto.mmtypes:
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class TestHashFunc(object):
|
|||
'\x00\x0f'*1024,'\x0e\x0f'*1023,'\x0a\x0d'*1025 )
|
||||
|
||||
for i,data in enumerate([inputs[input_n]] if input_n is not None else inputs):
|
||||
msg('\rTesting reference input data: {:4}/{} '.format(i+1,len(inputs)))
|
||||
msg(f'\rTesting reference input data: {i+1:4}/{len(inputs)} ')
|
||||
self.compare_hashes(len(data),data.encode())
|
||||
|
||||
msg('OK\n')
|
||||
|
|
@ -75,7 +75,7 @@ class TestHashFunc(object):
|
|||
def test_random(self,rounds):
|
||||
for i in range(rounds):
|
||||
if i+1 in (1,rounds) or not (i+1) % 10:
|
||||
msg('\rTesting random input data: {:4}/{} '.format(i+1,rounds))
|
||||
msg(f'\rTesting random input data: {i+1:4}/{rounds} ')
|
||||
dlen = int(os.urandom(4).hex(),16) >> 18
|
||||
self.compare_hashes(dlen,os.urandom(dlen))
|
||||
msg('OK\n')
|
||||
|
|
@ -136,7 +136,7 @@ class TestSha512(TestSha2):
|
|||
0x431d67c49c100d4c, 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817 )
|
||||
|
||||
t = globals()['Test'+test]()
|
||||
msg('Testing internal implementation of {}\n'.format(t.desc))
|
||||
msg(f'Testing internal implementation of {t.desc}\n')
|
||||
t.test_constants()
|
||||
t.test_ref()
|
||||
t.test_random(random_rounds)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ action = g.prog_name.split('-')[0]
|
|||
opts_data = {
|
||||
'sets': [('debug',True,'verbose',True)],
|
||||
'text': {
|
||||
'desc': '{} coin daemons for the MMGen test suite'.format(action.capitalize()),
|
||||
'desc': f'{action.capitalize()} coin daemons for the MMGen test suite',
|
||||
'usage':'[opts] <network IDs>',
|
||||
'options': """
|
||||
-h, --help Print this help message
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ def cleandir(d,do_msg=False):
|
|||
except: return
|
||||
|
||||
from shutil import rmtree
|
||||
if do_msg: gmsg("Cleaning directory '{}'".format(d))
|
||||
if do_msg:
|
||||
gmsg(f'Cleaning directory {d!r}')
|
||||
for f in files:
|
||||
try:
|
||||
os.unlink(os.path.join(d_enc,f))
|
||||
|
|
@ -110,7 +111,7 @@ def mk_tmpdir(d):
|
|||
except OSError as e:
|
||||
if e.errno != 17: raise
|
||||
else:
|
||||
vmsg("Created directory '{}'".format(d))
|
||||
vmsg(f'Created directory {d!r}')
|
||||
|
||||
def get_tmpfile(cfg,fn):
|
||||
return os.path.join(cfg['tmpdir'],fn)
|
||||
|
|
@ -143,9 +144,10 @@ def ok():
|
|||
|
||||
def cmp_or_die(s,t,desc=None):
|
||||
if s != t:
|
||||
m = 'ERROR: recoded data:\n{!r}\ndiffers from original data:\n{!r}'
|
||||
if desc: m = 'For {}:\n{}'.format(desc,m)
|
||||
raise TestSuiteFatalException(m.format(t,s))
|
||||
raise TestSuiteFatalException(
|
||||
(f'For {desc}:\n' if desc else '') +
|
||||
f'ERROR: recoded data:\n{t!r}\ndiffers from original data:\n{s!r}'
|
||||
)
|
||||
|
||||
def init_coverage():
|
||||
coverdir = os.path.join('test','trace')
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ try:
|
|||
import pexpect
|
||||
from pexpect.popen_spawn import PopenSpawn
|
||||
except ImportError as e:
|
||||
die(2,red('Pexpect module is missing. Cannnot run test suite ({!r})'.format(e)))
|
||||
die(2,red(f'Pexpect module is missing. Cannnot run test suite ({e!r})'))
|
||||
|
||||
def debug_pexpect_msg(p):
|
||||
if opt.debug_pexpect:
|
||||
msg('\n{}{}{}'.format(red('BEFORE ['),p.before,red(']')))
|
||||
msg('{}{}{}'.format(red('MATCH ['),p.after,red(']')))
|
||||
msg('\n{}{}{}'.format( red('BEFORE ['), p.before, red(']') ))
|
||||
msg('{}{}{}'.format( red('MATCH ['), p.after, red(']') ))
|
||||
|
||||
NL = '\n'
|
||||
|
||||
|
|
@ -75,14 +75,14 @@ class MMGenPexpect(object):
|
|||
|
||||
def do_comment(self,add_comment,has_label=False):
|
||||
p = ('Add a comment to transaction','Edit transaction comment')[has_label]
|
||||
self.expect('{}? (y/N): '.format(p),('n','y')[bool(add_comment)])
|
||||
self.expect(f'{p}? (y/N): ',('n','y')[bool(add_comment)])
|
||||
if add_comment:
|
||||
self.expect('Comment: ',add_comment+'\n')
|
||||
|
||||
def ok(self):
|
||||
ret = self.p.wait()
|
||||
if ret != self.req_exit_val and not opt.coverage:
|
||||
die(1,red('test.py: spawned program exited with value {}'.format(ret)))
|
||||
die(1,red(f'test.py: spawned program exited with value {ret}'))
|
||||
if opt.profile:
|
||||
return
|
||||
if not self.skip_ok:
|
||||
|
|
@ -110,19 +110,19 @@ class MMGenPexpect(object):
|
|||
self.expect('ENTER to continue: ','\n')
|
||||
|
||||
def passphrase_new(self,desc,passphrase):
|
||||
self.expect('Enter passphrase for {}: '.format(desc),passphrase+'\n')
|
||||
self.expect(f'Enter passphrase for {desc}: ',passphrase+'\n')
|
||||
self.expect('Repeat passphrase: ',passphrase+'\n')
|
||||
|
||||
def passphrase(self,desc,passphrase,pwtype=''):
|
||||
if pwtype: pwtype += ' '
|
||||
self.expect('Enter {}passphrase for {}.*?: '.format(pwtype,desc),passphrase+'\n',regex=True)
|
||||
self.expect(f'Enter {pwtype}passphrase for {desc}.*?: ',passphrase+'\n',regex=True)
|
||||
|
||||
def hash_preset(self,desc,preset=''):
|
||||
self.expect('Enter hash preset for {}'.format(desc))
|
||||
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):
|
||||
s1 = '{} written to file '.format(desc)
|
||||
s1 = f'{desc} written to file '
|
||||
s2 = query + "Type uppercase 'YES' to confirm: "
|
||||
ret = self.expect(([s1,s2],s1)[overwrite_unlikely])
|
||||
if ret == 1:
|
||||
|
|
@ -131,8 +131,8 @@ class MMGenPexpect(object):
|
|||
self.expect(NL,nonl=True)
|
||||
outfile = self.p.before.strip().strip("'")
|
||||
if opt.debug_pexpect:
|
||||
rmsg('Outfile [{}]'.format(outfile))
|
||||
vmsg('{} file: {}'.format(desc,cyan(outfile.replace("'",''))))
|
||||
rmsg(f'Outfile [{outfile}]')
|
||||
vmsg('{} file: {}'.format( desc, cyan(outfile.replace('"',"")) ))
|
||||
return outfile
|
||||
|
||||
def hincog_create(self,hincog_bytes):
|
||||
|
|
@ -156,7 +156,7 @@ class MMGenPexpect(object):
|
|||
debug_pexpect_msg(self.p)
|
||||
end = self.p.before.rstrip()
|
||||
if not g.debug:
|
||||
vmsg(' ==> {}'.format(cyan(end)))
|
||||
vmsg(f' ==> {cyan(end)}')
|
||||
return end
|
||||
|
||||
def interactive(self):
|
||||
|
|
@ -181,18 +181,18 @@ class MMGenPexpect(object):
|
|||
ret = f(s)
|
||||
except pexpect.TIMEOUT:
|
||||
if opt.debug_pexpect: raise
|
||||
m1 = red('\nERROR. Expect {!r} timed out. Exiting\n'.format(s))
|
||||
m2 = 'before: [{}]\n'.format(self.p.before)
|
||||
m3 = 'sent value: [{}]'.format(self.sent_value) if self.sent_value != None else ''
|
||||
m1 = red(f'\nERROR. Expect {s!r} timed out. Exiting\n')
|
||||
m2 = f'before: [{self.p.before}]\n'
|
||||
m3 = f'sent value: [{self.sent_value}]' if self.sent_value != None else ''
|
||||
rdie(1,m1+m2+m3)
|
||||
|
||||
debug_pexpect_msg(self.p)
|
||||
|
||||
if opt.verbose and type(s) != str:
|
||||
msg_r(' ==> {} '.format(ret))
|
||||
msg_r(f' ==> {ret} ')
|
||||
|
||||
if ret == -1:
|
||||
rdie(1,'Error. Expect returned {}'.format(ret))
|
||||
rdie(1,f'Error. Expect returned {ret}')
|
||||
else:
|
||||
if t == '':
|
||||
if not nonl and not silent: vmsg('')
|
||||
|
|
@ -209,9 +209,10 @@ class MMGenPexpect(object):
|
|||
self.sent_value = t
|
||||
if delay: time.sleep(delay)
|
||||
if opt.verbose:
|
||||
ls = (' ','')[bool(opt.debug or not s)]
|
||||
es = (' ','')[bool(s)]
|
||||
msg('{}SEND {}{}'.format(ls,es,yellow("'{}'".format(t.replace('\n',r'\n')))))
|
||||
ls = '' if opt.debug or not s else ' '
|
||||
es = '' if s else ' '
|
||||
yt = yellow('{!r}'.format( t.replace('\n',r'\n') ))
|
||||
msg(f'{ls}SEND {es}{yt}')
|
||||
return ret
|
||||
|
||||
def read(self,n=-1):
|
||||
|
|
|
|||
|
|
@ -11,24 +11,24 @@ cf_usr = cfg_file('usr')
|
|||
cf_sys = cfg_file('sys')
|
||||
cf_sample = cfg_file('sample')
|
||||
|
||||
msg('Usr cfg file: {}'.format(cf_usr.fn))
|
||||
msg('Sys cfg file: {}'.format(cf_sys.fn))
|
||||
msg('Sample cfg file: {}'.format(cf_sample.fn))
|
||||
msg(f'Usr cfg file: {cf_usr.fn}')
|
||||
msg(f'Sys cfg file: {cf_sys.fn}')
|
||||
msg(f'Sample cfg file: {cf_sample.fn}')
|
||||
|
||||
if cmd_args:
|
||||
if cmd_args[0] == 'parse_test':
|
||||
ps = cf_sample.get_lines()
|
||||
msg('parsed chunks: {}'.format(len(ps)))
|
||||
msg(f'parsed chunks: {len(ps)}')
|
||||
pu = cf_usr.get_lines()
|
||||
msg('usr cfg: {}'.format(' '.join(['{}={}'.format(i.name,i.value) for i in pu])))
|
||||
msg('usr cfg: {}'.format( ' '.join(f'{i.name}={i.value}' for i in pu) ))
|
||||
elif cmd_args[0] == 'coin_specific_vars':
|
||||
from mmgen.protocol import init_proto_from_opts
|
||||
proto = init_proto_from_opts()
|
||||
for varname in cmd_args[1:]:
|
||||
print('{}.{}: {}'.format(
|
||||
msg('{}.{}: {}'.format(
|
||||
type(proto).__name__,
|
||||
varname,
|
||||
getattr(proto,varname)
|
||||
))
|
||||
elif cmd_args[0] == 'mnemonic_entry_modes':
|
||||
print( 'mnemonic_entry_modes: {}'.format(g.mnemonic_entry_modes) )
|
||||
msg( 'mnemonic_entry_modes: {}'.format(g.mnemonic_entry_modes) )
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ opts_data = {
|
|||
},
|
||||
'code': {
|
||||
'options': lambda s: s.format(
|
||||
kgs=' '.join(['{}:{}'.format(n,k) for n,k in enumerate(g.key_generators,1)]),
|
||||
kgs=' '.join([f'{n}:{k}' for n,k in enumerate(g.key_generators,1)]),
|
||||
kg=g.key_generator,
|
||||
g=g,
|
||||
),
|
||||
|
|
@ -61,11 +61,11 @@ for k in (
|
|||
'key_generator', # global_sets_opt
|
||||
'hidden_incog_input_params',
|
||||
):
|
||||
msg('{:30} {}'.format('opt.'+k+':',getattr(opt,k)))
|
||||
msg('{:30} {}'.format( f'opt.{k}:', getattr(opt,k) ))
|
||||
|
||||
msg('')
|
||||
for k in (
|
||||
'subseeds', # opt_sets_global
|
||||
'key_generator', # global_sets_opt
|
||||
):
|
||||
msg('{:30} {}'.format('g.'+k+':',getattr(opt,k)))
|
||||
msg('{:30} {}'.format( f'g.{k}:', getattr(opt,k) ))
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ def tt_my_raw_input():
|
|||
"""))
|
||||
get_char_raw('Ready? ',num_chars=1)
|
||||
reply = my_raw_input('\nEnter text: ')
|
||||
confirm('Did you enter the text {!r}?'.format(reply))
|
||||
confirm(f'Did you enter the text {reply!r}?')
|
||||
|
||||
def tt_get_char(raw=False,one_char=False,sleep=0,immed_chars=''):
|
||||
fname = ('get_char','get_char_raw')[raw]
|
||||
|
|
@ -81,11 +81,11 @@ def tt_get_char(raw=False,one_char=False,sleep=0,immed_chars=''):
|
|||
)[raw]
|
||||
m2 = (
|
||||
'',
|
||||
'\nA delay of {} seconds will added before each prompt'.format(sleep)
|
||||
f'\nA delay of {sleep} seconds will added before each prompt'
|
||||
)[bool(sleep)]
|
||||
m3 = (
|
||||
'',
|
||||
'\nThe characters {!r} will be repeated immediately, the others with delay.'.format(immed_chars)
|
||||
f'\nThe characters {immed_chars!r} will be repeated immediately, the others with delay.'
|
||||
)[bool(immed_chars)]
|
||||
m4 = 'The F1-F12 keys will be ' + (
|
||||
'blocked entirely.'
|
||||
|
|
@ -104,13 +104,16 @@ def tt_get_char(raw=False,one_char=False,sleep=0,immed_chars=''):
|
|||
if immed_chars:
|
||||
kwargs.update({'immed_chars':immed_chars})
|
||||
|
||||
cmsg('Testing {}({}):'.format(fname,','.join(['{}={!r}'.format(*i) for i in kwargs.items()])))
|
||||
msg(fs.format(m1,yellow(m2),yellow(m3),yellow(m4)))
|
||||
cmsg('Testing {}({}):'.format(
|
||||
fname,
|
||||
','.join(f'{a}={b!r}' for a,b in kwargs.items())
|
||||
))
|
||||
msg(fs.format( m1, yellow(m2), yellow(m3), yellow(m4) ))
|
||||
|
||||
try:
|
||||
while True:
|
||||
ret = globals()[fname]('Enter a letter: ',**kwargs)
|
||||
msg('You typed {!r}'.format(ret))
|
||||
msg(f'You typed {ret!r}')
|
||||
except KeyboardInterrupt:
|
||||
msg('\nDone')
|
||||
|
||||
|
|
@ -118,14 +121,13 @@ def tt_urand():
|
|||
cmsg('Testing _get_random_data_from_user():')
|
||||
from mmgen.crypto import _get_random_data_from_user
|
||||
ret = _get_random_data_from_user(10,desc='data').decode()
|
||||
msg('USER ENTROPY (user input + keystroke timings):\n\n{}'.format(fmt(ret,' ')))
|
||||
msg(f'USER ENTROPY (user input + keystroke timings):\n\n{fmt(ret," ")}')
|
||||
times = ret.splitlines()[1:]
|
||||
avg_prec = sum(len(t.split('.')[1]) for t in times) // len(times)
|
||||
if avg_prec < g.min_time_precision:
|
||||
m = 'WARNING: Avg. time precision of only {} decimal points. User entropy quality is degraded!'
|
||||
ymsg(m.format(avg_prec))
|
||||
ymsg(f'WARNING: Avg. time precision of only {avg_prec} decimal points. User entropy quality is degraded!')
|
||||
else:
|
||||
msg('Average time precision: {} decimal points - OK'.format(avg_prec))
|
||||
msg(f'Average time precision: {avg_prec} decimal points - OK')
|
||||
my_raw_input('Press ENTER to continue: ')
|
||||
|
||||
def tt_txview():
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ def get_descriptor_obj(objclass,attrname):
|
|||
for o in (objclass,objclass.__bases__[0]): # assume there's only one base class
|
||||
if attrname in o.__dict__:
|
||||
return o.__dict__[attrname]
|
||||
rdie(3,'unable to find descriptor {}.{}'.format(objclass.__name__,attrname))
|
||||
rdie(3,f'unable to find descriptor {objclass.__name__}.{attrname}')
|
||||
|
||||
def test_attr_perm(obj,attrname,perm_name,perm_value,dobj,attrval_type):
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ def test_attr_perm(obj,attrname,perm_name,perm_value,dobj,attrval_type):
|
|||
try:
|
||||
so = sample_objs[attrval_type.__name__]
|
||||
except:
|
||||
raise SampleObjError('unable to find sample object of type {!r}'.format(attrval_type.__name__))
|
||||
raise SampleObjError(f'unable to find sample object of type {attrval_type.__name__!r}')
|
||||
# ListItemAttr allows setting an attribute if its value is None
|
||||
if type(dobj) == ListItemAttr and getattr(obj,attrname) == None:
|
||||
setattr(obj,attrname,so)
|
||||
|
|
@ -89,7 +89,7 @@ def test_attr_perm(obj,attrname,perm_name,perm_value,dobj,attrval_type):
|
|||
elif perm_name == 'delete_ok':
|
||||
delattr(obj,attrname)
|
||||
except SampleObjError as e:
|
||||
rdie(2,'Test script error ({})'.format(e))
|
||||
rdie(2,f'Test script error ({e})')
|
||||
except Exception as e:
|
||||
if perm_value == True:
|
||||
fs = '{!r}: unable to {} attribute {!r}, though {}ing is allowed ({})'
|
||||
|
|
@ -116,12 +116,12 @@ def test_attr(data,obj,attrname,dobj,bits,attrval_type):
|
|||
fs = 'init value {iv}={a} for attr {n!r} does not match test data ({iv}={b})'
|
||||
rdie(2,fs.format(iv=k,n=attrname,a=d[k],b=bits[k]))
|
||||
if opt.verbose and d[k] == True:
|
||||
msg_r(' {}={!r}'.format(k,d[k]))
|
||||
msg_r(f' {k}={d[k]!r}')
|
||||
|
||||
if opt.show_nonstandard_init:
|
||||
for k,v in (('typeconv',False),('set_none_ok',True)):
|
||||
if d[k] == v:
|
||||
msg_r(' {}={}'.format(k,v))
|
||||
msg_r(f' {k}={v}')
|
||||
|
||||
def test_object(test_data,objname):
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ def run_test(test,arg,input_data,arg1,exc_name):
|
|||
try:
|
||||
if not opt.super_silent:
|
||||
arg_disp = repr(arg_copy[0] if type(arg_copy) == tuple else arg_copy)
|
||||
msg_r((orange,green)[input_data=='good']('{:<22}'.format(arg_disp+':')))
|
||||
msg_r((green if input_data=='good' else orange)(f'{arg_disp+":":<22}'))
|
||||
cls = globals()[test]
|
||||
|
||||
if opt.getobj:
|
||||
|
|
|
|||
|
|
@ -91,17 +91,17 @@ passwd_data = {
|
|||
'xmrseed_dfl_αω':td('62f5b72a5ca89cab', 'xmrseed:25:αω','-αω-xmrseed-25','αω xmrseed:25','tequila eden skulls giving jester hospital dreams bakery adjust nanny cactus inwardly films amply nanny soggy vials muppet yellow woken ashtray organs exhale foes eden'),
|
||||
}
|
||||
|
||||
cvr_opts = ' -m trace --count --coverdir={} --file={}'.format(*init_coverage()) if opt.coverage else ''
|
||||
cmd_base = 'python3{} cmds/mmgen-{{}}gen -qS'.format(cvr_opts)
|
||||
cvr_opts = ' -m trace --count --coverdir={} --file={}'.format( *init_coverage() ) if opt.coverage else ''
|
||||
cmd_base = f'python3{cvr_opts} cmds/mmgen-{{}}gen -qS'
|
||||
|
||||
def get_cmd_output(cmd):
|
||||
cp = run(cmd.split(),stdout=PIPE,stderr=PIPE)
|
||||
if cp.returncode != 0:
|
||||
ydie(2,'\nSpawned program exited with error code {}:\n{}'.format(cp.returncode,cp.stderr.decode()))
|
||||
ydie(2,f'\nSpawned program exited with error code {cp.returncode}:\n{cp.stderr.decode()}')
|
||||
return cp.stdout.decode().splitlines()
|
||||
|
||||
def do_test(cmd,tdata,msg_str,addr_desc):
|
||||
vmsg(green('Executing: {}'.format(cmd)))
|
||||
vmsg(green(f'Executing: {cmd}'))
|
||||
msg_r('Testing: ' + msg_str)
|
||||
|
||||
lines = get_cmd_output(cmd)
|
||||
|
|
@ -113,9 +113,9 @@ def do_test(cmd,tdata,msg_str,addr_desc):
|
|||
for k in ref_data:
|
||||
if cmd_out[k] == ref_data[k]:
|
||||
s = k.replace('seed','seed[:8]').replace('addr',addr_desc)
|
||||
vmsg(' {:9}: {}'.format(s,cmd_out[k]))
|
||||
vmsg(f' {s:9}: {cmd_out[k]}')
|
||||
else:
|
||||
rdie(1,'\nError: sc_{} value {} does not match reference value {}'.format(k,cmd_out[k],ref_data[k]))
|
||||
rdie(1,f'\nError: sc_{k} value {cmd_out[k]} does not match reference value {ref_data[k]}')
|
||||
msg('OK')
|
||||
|
||||
def do_coin_tests():
|
||||
|
|
@ -126,15 +126,15 @@ def do_coin_tests():
|
|||
continue
|
||||
coin,mmtype = tname.split('_',1) if '_' in tname else (tname,None)
|
||||
type_arg = ' --type='+mmtype if mmtype else ''
|
||||
cmd = cmd_base.format('addr') + ' --coin={}{} test/ref/98831F3A.mmwords 1'.format(coin,type_arg)
|
||||
do_test(cmd,tdata,'--coin {:4} {:22}'.format(coin.upper(),type_arg),'address')
|
||||
cmd = cmd_base.format('addr') + f' --coin={coin}{type_arg} test/ref/98831F3A.mmwords 1'
|
||||
do_test(cmd,tdata,f'--coin {coin.upper():4} {type_arg:22}','address')
|
||||
|
||||
def do_passwd_tests():
|
||||
bmsg('Testing password scramble strings and list IDs')
|
||||
for tname,tdata in passwd_data.items():
|
||||
a,b,pwid = tname.split('_')
|
||||
fmt_arg = '' if a == 'dfl' else '--passwd-fmt={} '.format(a)
|
||||
len_arg = '' if b == 'dfl' else '--passwd-len={} '.format(b)
|
||||
fmt_arg = '' if a == 'dfl' else f'--passwd-fmt={a} '
|
||||
len_arg = '' if b == 'dfl' else f'--passwd-len={b} '
|
||||
fs = '{}' + fmt_arg + len_arg + '{}' + pwid + ' 1'
|
||||
cmd = cmd_base.format('pass') + ' ' + fs.format('--accept-defaults ','test/ref/98831F3A.mmwords ')
|
||||
s = fs.format('','')
|
||||
|
|
|
|||
124
test/test.py
124
test/test.py
|
|
@ -40,7 +40,7 @@ def create_shm_dir(data_dir,trash_dir):
|
|||
try:
|
||||
run(['python3',os.path.join('cmds','mmgen-regtest'),'stop'],check=True)
|
||||
except:
|
||||
rdie(1,"Unable to remove {!r}!".format(tdir))
|
||||
rdie(1,f'Unable to remove {tdir!r}!')
|
||||
else:
|
||||
time.sleep(2)
|
||||
shutil.rmtree(tdir)
|
||||
|
|
@ -49,14 +49,14 @@ def create_shm_dir(data_dir,trash_dir):
|
|||
else:
|
||||
tdir,pfx = '/dev/shm','mmgen-test-'
|
||||
try:
|
||||
run('rm -rf {}/{}*'.format(tdir,pfx),shell=True,check=True)
|
||||
run(f'rm -rf {tdir}/{pfx}*',shell=True,check=True)
|
||||
except Exception as e:
|
||||
die(2,'Unable to delete directory tree {}/{}* ({})'.format(tdir,pfx,e.args[0]))
|
||||
die(2,f'Unable to delete directory tree {tdir}/{pfx}* ({e.args[0]})')
|
||||
try:
|
||||
import tempfile
|
||||
shm_dir = str(tempfile.mkdtemp('',pfx,tdir))
|
||||
except Exception as e:
|
||||
die(2,'Unable to create temporary directory in {} ({})'.format(tdir,e.args[0]))
|
||||
die(2,f'Unable to create temporary directory in {tdir} ({e.args[0]})')
|
||||
|
||||
dest = os.path.join(shm_dir,os.path.basename(trash_dir))
|
||||
os.mkdir(dest,0o755)
|
||||
|
|
@ -164,7 +164,9 @@ def add_cmdline_opts():
|
|||
sys.argv.insert(1,'--data-dir=' + data_dir)
|
||||
sys.argv.insert(1,'--daemon-data-dir=test/daemons/' + get_coin())
|
||||
from mmgen.daemon import CoinDaemon
|
||||
sys.argv.insert(1,'--rpc-port={}'.format(CoinDaemon(network_id,test_suite=True).rpc_port))
|
||||
sys.argv.insert(1,'--rpc-port={}'.format(
|
||||
CoinDaemon(network_id,test_suite=True).rpc_port
|
||||
))
|
||||
|
||||
# add_cmdline_opts()
|
||||
|
||||
|
|
@ -374,7 +376,7 @@ def fixup_cfgs():
|
|||
cfgs['2'+k].update(cfgs[k])
|
||||
|
||||
for k in cfgs:
|
||||
cfgs[k]['tmpdir'] = os.path.join('test','tmp{}'.format(k))
|
||||
cfgs[k]['tmpdir'] = os.path.join('test',f'tmp{k}')
|
||||
cfgs[k]['segwit'] = randbool() if opt.segwit_random else bool(opt.segwit or opt.bech32)
|
||||
|
||||
from copy import deepcopy
|
||||
|
|
@ -402,15 +404,18 @@ def list_cmds():
|
|||
cw = max(max(len(k) for k in gm.dpy_data),cw)
|
||||
|
||||
for gname,gdesc,clist,dpdata in d:
|
||||
Msg('\n'+green('{!r} - {}:'.format(gname,gdesc)))
|
||||
Msg('\n'+green(f'{gname!r} - {gdesc}:'))
|
||||
for cmd in clist:
|
||||
data = dpdata[cmd]
|
||||
Msg(' {:{w}} - {}'.format(cmd,data if type(data) == str else data[1],w=cw))
|
||||
Msg(' {:{w}} - {}'.format(
|
||||
cmd,
|
||||
(data if type(data) == str else data[1]),
|
||||
w = cw ))
|
||||
|
||||
w = max(map(len,utils))
|
||||
Msg('\n'+green('AVAILABLE UTILITIES:'))
|
||||
for cmd in sorted(utils):
|
||||
Msg(' {:{w}} - {}'.format(cmd,utils[cmd],w=w))
|
||||
Msg(' {:{w}} - {}'.format( cmd, utils[cmd], w=w ))
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
|
@ -433,12 +438,15 @@ def clean(usr_dirs=None):
|
|||
if d in all_dirs:
|
||||
cleandir(all_dirs[d])
|
||||
else:
|
||||
die(1,'{}: invalid directory number'.format(d))
|
||||
die(1,f'{d}: invalid directory number')
|
||||
if dirlist:
|
||||
iqmsg(green('Cleaned tmp director{} {}'.format(suf(dirlist,'ies'),' '.join(dirlist))))
|
||||
iqmsg(green('Cleaned tmp director{} {}'.format(
|
||||
suf(dirlist,'ies'),
|
||||
' '.join(dirlist))
|
||||
))
|
||||
cleandir(data_dir)
|
||||
cleandir(trash_dir)
|
||||
iqmsg(green("Cleaned directories '{}'".format("' '".join([data_dir,trash_dir]))))
|
||||
iqmsg(green(f'Cleaned directories {data_dir!r} {trash_dir!r}'))
|
||||
|
||||
def create_tmp_dirs(shm_dir):
|
||||
if g.platform == 'win':
|
||||
|
|
@ -530,7 +538,7 @@ class CmdGroupMgr(object):
|
|||
if modname == None and 'modname' in kwargs:
|
||||
modname = kwargs['modname']
|
||||
import importlib
|
||||
modpath = 'test.test_py_d.ts_{}'.format(modname or gname)
|
||||
modpath = f'test.test_py_d.ts_{modname or gname}'
|
||||
return getattr(importlib.import_module(modpath),clsname)
|
||||
|
||||
def create_group(self,gname,full_data=False,modname=None,is3seed=False,add_dpy=False):
|
||||
|
|
@ -557,14 +565,14 @@ class CmdGroupMgr(object):
|
|||
for a,b in cls.cmd_group:
|
||||
if is3seed:
|
||||
for n,(i,j) in enumerate(zip(cls.tmpdir_nums,(128,192,256))):
|
||||
k = '{}_{}'.format(a,n+1)
|
||||
k = f'{a}_{n+1}'
|
||||
if hasattr(cls,'skip_cmds') and k in cls.skip_cmds:
|
||||
continue
|
||||
sdeps = get_shared_deps(k,i)
|
||||
if type(b) == str:
|
||||
cdata.append( (k, (i,'{} ({}-bit)'.format(b,j),[[[]+sdeps,i]])) )
|
||||
cdata.append( (k, (i,f'{b} ({j}-bit)',[[[]+sdeps,i]])) )
|
||||
else:
|
||||
cdata.append( (k, (i,'{} ({}-bit)'.format(b[1],j),[[b[0]+sdeps,i]])) )
|
||||
cdata.append( (k, (i,f'{b[1]} ({j}-bit)',[[b[0]+sdeps,i]])) )
|
||||
else:
|
||||
cdata.append( (a, b if full_data else (cls.tmpdir_nums[0],b,[[[],cls.tmpdir_nums[0]]])) )
|
||||
|
||||
|
|
@ -597,7 +605,7 @@ class CmdGroupMgr(object):
|
|||
and g[0] in tuple(self.cmd_groups_dfl) + tuple(usr_args) ]
|
||||
|
||||
for name,cls in ginfo:
|
||||
msg('{:17} - {}'.format(name,cls.__doc__))
|
||||
msg(f'{name:17} - {cls.__doc__}')
|
||||
|
||||
Die(0,'\n'+' '.join(e[0] for e in ginfo))
|
||||
|
||||
|
|
@ -608,7 +616,7 @@ class CmdGroupMgr(object):
|
|||
"""
|
||||
if group:
|
||||
if not group in [e[0] for e in self.cmd_groups]:
|
||||
die(1,'{!r}: unrecognized group'.format(group))
|
||||
die(1,f'{group!r}: unrecognized group')
|
||||
groups = [self.cmd_groups[group]]
|
||||
else:
|
||||
groups = self.cmd_groups
|
||||
|
|
@ -626,6 +634,7 @@ class TestSuiteRunner(object):
|
|||
'test suite runner'
|
||||
|
||||
def __init__(self,data_dir,trash_dir):
|
||||
|
||||
self.data_dir = data_dir
|
||||
self.trash_dir = trash_dir
|
||||
self.cmd_total = 0
|
||||
|
|
@ -636,23 +645,23 @@ class TestSuiteRunner(object):
|
|||
|
||||
if opt.log:
|
||||
self.log_fd = open(log_file,'a')
|
||||
self.log_fd.write('\nLog started: {} UTC\n'.format(make_timestr()))
|
||||
omsg('INFO → Logging to file {!r}'.format(log_file))
|
||||
self.log_fd.write(f'\nLog started: {make_timestr()} UTC\n')
|
||||
omsg(f'INFO → Logging to file {log_file!r}')
|
||||
else:
|
||||
self.log_fd = None
|
||||
|
||||
if opt.coverage:
|
||||
self.coverdir,self.accfile = init_coverage()
|
||||
omsg('INFO → Writing coverage files to {!r}'.format(self.coverdir))
|
||||
omsg(f'INFO → Writing coverage files to {self.coverdir!r}')
|
||||
|
||||
def spawn_wrapper( self, cmd,
|
||||
args = [],
|
||||
extra_desc = '',
|
||||
no_output = False,
|
||||
msg_only = False,
|
||||
no_msg = False,
|
||||
cmd_dir = 'cmds',
|
||||
no_traceback = False ):
|
||||
def spawn_wrapper(self,cmd,
|
||||
args = [],
|
||||
extra_desc = '',
|
||||
no_output = False,
|
||||
msg_only = False,
|
||||
no_msg = False,
|
||||
cmd_dir = 'cmds',
|
||||
no_traceback = False ):
|
||||
|
||||
desc = self.ts.test_name if opt.names else self.gm.dpy_data[self.ts.test_name][1]
|
||||
if extra_desc: desc += ' ' + extra_desc
|
||||
|
|
@ -662,9 +671,10 @@ class TestSuiteRunner(object):
|
|||
elif g.platform == 'win':
|
||||
cmd = os.path.join('/mingw64','opt','bin',cmd)
|
||||
|
||||
passthru_opts = ['--{}{}'.format(k.replace('_','-'),
|
||||
'=' + getattr(opt,k) if getattr(opt,k) != True else '')
|
||||
for k in self.ts.base_passthru_opts + self.ts.passthru_opts if getattr(opt,k)]
|
||||
passthru_opts = ['--{}{}'.format(
|
||||
k.replace('_','-'),
|
||||
'=' + getattr(opt,k) if getattr(opt,k) != True else ''
|
||||
) for k in self.ts.base_passthru_opts + self.ts.passthru_opts if getattr(opt,k)]
|
||||
|
||||
args = [cmd] + passthru_opts + self.ts.extra_spawn_args + args
|
||||
|
||||
|
|
@ -682,7 +692,10 @@ class TestSuiteRunner(object):
|
|||
if opt.coverage:
|
||||
args = ['python3','-m','trace','--count','--coverdir='+self.coverdir,'--file='+self.accfile] + args
|
||||
|
||||
qargs = ['{q}{}{q}'.format(a,q=('',"'")[' ' in a]) for a in args]
|
||||
qargs = ['{q}{}{q}'.format(
|
||||
a,
|
||||
q = "'" if ' ' in a else ''
|
||||
) for a in args]
|
||||
cmd_disp = ' '.join(qargs).replace('\\','/') # for mingw
|
||||
|
||||
if not no_msg:
|
||||
|
|
@ -735,9 +748,9 @@ class TestSuiteRunner(object):
|
|||
def gen_msg():
|
||||
yield ('{g}:{c}' if cmd else 'test group {g!r}').format(g=gname,c=cmd)
|
||||
if len(ts_cls.networks) != 1:
|
||||
yield ' for {} {}'.format(proto.coin,proto.network)
|
||||
yield f' for {proto.coin} {proto.network}'
|
||||
if segwit_opt:
|
||||
yield ' (--{})'.format(segwit_opt.replace('_','-'))
|
||||
yield ' (--{})'.format( segwit_opt.replace('_','-') )
|
||||
|
||||
m = ''.join(gen_msg())
|
||||
|
||||
|
|
@ -769,7 +782,7 @@ class TestSuiteRunner(object):
|
|||
omsg(f'INFO → Resuming at command {resume!r}')
|
||||
|
||||
if opt.exit_after and opt.exit_after not in self.gm.cmd_list:
|
||||
die(1,'{!r}: command not recognized'.format(opt.exit_after))
|
||||
die(1,f'{opt.exit_after!r}: command not recognized')
|
||||
|
||||
return True
|
||||
|
||||
|
|
@ -809,13 +822,13 @@ class TestSuiteRunner(object):
|
|||
do_between()
|
||||
gname_save = gname
|
||||
else:
|
||||
die(1,'{!r}: command not recognized'.format(arg))
|
||||
die(1,f'{arg!r}: command not recognized')
|
||||
else:
|
||||
if opt.exclude_groups:
|
||||
exclude = opt.exclude_groups.split(',')
|
||||
for e in exclude:
|
||||
if e not in self.gm.cmd_groups_dfl:
|
||||
die(1,'{!r}: group not recognized'.format(e))
|
||||
die(1,f'{e!r}: group not recognized')
|
||||
for gname in self.gm.cmd_groups_dfl:
|
||||
if opt.exclude_groups and gname in exclude:
|
||||
continue
|
||||
|
|
@ -827,13 +840,11 @@ class TestSuiteRunner(object):
|
|||
|
||||
self.end_msg()
|
||||
|
||||
def check_needs_rerun(self,
|
||||
cmd,
|
||||
build=False,
|
||||
root=True,
|
||||
force_delete=False,
|
||||
dpy=False
|
||||
):
|
||||
def check_needs_rerun(self,cmd,
|
||||
build = False,
|
||||
root = True,
|
||||
force_delete = False,
|
||||
dpy = False ):
|
||||
|
||||
self.ts.test_name = cmd
|
||||
rerun = root # force_delete is not passed to recursive call
|
||||
|
|
@ -893,13 +904,14 @@ class TestSuiteRunner(object):
|
|||
if resume:
|
||||
if cmd != resume:
|
||||
return
|
||||
bmsg('Resuming at {!r}'.format(cmd))
|
||||
bmsg(f'Resuming at {cmd!r}')
|
||||
resume = False
|
||||
opt.skip_deps = False
|
||||
|
||||
if opt.profile: start = time.time()
|
||||
if opt.profile:
|
||||
start = time.time()
|
||||
|
||||
self.ts.test_name = cmd # NB: Do not remove, this needs to set twice
|
||||
self.ts.test_name = cmd # NB: Do not remove, this needs to be set twice
|
||||
cdata = self.gm.dpy_data[cmd]
|
||||
# self.ts.test_dpydata = cdata
|
||||
self.ts.tmpdir_num = cdata[0]
|
||||
|
|
@ -919,7 +931,7 @@ class TestSuiteRunner(object):
|
|||
self.process_retval(cmd,ret)
|
||||
|
||||
if opt.profile:
|
||||
omsg('\r\033[50C{:.4f}'.format(time.time() - start))
|
||||
omsg('\r\033[50C{:.4f}'.format( time.time() - start ))
|
||||
|
||||
if cmd == opt.exit_after:
|
||||
sys.exit(0)
|
||||
|
|
@ -943,19 +955,19 @@ class TestSuiteRunner(object):
|
|||
self.skipped_warnings.append(
|
||||
'Test {!r} was skipped:\n {}'.format(cmd,'\n '.join(ret[1].split('\n'))))
|
||||
else:
|
||||
rdie(1,'{!r} returned {}'.format(cmd,ret))
|
||||
rdie(1,f'{cmd!r} returned {ret}')
|
||||
|
||||
def check_deps(self,cmds): # TODO: broken
|
||||
if len(cmds) != 1:
|
||||
die(1,'Usage: {} check_deps <command>'.format(g.prog_name))
|
||||
die(1,f'Usage: {g.prog_name} check_deps <command>')
|
||||
|
||||
cmd = cmds[0]
|
||||
|
||||
if cmd not in self.gm.cmd_list:
|
||||
die(1,'{!r}: unrecognized command'.format(cmd))
|
||||
die(1,f'{cmd!r}: unrecognized command')
|
||||
|
||||
if not opt.quiet:
|
||||
omsg('Checking dependencies for {!r}'.format(cmd))
|
||||
omsg(f'Checking dependencies for {cmd!r}')
|
||||
|
||||
self.check_needs_rerun(self.ts,cmd,build=False)
|
||||
|
||||
|
|
@ -963,7 +975,7 @@ class TestSuiteRunner(object):
|
|||
for cmd in self.rebuild_list:
|
||||
c = self.rebuild_list[cmd]
|
||||
m = 'Rebuild' if (c[0] and c[1]) else 'Build' if c[0] else 'OK'
|
||||
omsg('cmd {:<{w}} {}'.format(cmd+':', m, w=w))
|
||||
omsg('cmd {:<{w}} {}'.format( cmd+':', m, w=w ))
|
||||
|
||||
def generate_file_deps(self,cmd):
|
||||
return [(str(n),e) for exts,n in self.gm.dpy_data[cmd][2] for e in exts]
|
||||
|
|
@ -975,14 +987,14 @@ class TestSuiteRunner(object):
|
|||
try:
|
||||
num = str(self.gm.dpy_data[cmd][0])
|
||||
except KeyError:
|
||||
qmsg_r('Missing dependency {!r}'.format(cmd))
|
||||
qmsg_r(f'Missing dependency {cmd!r}')
|
||||
gname = self.gm.find_cmd_in_groups(cmd)
|
||||
if gname:
|
||||
kwargs = self.gm.cmd_groups[gname][1]
|
||||
kwargs.update({'add_dpy':True})
|
||||
self.gm.create_group(gname,**kwargs)
|
||||
num = str(self.gm.dpy_data[cmd][0])
|
||||
qmsg(' found in group {!r}'.format(gname))
|
||||
qmsg(f' found in group {gname!r}')
|
||||
else:
|
||||
qmsg(' not found in any command group!')
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ def ok_msg():
|
|||
sys.stderr.write(green('\nOK\n') if opt.exact_output or opt.verbose else ' OK\n')
|
||||
|
||||
def skip(name,reason=None):
|
||||
msg('Skipping {}{}'.format(name,' ({})'.format(reason) if reason else ''))
|
||||
msg('Skipping {}{}'.format( name, f' ({reason})' if reason else '' ))
|
||||
return 'skip'
|
||||
|
||||
def confirm_continue():
|
||||
|
|
|
|||
|
|
@ -136,9 +136,10 @@ class TestSuiteAutosign(TestSuiteBase):
|
|||
|
||||
def do_autosign_live(opts,mountpoint,led_opts=[],gen_wallet=True):
|
||||
|
||||
omsg(purple('Running autosign test with {}'.format(
|
||||
f"'{' '.join(led_opts)}'" if led_opts else 'no LED'
|
||||
)))
|
||||
omsg(purple(
|
||||
'Running autosign test with ' +
|
||||
(f"'{' '.join(led_opts)}'" if led_opts else 'no LED')
|
||||
))
|
||||
|
||||
def do_mount():
|
||||
try: run(['mount',mountpoint],check=True)
|
||||
|
|
@ -173,7 +174,7 @@ class TestSuiteAutosign(TestSuiteBase):
|
|||
|
||||
def do_loop():
|
||||
omsg(blue(m2))
|
||||
t.expect('{} transactions signed'.format(txcount))
|
||||
t.expect(f'{txcount} transactions signed')
|
||||
if not led_opts:
|
||||
t.expect('2 transactions failed to sign')
|
||||
t.expect('Waiting')
|
||||
|
|
@ -197,7 +198,7 @@ class TestSuiteAutosign(TestSuiteBase):
|
|||
def do_autosign(opts,mountpoint,mn_type=None,short=False):
|
||||
|
||||
def autosign_expect(t,txcount):
|
||||
t.expect('{} transactions signed'.format(txcount))
|
||||
t.expect(f'{txcount} transactions signed')
|
||||
t.expect('2 transactions failed to sign')
|
||||
t.expect('Waiting')
|
||||
t.kill(2)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class TestSuiteBase(object):
|
|||
self.spawn = spawn
|
||||
self.have_dfl_wallet = False
|
||||
self.usr_rand_chars = (5,30)[bool(opt.usr_random)]
|
||||
self.usr_rand_arg = '-r{}'.format(self.usr_rand_chars)
|
||||
self.usr_rand_arg = f'-r{self.usr_rand_chars}'
|
||||
self.altcoin_pfx = '' if self.proto.base_coin == 'BTC' else '-'+self.proto.base_coin
|
||||
self.tn_ext = ('','.testnet')[self.proto.testnet]
|
||||
d = {'bch':'btc','btc':'btc','ltc':'ltc'}
|
||||
|
|
@ -74,7 +74,7 @@ class TestSuiteBase(object):
|
|||
|
||||
def skip_for_win(self):
|
||||
if g.platform == 'win':
|
||||
msg("Skipping test '{}': not supported on MSys2 platform".format(self.test_name))
|
||||
msg(f'Skipping test {self.test_name!r}: not supported on MSys2 platform')
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class TestSuiteCfg(TestSuiteBase):
|
|||
|
||||
txt = 'mnemonic_entry_modes mmgen:full bip39:short'
|
||||
write_to_file(self.path('usr'),txt+'\n')
|
||||
imsg(yellow(f'Wrote cfg file: "{txt}"'))
|
||||
imsg(yellow(f'Wrote cfg file: {txt!r}'))
|
||||
return run("{'mmgen': 'full', 'bip39': 'short'}")
|
||||
|
||||
def chain_names(self):
|
||||
|
|
@ -209,7 +209,7 @@ class TestSuiteCfg(TestSuiteBase):
|
|||
for coin,chain_chk in (('ETH',chk),('ETC',None)):
|
||||
t = self.spawn_test(
|
||||
args = [f'--coin={coin}',f'--testnet={(0,1)[testnet]}','coin_specific_vars','chain_names'],
|
||||
extra_desc = f'({coin} testnet={testnet} chain_names={chain_chk})' )
|
||||
extra_desc = f'({coin} testnet={testnet!r:5} chain_names={chain_chk})' )
|
||||
chain = t.expect_getend('chain_names: ')
|
||||
if chain_chk:
|
||||
assert chain == chain_chk, f'{chain} != {chain_chk}'
|
||||
|
|
@ -221,13 +221,13 @@ class TestSuiteCfg(TestSuiteBase):
|
|||
|
||||
txt = 'eth_mainnet_chain_names istanbul constantinople'
|
||||
write_to_file(self.path('usr'),txt+'\n')
|
||||
imsg(yellow(f'Wrote cfg file: "{txt}"'))
|
||||
imsg(yellow(f'Wrote cfg file: {txt!r}'))
|
||||
t = run("['istanbul', 'constantinople']",False)
|
||||
t = run(None,True)
|
||||
|
||||
txt = 'eth_testnet_chain_names rinkeby'
|
||||
write_to_file(self.path('usr'),txt+'\n')
|
||||
imsg(yellow(f'Wrote cfg file: "{txt}"'))
|
||||
imsg(yellow(f'Wrote cfg file: {txt!r}'))
|
||||
t = run(None,False)
|
||||
t = run("['rinkeby']",True)
|
||||
|
||||
|
|
|
|||
|
|
@ -348,7 +348,12 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
|
||||
@property
|
||||
def eth_args(self):
|
||||
return ['--outdir={}'.format(self.tmpdir),'--coin='+self.proto.coin,'--rpc-port={}'.format(self.rpc_port),'--quiet']
|
||||
return [
|
||||
f'--outdir={self.tmpdir}',
|
||||
f'--coin={self.proto.coin}',
|
||||
f'--rpc-port={self.rpc_port}',
|
||||
'--quiet'
|
||||
]
|
||||
|
||||
async def setup(self):
|
||||
self.spawn('',msg_only=True)
|
||||
|
|
@ -368,7 +373,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
return False
|
||||
from mmgen.rpc import rpc_init
|
||||
rpc = await rpc_init(self.proto)
|
||||
imsg('Daemon: {} v{}'.format(rpc.daemon.coind_name,rpc.daemon_version_str))
|
||||
imsg(f'Daemon: {rpc.daemon.coind_name} v{rpc.daemon_version_str}')
|
||||
|
||||
return 'ok'
|
||||
|
||||
|
|
@ -443,7 +448,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
|
||||
def wallet_upgrade(self,src_file):
|
||||
if self.proto.coin == 'ETC':
|
||||
msg('skipping test {!r} for ETC'.format(self.test_name))
|
||||
msg(f'skipping test {self.test_name!r} for ETC')
|
||||
return 'skip'
|
||||
src_dir = joinpath(ref_dir,'ethereum')
|
||||
dest_dir = joinpath(self.tr.data_dir,'altcoins',self.proto.coin.lower())
|
||||
|
|
@ -510,7 +515,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
fee_desc = 'gas price',
|
||||
no_read = False,
|
||||
tweaks = [] ):
|
||||
fee_res = r'\D{}\D.*{c} .*\D{}\D.*gas price in Gwei'.format(*fee_res_data,c=self.proto.coin)
|
||||
fee_res = r'\D{}\D.*{c} .*\D{}\D.*gas price in Gwei'.format( *fee_res_data, c=self.proto.coin )
|
||||
t = self.spawn('mmgen-'+caller, self.eth_args + ['-B'] + args)
|
||||
t.expect(r'add \[l\]abel, .*?:.','p', regex=True)
|
||||
t.written_to_file('Account balances listing')
|
||||
|
|
@ -536,7 +541,9 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
keyfile = joinpath(self.tmpdir,parity_devkey_fn)
|
||||
txfile = self.get_file_with_ext(ext,no_dot=True)
|
||||
t = self.spawn( 'mmgen-txsign',
|
||||
['--outdir={}'.format(self.tmpdir),'--coin='+self.proto.coin,'--quiet']
|
||||
[f'--outdir={self.tmpdir}']
|
||||
+ [f'--coin={self.proto.coin}']
|
||||
+ ['--quiet']
|
||||
+ ['--rpc-host=bad_host'] # ETH signing must work without RPC
|
||||
+ add_args
|
||||
+ ([],['--yes'])[ni]
|
||||
|
|
@ -672,7 +679,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
addr,amt,adj = b if len(b) == 3 else b + (False,)
|
||||
if adj and self.proto.coin == 'ETC':
|
||||
amt = str(Decimal(amt) + Decimal(adj[1]) * self.bal_corr)
|
||||
pat = r'\D{}\D.*\D{}\D'.format(addr,amt.replace('.',r'\.'))
|
||||
pat = r'\D{}\D.*\D{}\D'.format( addr, amt.replace('.',r'\.') )
|
||||
assert re.search(pat,text), pat
|
||||
ss = f'Total {self.proto.coin}:'
|
||||
assert re.search(ss,text),ss
|
||||
|
|
@ -685,7 +692,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
addr,_amt1,_amt2,adj = b if len(b) == 4 else b + (False,)
|
||||
if adj and self.proto.coin == 'ETC':
|
||||
_amt2 = str(Decimal(_amt2) + Decimal(adj[1]) * self.bal_corr)
|
||||
pat = r'{}\b.*\D{}\D.*\b{}\D'.format(addr,_amt1,_amt2)
|
||||
pat = rf'{addr}\b.*\D{_amt1}\D.*\b{_amt2}\D'
|
||||
assert re.search(pat,text), pat
|
||||
ss = 'Total MM1:'
|
||||
assert re.search(ss,text),ss
|
||||
|
|
@ -712,7 +719,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
|
||||
def chk_label(self,lbl_pat,addr='98831F3A:E:3'):
|
||||
t = self.spawn('mmgen-tool', self.eth_args + ['listaddresses','all_labels=1'])
|
||||
t.expect(r'{}\b.*\S{{30}}\b.*{}\b'.format(addr,lbl_pat),regex=True)
|
||||
t.expect(rf'{addr}\b.*\S{{30}}\b.*{lbl_pat}\b',regex=True)
|
||||
return t
|
||||
|
||||
def add_label1(self): return self.add_label(lbl=tw_label_zh)
|
||||
|
|
@ -731,8 +738,8 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
imsg(f'Using precompiled contract data in {odir}')
|
||||
return 'skip' if os.path.exists(odir) else False
|
||||
self.spawn('',msg_only=True)
|
||||
cmd_args = ['--{}={}'.format(k,v) for k,v in list(token_data.items())]
|
||||
imsg("Compiling solidity token contract '{}' with 'solc'".format(token_data['symbol']))
|
||||
cmd_args = [f'--{k}={v}' for k,v in list(token_data.items())]
|
||||
imsg("Compiling solidity token contract '{}' with 'solc'".format( token_data['symbol'] ))
|
||||
try: os.mkdir(odir)
|
||||
except: pass
|
||||
cmd = [
|
||||
|
|
@ -741,12 +748,12 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
'--coin=' + self.proto.coin,
|
||||
'--outdir=' + odir
|
||||
] + cmd_args + [CoinProtocol.Ethereum.checksummed_addr(dfl_devaddr)]
|
||||
imsg("Executing: {}".format(' '.join(cmd)))
|
||||
imsg('Executing: {}'.format( ' '.join(cmd) ))
|
||||
cp = run(cmd,stdout=DEVNULL,stderr=PIPE)
|
||||
if cp.returncode != 0:
|
||||
rmsg('solc failed with the following output:')
|
||||
ydie(2,cp.stderr.decode())
|
||||
imsg("ERC20 token '{}' compiled".format(token_data['symbol']))
|
||||
imsg('ERC20 token {!r} compiled'.format( token_data['symbol'] ))
|
||||
return 'ok'
|
||||
|
||||
def token_compile1(self):
|
||||
|
|
@ -773,12 +780,14 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
async def token_deploy(self,num,key,gas,mmgen_cmd='txdo',tx_fee='8G'):
|
||||
keyfile = joinpath(self.tmpdir,parity_devkey_fn)
|
||||
fn = joinpath(self.tmpdir,'mm'+str(num),key+'.bin')
|
||||
args = ['-B',
|
||||
'--tx-fee='+tx_fee,
|
||||
'--tx-gas={}'.format(gas),
|
||||
'--contract-data='+fn,
|
||||
'--inputs='+dfl_devaddr,
|
||||
'--yes' ]
|
||||
args = [
|
||||
'-B',
|
||||
f'--tx-fee={tx_fee}',
|
||||
f'--tx-gas={gas}',
|
||||
f'--contract-data={fn}',
|
||||
f'--inputs={dfl_devaddr}',
|
||||
'--yes',
|
||||
]
|
||||
if mmgen_cmd == 'txdo':
|
||||
args += ['-k',keyfile]
|
||||
t = self.spawn( 'mmgen-'+mmgen_cmd, self.eth_args + args)
|
||||
|
|
@ -823,7 +832,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
self.spawn('',msg_only=True)
|
||||
sid = dfl_sid
|
||||
from mmgen.tool import MMGenToolCmdWallet
|
||||
usr_mmaddrs = ['{}:E:{}'.format(sid,i) for i in (11,21)]
|
||||
usr_mmaddrs = [f'{sid}:E:{i}' for i in (11,21)]
|
||||
usr_addrs = [MMGenToolCmdWallet(proto=self.proto).gen_addr(addr,dfl_words_file) for addr in usr_mmaddrs]
|
||||
|
||||
from mmgen.altcoins.eth.contract import TokenResolve
|
||||
|
|
@ -835,8 +844,8 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
rpc,
|
||||
self.read_from_tmpfile(f'token_addr{i+1}').strip() )
|
||||
imsg_r( '\n' + await tk.info() )
|
||||
imsg('dev token balance (pre-send): {}'.format(await tk.get_balance(dfl_devaddr)))
|
||||
imsg('Sending {} {} to address {} ({})'.format(amt,self.proto.dcoin,usr_addrs[i],usr_mmaddrs[i]))
|
||||
imsg('dev token balance (pre-send): {}'.format( await tk.get_balance(dfl_devaddr) ))
|
||||
imsg(f'Sending {amt} {self.proto.dcoin} to address {usr_addrs[i]} ({usr_mmaddrs[i]})')
|
||||
txid = await tk.transfer(
|
||||
dfl_devaddr,
|
||||
usr_addrs[i],
|
||||
|
|
@ -853,10 +862,12 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
self.proto,
|
||||
rpc,
|
||||
self.read_from_tmpfile(f'token_addr{i+1}').strip() )
|
||||
imsg('Token: {}'.format(await tk.get_symbol()))
|
||||
imsg('dev token balance: {}'.format(await tk.get_balance(dfl_devaddr)))
|
||||
imsg('Token: {}'.format( await tk.get_symbol() ))
|
||||
imsg(f'dev token balance: {await tk.get_balance(dfl_devaddr)}')
|
||||
imsg('usr token balance: {} ({} {})'.format(
|
||||
await tk.get_balance(usr_addrs[i]),usr_mmaddrs[i],usr_addrs[i]))
|
||||
await tk.get_balance(usr_addrs[i]),
|
||||
usr_mmaddrs[i],
|
||||
usr_addrs[i] ))
|
||||
|
||||
from mmgen.rpc import rpc_init
|
||||
rpc = await rpc_init(self.proto)
|
||||
|
|
@ -1068,7 +1079,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
t.expect(' main menu): ',n)
|
||||
t.expect('Is this what you want? (y/N): ','y')
|
||||
t.expect('[R]efresh balance:\b','q')
|
||||
t.expect('Total unspent:.*\D{}\D.*{}'.format(total,total_coin),regex=True)
|
||||
t.expect(f'Total unspent:.*\D{total}\D.*{total_coin}',regex=True)
|
||||
t.read()
|
||||
return t
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class TestSuiteInput(TestSuiteBase):
|
|||
pw = 'abc-α'
|
||||
t.expect(prompt,pw)
|
||||
ret = t.expect_getend('Entered: ')
|
||||
assert ret == pw,'Password mismatch! {} != {}'.format(ret,pw)
|
||||
assert ret == pw, f'Password mismatch! {ret} != {pw}'
|
||||
return t
|
||||
|
||||
def password_entry_noecho(self):
|
||||
|
|
@ -190,7 +190,7 @@ class TestSuiteInput(TestSuiteBase):
|
|||
regex = True )
|
||||
t.expect('Using (.+) entry mode',regex=True)
|
||||
mode = strip_ansi_escapes(t.p.match.group(1)).lower()
|
||||
assert mode == mne.em.name.lower(), '{} != {}'.format(mode,mne.em.name.lower())
|
||||
assert mode == mne.em.name.lower(), f'{mode} != {mne.em.name.lower()}'
|
||||
stealth_mnemonic_entry(t,mne,mn,entry_mode=entry_mode,pad_entry=pad_entry)
|
||||
t.expect(sample_mn[fmt]['hex'])
|
||||
t.read()
|
||||
|
|
@ -198,7 +198,7 @@ class TestSuiteInput(TestSuiteBase):
|
|||
|
||||
def _user_seed_entry(self,fmt,usr_rand=False,out_fmt=None,entry_mode='full',mn=None):
|
||||
wcls = Wallet.fmt_code_to_type(fmt)
|
||||
wf = os.path.join(ref_dir,'FE3C6545.{}'.format(wcls.ext))
|
||||
wf = os.path.join(ref_dir,f'FE3C6545.{wcls.ext}')
|
||||
if wcls.wclass == 'mnemonic':
|
||||
mn = mn or read_from_file(wf).strip().split()
|
||||
elif wcls.wclass == 'dieroll':
|
||||
|
|
@ -206,7 +206,7 @@ class TestSuiteInput(TestSuiteBase):
|
|||
for idx,val in ((5,'x'),(18,'0'),(30,'7'),(44,'9')):
|
||||
mn.insert(idx,val)
|
||||
t = self.spawn('mmgen-walletconv',['-r10','-S','-i',fmt,'-o',out_fmt or fmt])
|
||||
t.expect('{} type:.*{}'.format(capfirst(wcls.wclass),wcls.mn_type),regex=True)
|
||||
t.expect(f'{capfirst(wcls.wclass)} type:.*{wcls.mn_type}',regex=True)
|
||||
t.expect(wcls.choose_seedlen_prompt,'1')
|
||||
t.expect('(Y/n): ','y')
|
||||
if wcls.wclass == 'mnemonic':
|
||||
|
|
@ -217,7 +217,7 @@ class TestSuiteInput(TestSuiteBase):
|
|||
t.expect('Type a number.*: ',str(mne.entry_modes.index(entry_mode)+1),regex=True)
|
||||
t.expect('Using (.+) entry mode',regex=True)
|
||||
mode = strip_ansi_escapes(t.p.match.group(1)).lower()
|
||||
assert mode == mne.em.name.lower(), '{} != {}'.format(mode,mne.em.name.lower())
|
||||
assert mode == mne.em.name.lower(), f'{mode} != {mne.em.name.lower()}'
|
||||
stealth_mnemonic_entry(t,mne,mn,entry_mode=entry_mode)
|
||||
elif wcls.wclass == 'dieroll':
|
||||
user_dieroll_entry(t,mn)
|
||||
|
|
@ -228,9 +228,9 @@ class TestSuiteInput(TestSuiteBase):
|
|||
t.expect(wcls.user_entropy_prompt,'n')
|
||||
if not usr_rand:
|
||||
sid_chk = 'FE3C6545'
|
||||
sid = t.expect_getend('Valid {} for Seed ID '.format(wcls.desc))
|
||||
sid = t.expect_getend(f'Valid {wcls.desc} for Seed ID ')
|
||||
sid = strip_ansi_escapes(sid.split(',')[0])
|
||||
assert sid == sid_chk,'Seed ID mismatch! {} != {}'.format(sid,sid_chk)
|
||||
assert sid == sid_chk, f'Seed ID mismatch! {sid} != {sid_chk}'
|
||||
t.expect('to confirm: ','YES\n')
|
||||
t.read()
|
||||
return t
|
||||
|
|
|
|||
|
|
@ -313,7 +313,9 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
|
|||
else f'{al_id}:{idx}{lbl}' ),
|
||||
'vout': int(getrandnum(4) % 8),
|
||||
'txid': os.urandom(32).hex(),
|
||||
'amount': self.proto.coin_amt('{}.{}'.format(amt1 + getrandnum(4) % amt2, getrandnum(4) % 100000000)),
|
||||
'amount': self.proto.coin_amt('{}.{}'.format(
|
||||
amt1 + getrandnum(4) % amt2,
|
||||
getrandnum(4) % 100000000 )),
|
||||
'address': coinaddr,
|
||||
'spendable': False,
|
||||
'scriptPubKey': f'{s_beg}{coinaddr.hex}{s_end}',
|
||||
|
|
@ -387,18 +389,28 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
|
|||
for k in self.cfgs:
|
||||
self.cfgs[k]['amts'] = [None,None]
|
||||
for idx,mod in enumerate(mods):
|
||||
self.cfgs[k]['amts'][idx] = '{}.{}'.format(getrandnum(4) % mod, str(getrandnum(4))[:5])
|
||||
self.cfgs[k]['amts'][idx] = '{}.{}'.format(
|
||||
getrandnum(4) % mod,
|
||||
str(getrandnum(4))[:5] )
|
||||
|
||||
cmd_args = ['--outdir='+self.tmpdir]
|
||||
for num in tx_data:
|
||||
s = tx_data[num]
|
||||
cmd_args += [
|
||||
'{}:{},{}'.format(s['al_id'],s['addr_idxs'][0],self.cfgs[num]['amts'][0]),
|
||||
]
|
||||
'{}:{},{}'.format(
|
||||
s['al_id'],
|
||||
s['addr_idxs'][0],
|
||||
self.cfgs[num]['amts'][0] )]
|
||||
# + one change address and one BTC address
|
||||
if num is list(tx_data.keys())[-1]:
|
||||
cmd_args += ['{}:{}'.format(s['al_id'],s['addr_idxs'][1])]
|
||||
cmd_args += ['{},{}'.format(rand_coinaddr,self.cfgs[num]['amts'][1])]
|
||||
cmd_args += [
|
||||
'{}:{}'.format(
|
||||
s['al_id'],
|
||||
s['addr_idxs'][1] )]
|
||||
cmd_args += [
|
||||
'{},{}'.format(
|
||||
rand_coinaddr,
|
||||
self.cfgs[num]['amts'][1] )]
|
||||
|
||||
return cmd_args + [tx_data[num]['addrfile'] for num in tx_data]
|
||||
|
||||
|
|
@ -427,11 +439,14 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
|
|||
|
||||
if cmdline_inputs:
|
||||
from mmgen.tx import TwLabel
|
||||
cmd_args = ['--inputs={},{},{},{},{},{}'.format(
|
||||
TwLabel(self.proto,dfake[0][self.lbl_id]).mmid,dfake[1]['address'],
|
||||
TwLabel(self.proto,dfake[2][self.lbl_id]).mmid,dfake[3]['address'],
|
||||
TwLabel(self.proto,dfake[4][self.lbl_id]).mmid,dfake[5]['address']
|
||||
),'--outdir='+self.tr.trash_dir] + cmd_args[1:]
|
||||
cmd_args = [
|
||||
'--inputs={},{},{},{},{},{}'.format(
|
||||
TwLabel(self.proto,dfake[0][self.lbl_id]).mmid,dfake[1]['address'],
|
||||
TwLabel(self.proto,dfake[2][self.lbl_id]).mmid,dfake[3]['address'],
|
||||
TwLabel(self.proto,dfake[4][self.lbl_id]).mmid,dfake[5]['address']
|
||||
),
|
||||
f'--outdir={self.tr.trash_dir}'
|
||||
] + cmd_args[1:]
|
||||
|
||||
end_silence()
|
||||
|
||||
|
|
@ -552,7 +567,9 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
|
|||
f,t = self._walletconv_export(wf,out_fmt=out_fmt,pf=pf)
|
||||
silence()
|
||||
wcls = Wallet.fmt_code_to_type(out_fmt)
|
||||
msg('==> {}: {}'.format(wcls.desc,cyan(get_data_from_file(f,wcls.desc))))
|
||||
msg('==> {}: {}'.format(
|
||||
wcls.desc,
|
||||
cyan(get_data_from_file(f,wcls.desc)) ))
|
||||
end_silence()
|
||||
return t
|
||||
|
||||
|
|
@ -609,7 +626,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
|
|||
t.expect_getend('Incog Wallet ID: ')
|
||||
wcls = Wallet.fmt_code_to_type(in_fmt)
|
||||
t.hash_preset(wcls.desc,'1')
|
||||
t.passphrase('{} \w{{8}}'.format(wcls.desc),self.wpasswd)
|
||||
t.passphrase(f'{wcls.desc} \w{{8}}',self.wpasswd)
|
||||
vmsg('Comparing generated checksum with checksum from address file')
|
||||
chk = t.expect_getend(r'Checksum for address data .*?: ',regex=True)
|
||||
verify_checksum_or_exit(self._get_addrfile_checksum(),chk)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue