From 7f13c8580520f5c98a739da0d811d9c92fdfb682 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 11 Sep 2026 14:10:55 +0000 Subject: [PATCH] cmdtest.py autosign_automount: add legacy TX files to removable device --- test/cmdtest_d/automount.py | 19 +++++++++++++++++-- test/cmdtest_d/autosign.py | 9 +++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/test/cmdtest_d/automount.py b/test/cmdtest_d/automount.py index 2cbafbf3..4791d340 100755 --- a/test/cmdtest_d/automount.py +++ b/test/cmdtest_d/automount.py @@ -15,7 +15,7 @@ import time from .autosign import CmdTestAutosignThreaded from .regtest import CmdTestRegtest, rt_pw -from ..include.common import gr_uc, create_addrpairs +from ..include.common import gr_uc, create_addrpairs, write_to_cfgfile class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtest): 'automounted transacting operations via regtest mode' @@ -40,6 +40,7 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtest): cmd_group = ( ('setup', 'regtest mode setup'), ('walletgen_alice', 'wallet generation (Alice)'), + ('add_legacy_txfiles', 'adding legacy transaction files to removable device'), ('addrgen_alice', 'address generation (Alice)'), ('addrimport_alice', 'importing Alice’s addresses'), ('addrimport_alice_non_mmgen', 'importing Alice’s non-MMGen addresses'), @@ -91,7 +92,8 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtest): ('alice_bal2', 'checking Alice’s balance'), ('wait_loop_kill', 'stopping autosign wait loop'), ('stop', 'stopping regtest daemon'), - ('autosign_txview', 'viewing transactions on removable device'), + ('txview_allow_legacy', 'viewing transactions on removable device (allow legacy files'), + ('txview_forbid_legacy', 'viewing transactions on removable device (forbid legacy files'), ) def __init__(self, cfg, trunner, cfgs, spawn): @@ -108,6 +110,19 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtest): self.non_mmgen_addrs = create_addrpairs(self.proto, 'C', 2) + def add_legacy_txfiles(self): + self.spawn(msg_only=True) + self.tx_file_ops('copy', txfile_coins=['btc'], tx_dir='txauto_dir') + return 'ok' + + async def txview_allow_legacy(self): + write_to_cfgfile(['allow_legacy_tx_files true']) + return await self.autosign_txview(expect_str='forbidden', reverse=True) + + async def txview_forbid_legacy(self): + write_to_cfgfile(['allow_legacy_tx_files false']) + return await self.autosign_txview(expect_str='forbidden', reverse=False) + def addrimport_alice_non_mmgen(self): self.write_to_tmpfile( 'non_mmgen_addrs', diff --git a/test/cmdtest_d/autosign.py b/test/cmdtest_d/autosign.py index bccd7f41..129e15c7 100755 --- a/test/cmdtest_d/autosign.py +++ b/test/cmdtest_d/autosign.py @@ -667,12 +667,17 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase): def do_umount_online(self, *args, **kwargs): return self._mount_ops('asi_online', 'do_umount', *args, **kwargs) - async def autosign_txview(self): + async def autosign_txview(self, *, expect_str=None, reverse=False): self.insert_device() self.do_mount() src = Path(self.asi.txauto_dir) t = self.spawn('mmgen-tool', ['txview'] + [str(fn) for fn in sorted(src.iterdir())]) - t.read() + text = t.read() + if expect_str: + if reverse: + assert not expect_str in text + else: + assert expect_str in text self.do_umount() self.remove_device() return t