From a5e3a1807c4ee14572352c109f3c52a59412cf56 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 20 Oct 2026 17:38:48 +0000 Subject: [PATCH] minor fixes and cleanups --- mmgen/filename.py | 4 ++-- mmgen/proto/xmr/tw/ctl.py | 13 +++++++++---- mmgen/proto/xmr/tx/new.py | 2 +- mmgen/tw/store.py | 6 ++---- test/cmdtest_d/autosign.py | 21 ++++++++++++++------- test/cmdtest_d/include/pexpect.py | 4 +++- test/overlay/fakemods/mmgen/daemon.py | 1 - 7 files changed, 31 insertions(+), 20 deletions(-) diff --git a/mmgen/filename.py b/mmgen/filename.py index a154dbeb..5b626a51 100644 --- a/mmgen/filename.py +++ b/mmgen/filename.py @@ -36,9 +36,9 @@ class File: self.atime = None try: - st = os.stat(fn) + st = os.stat(str(fn)) except: - die('FileNotFound', f'{fn!r}: file not found') + die('FileNotFound', f'{fn!s}: file not found') import stat if stat.S_ISBLK(st.st_mode): diff --git a/mmgen/proto/xmr/tw/ctl.py b/mmgen/proto/xmr/tw/ctl.py index 9b8d316c..80dbc969 100644 --- a/mmgen/proto/xmr/tw/ctl.py +++ b/mmgen/proto/xmr/tw/ctl.py @@ -10,14 +10,19 @@ proto.xmr.tw.ctl: Monero tracking wallet control class """ -from ....tw.ctl import write_mode -from ....tw.store import TwCtlWithStore +from ....tw.ctl import TwCtl, write_mode -class MoneroTwCtl(TwCtlWithStore): +class MoneroTwCtl(TwCtl): - tw_subdir = 'tracking-wallets' use_cached_balances = True + async def __init__(self, cfg, proto, *, mode='r', **kwargs): + await super().__init__(cfg, proto, mode=mode, no_rpc=True) + + @classmethod + def get_tw_dir(cls, proto): + return proto.network_datadir / 'tracking-wallets' + @write_mode async def set_comment( self, diff --git a/mmgen/proto/xmr/tx/new.py b/mmgen/proto/xmr/tx/new.py index 9ea8138b..9328ae57 100644 --- a/mmgen/proto/xmr/tx/new.py +++ b/mmgen/proto/xmr/tx/new.py @@ -24,7 +24,7 @@ class New(Base, TxNew): async def get_input_addrs_from_inputs_opt(self): return [] # TODO - async def set_gas(self): + async def set_gas(self, *, to_addr=None, force=False): pass async def get_funds_remaining(self, fee, outputs_sum, start_fee_desc): diff --git a/mmgen/tw/store.py b/mmgen/tw/store.py index 5ff012a5..db502bb2 100644 --- a/mmgen/tw/store.py +++ b/mmgen/tw/store.py @@ -12,7 +12,6 @@ tw.store: Tracking wallet control class with store import json -from ..base_obj import AsyncInit from ..obj import TwComment from ..util import msg, die, cached_property from ..addr import is_coin_addr, is_mmgen_id, CoinAddr @@ -20,10 +19,9 @@ from ..addr import is_coin_addr, is_mmgen_id, CoinAddr from .shared import TwMMGenID, TwLabel from .ctl import TwCtl, write_mode, label_addr_pair -class TwCtlWithStore(TwCtl, metaclass=AsyncInit): +class TwCtlWithStore(TwCtl): caps = ('batch',) - tw_subdir = None tw_fn = 'tracking-wallet.json' aggressive_sync = False @@ -79,7 +77,7 @@ class TwCtlWithStore(TwCtl, metaclass=AsyncInit): @classmethod def get_tw_dir(cls, proto): - return proto.network_datadir / (cls.tw_subdir or '') + return proto.network_datadir def upgrade_wallet_maybe(self): pass diff --git a/test/cmdtest_d/autosign.py b/test/cmdtest_d/autosign.py index 43e1752e..580229aa 100644 --- a/test/cmdtest_d/autosign.py +++ b/test/cmdtest_d/autosign.py @@ -529,6 +529,7 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase): tweaks = [], expect_str = None, data_arg = None, + ui_handler_args = None, need_rbf = False): if output_args: @@ -563,10 +564,11 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase): t = (ui_handler or self.txcreate_ui_common)( t, - inputs = inputs, - interactive_fee = '32s', - tweaks = tweaks, - file_desc = 'Unsigned automount transaction') + **(ui_handler_args if ui_handler_args else { + 'inputs': inputs, + 'interactive_fee': '32s', + 'tweaks': tweaks, + 'file_desc': 'Unsigned automount transaction'})) return do_return() @@ -575,9 +577,11 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase): user, *, comment = None, + add_opts = [], no_wait = False, need_rbf = False, dump_hex = False, + expect_pat = None, mark_sent = False): if need_rbf and not self.proto.cap('rbf'): @@ -593,12 +597,15 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase): self.insert_device_online() t = self.spawn('mmgen-txsend', - [f'--{user}', '--quiet', '--autosign'] + extra_opt, no_passthru_opts=['coin']) + [f'--{user}', '--quiet', '--autosign'] + extra_opt + add_opts, no_passthru_opts=['coin']) - if mark_sent: + if '--status' in add_opts: + if expect_pat: + t.expect(expect_pat, regex=True) + elif mark_sent: t.written_to_file('Sent automount transaction') else: - t.view_tx('t') + t.view_tx('t', expect_pat=expect_pat) t.do_comment(comment) if dump_hex: t.written_to_file('Serialized transaction hex data') diff --git a/test/cmdtest_d/include/pexpect.py b/test/cmdtest_d/include/pexpect.py index 255fbab0..8c0fc92d 100644 --- a/test/cmdtest_d/include/pexpect.py +++ b/test/cmdtest_d/include/pexpect.py @@ -85,7 +85,7 @@ class CmdTestPexpect: if not have_yes_opt: self.expect('Check key-to-address validity? (y/N): ', ('n', 'y')[check]) - def view_tx(self, view): + def view_tx(self, view, *, expect_pat=None): self.expect(r'View.* transaction.*\? .*: ', view, regex=True) match view: case 'v' if cfg.pexpect_spawn: @@ -93,6 +93,8 @@ class CmdTestPexpect: case 'v' | 'n' | '\n': pass case _: + if expect_pat: + self.expect(expect_pat, regex=True) self.expect('to continue: ', '\n') def do_comment(self, add_comment, has_label=False): diff --git a/test/overlay/fakemods/mmgen/daemon.py b/test/overlay/fakemods/mmgen/daemon.py index c20ef522..7b5bc428 100644 --- a/test/overlay/fakemods/mmgen/daemon.py +++ b/test/overlay/fakemods/mmgen/daemon.py @@ -26,7 +26,6 @@ class overlay_fake_Daemon: @property def port_shift(self): - udata = { '': 0, 'miner': 1,