minor fixes and cleanups
This commit is contained in:
parent
877be3f877
commit
eccc48b37f
4 changed files with 17 additions and 21 deletions
18
mmgen/tw.py
18
mmgen/tw.py
|
|
@ -48,21 +48,21 @@ _date_formatter = {
|
|||
'date_time': lambda rpc,secs: '{}-{:02}-{:02} {:02}:{:02}'.format(*time.gmtime(secs)[:5]),
|
||||
}
|
||||
|
||||
async def _set_dates(rpc,us):
|
||||
if rpc.proto.base_proto != 'Bitcoin':
|
||||
return
|
||||
if us and us[0].date is None:
|
||||
# 'blocktime' differs from 'time', is same as getblockheader['time']
|
||||
dates = [o['blocktime'] for o in await rpc.gathered_call('gettransaction',[(o.txid,) for o in us])]
|
||||
for idx,o in enumerate(us):
|
||||
o.date = dates[idx]
|
||||
|
||||
if os.getenv('MMGEN_BOGUS_WALLET_DATA'):
|
||||
# 1831006505 (09 Jan 2028) = projected time of block 1000000
|
||||
_date_formatter['days'] = lambda rpc,secs: (1831006505 - secs) // 86400
|
||||
async def _set_dates(rpc,us):
|
||||
for o in us:
|
||||
o.date = 1831006505 - int(9.7 * 60 * (o.confs - 1))
|
||||
else:
|
||||
async def _set_dates(rpc,us):
|
||||
if rpc.proto.base_proto != 'Bitcoin':
|
||||
return
|
||||
if us and us[0].date is None:
|
||||
# 'blocktime' differs from 'time', is same as getblockheader['time']
|
||||
dates = [o['blocktime'] for o in await rpc.gathered_call('gettransaction',[(o.txid,) for o in us])]
|
||||
for idx,o in enumerate(us):
|
||||
o.date = dates[idx]
|
||||
|
||||
class TwUnspentOutputs(MMGenObject,metaclass=AsyncInit):
|
||||
|
||||
|
|
|
|||
|
|
@ -558,13 +558,6 @@ run_tests() {
|
|||
done
|
||||
}
|
||||
|
||||
check_core_repo() {
|
||||
[ -e "$CORE_REPO_ROOT/src/test/data/tx_valid.json" ] || {
|
||||
echo "CORE_REPO_ROOT not set, or does not point to Bitcoin Core repository"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
check_args() {
|
||||
for i in $tests; do
|
||||
echo "$dfl_tests $extra_tests" | grep -q "\<$i\>" || {
|
||||
|
|
@ -574,7 +567,6 @@ check_args() {
|
|||
done
|
||||
}
|
||||
|
||||
check_core_repo
|
||||
check_args
|
||||
[ "$LIST_CMDS" ] || echo "Running tests: $tests"
|
||||
START=$(date +%s)
|
||||
|
|
|
|||
|
|
@ -107,7 +107,10 @@ def get_file_with_ext(tdir,ext,delete=True,no_dot=False,return_list=False,delete
|
|||
if len(flist) > 1 or delete_all:
|
||||
if delete or delete_all:
|
||||
if (opt.exact_output or opt.verbose) and not opt.quiet:
|
||||
msg("Multiple *.{} files in '{}' - deleting".format(ext,tdir))
|
||||
if delete_all:
|
||||
msg(f'Deleting all *.{ext} files in {tdir!r}')
|
||||
else:
|
||||
msg(f'Multiple *.{ext} files in {tdir!r} - deleting')
|
||||
for f in flist:
|
||||
os.unlink(f)
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -122,9 +122,10 @@ class TestSuiteOutput(TestSuiteBase):
|
|||
def output_jp(self): return self.screen_output('jp')
|
||||
|
||||
def oneshot_warning(self):
|
||||
nl = '\r\n' if g.platform == 'win' else '\n'
|
||||
t = self.spawn('test/misc/oneshot_warning.py',cmd_dir='.')
|
||||
for s in (
|
||||
'pw\nwg1',
|
||||
f'pw{nl}wg1',
|
||||
'foo is experimental',
|
||||
'wg2', 'The bar command is dangerous',
|
||||
'wg3', 'baz variant alpha',
|
||||
|
|
@ -135,11 +136,11 @@ class TestSuiteOutput(TestSuiteBase):
|
|||
'pw',
|
||||
"passphrase from file 'A'",
|
||||
"passphrase from file 'B'",
|
||||
'wg1\nwg2\nwg3\nwg4\nw1\nw2\nw3',
|
||||
f'wg1{nl}wg2{nl}wg3{nl}wg4{nl}w1{nl}w2{nl}w3',
|
||||
'pw',
|
||||
"passphrase from file 'A'",
|
||||
"passphrase from file 'B'",
|
||||
'wg1\nwg2\nwg3\nwg4\nw1\nw2\nw3',
|
||||
f'wg1{nl}wg2{nl}wg3{nl}wg4{nl}w1{nl}w2{nl}w3',
|
||||
'bottom',
|
||||
):
|
||||
t.expect(s)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue