cmdtest.py autosign_automount: add legacy TX files to removable device

This commit is contained in:
The MMGen Project 2026-09-11 14:10:55 +00:00
commit 7f13c85805
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 24 additions and 4 deletions

View file

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

View file

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