test suite: minor fixes and cleanups

This commit is contained in:
The MMGen Project 2026-08-22 18:34:46 +00:00
commit bcd8255107
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 15 additions and 12 deletions

View file

@ -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(

View file

@ -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

View file

@ -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)

View file

@ -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:

View file

@ -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"