From eccc48b37ff0c9be77cf0a24d7440c5e2e1a8641 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 26 Sep 2021 21:16:55 +0000 Subject: [PATCH] minor fixes and cleanups --- mmgen/tw.py | 18 +++++++++--------- test/test-release.sh | 8 -------- test/test_py_d/common.py | 5 ++++- test/test_py_d/ts_misc.py | 7 ++++--- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/mmgen/tw.py b/mmgen/tw.py index 43132640..627f956b 100755 --- a/mmgen/tw.py +++ b/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): diff --git a/test/test-release.sh b/test/test-release.sh index cc71e60e..db13a668 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -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) diff --git a/test/test_py_d/common.py b/test/test_py_d/common.py index d9c6bc15..6b8b0bc6 100755 --- a/test/test_py_d/common.py +++ b/test/test_py_d/common.py @@ -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 diff --git a/test/test_py_d/ts_misc.py b/test/test_py_d/ts_misc.py index 6cc40d26..48976538 100755 --- a/test/test_py_d/ts_misc.py +++ b/test/test_py_d/ts_misc.py @@ -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)