From bcd82551076b32dd5f7b3af286d07f000041c152 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 22 Aug 2026 18:34:46 +0000 Subject: [PATCH] test suite: minor fixes and cleanups --- test/cmdtest_d/input.py | 5 +++-- test/cmdtest_d/regtest.py | 10 ++++++---- test/cmdtest_d/swap.py | 6 +++--- test/misc/term.py | 2 +- test/test-release.d/cfg.sh | 4 ++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/test/cmdtest_d/input.py b/test/cmdtest_d/input.py index 1aa73f37..806a84ac 100755 --- a/test/cmdtest_d/input.py +++ b/test/cmdtest_d/input.py @@ -481,11 +481,12 @@ class CmdTestInput(CmdTestBase): stealth_mnemonic_entry(t, mne, mn, entry_mode=entry_mode) elif wcls.type == 'dieroll': user_dieroll_entry(t, mn) + prompt = wcls.user_entropy_prompt.split('\n')[-1] if usr_rand: - t.expect(wcls.user_entropy_prompt, 'y') + t.expect(prompt, 'y') t.usr_rand(10) else: - t.expect(wcls.user_entropy_prompt, 'n') + t.expect(prompt, 'n') if not usr_rand: sid_chk = 'FE3C6545' sid = strip_ansi_escapes( diff --git a/test/cmdtest_d/regtest.py b/test/cmdtest_d/regtest.py index 087fe1e0..94588736 100755 --- a/test/cmdtest_d/regtest.py +++ b/test/cmdtest_d/regtest.py @@ -695,11 +695,12 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared): return self.addrimport('alice', batch=False, quiet=False) async def bob_import_miner_addr(self): - if not self.deterministic: + if self.deterministic: + return self.spawn( + 'mmgen-addrimport', + ['--bob', '--rescan', '--quiet', f'--address={await self.rt.miner_addr}']) + else: return 'skip' - return self.spawn( - 'mmgen-addrimport', - ['--bob', '--rescan', '--quiet', f'--address={await self.rt.miner_addr}']) async def fund_wallet_deterministic(self, addr, utxo_nums, skip_passphrase=False): """ @@ -2303,4 +2304,5 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared): class CmdTestRegtestBDBWallet(CmdTestRegtest): 'transacting and tracking wallet operations via regtest mode (legacy BDB wallet)' + networks = ('ltc', 'bch') bdb_wallet = True diff --git a/test/cmdtest_d/swap.py b/test/cmdtest_d/swap.py index 7e79efd4..11bf80ae 100755 --- a/test/cmdtest_d/swap.py +++ b/test/cmdtest_d/swap.py @@ -12,11 +12,14 @@ test.cmdtest_d.swap: asset swap tests for the cmdtest.py test suite """ +import json from pathlib import Path from mmgen.cfg import Config +from mmgen.util import make_chksum_6 from mmgen.protocol import init_proto from mmgen.wallet.mmgen import wallet as MMGenWallet +from mmgen.tx.file import json_dumps from ..include.common import imsg, make_burn_addr, gr_uc @@ -773,9 +776,6 @@ class CmdTestSwap(CmdTestSwapMethods, CmdTestRegtest, CmdTestAutosignThreaded): return self._swaptxsign() def swaptxsend_bad2(self): - import json - from mmgen.tx.file import json_dumps - from mmgen.util import make_chksum_6 fn = self.get_file_with_ext('sigtx') with open(fn) as fh: data = json.load(fh) diff --git a/test/misc/term.py b/test/misc/term.py index 7fce9a13..36f65536 100755 --- a/test/misc/term.py +++ b/test/misc/term.py @@ -149,7 +149,7 @@ def tt_urand(): cmsg('Testing _get_random_data_from_user():') from mmgen.crypto import Crypto ret = Crypto(cfg)._get_random_data_from_user(uchars=10, desc='data').decode() - msg(f'USER ENTROPY (user input + keystroke timings):\n\n{fmt(ret, " ")}') + msg(f'USER ENTROPY (user input + keystroke timings):\n\n{fmt(ret, indent=" ")}') times = ret.splitlines()[1:] avg_prec = sum(len(t.split('.')[1]) for t in times) // len(times) if avg_prec < gc.min_time_precision: diff --git a/test/test-release.d/cfg.sh b/test/test-release.d/cfg.sh index fcff9a99..6f65bd90 100755 --- a/test/test-release.d/cfg.sh +++ b/test/test-release.d/cfg.sh @@ -76,8 +76,8 @@ init_tests() { t_ruff=" - $ruff check setup.py - $ruff check mmgen - - $ruff check test - $ruff check examples + - $ruff check test " d_pylint="code errors with Pylint static analyzer" @@ -85,9 +85,9 @@ init_tests() { t_pylint=" - $pylint setup.py - $pylint mmgen + - $pylint examples - $pylint test - $pylint --disable=relative-beyond-top-level test/cmdtest_d - - $pylint examples " d_bandit="code vulnerabilities with Bandit static analyzer"