From ea4dd0a07405f54c8b1aa8aba3efcc262cd820b9 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 22 Feb 2024 12:48:42 +0000 Subject: [PATCH] autosign: use fakemod for test cfg initialization --- mmgen/autosign.py | 26 +++++++++---------------- mmgen/data/version | 2 +- test/overlay/fakemods/mmgen/autosign.py | 19 ++++++++++++++++++ 3 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 test/overlay/fakemods/mmgen/autosign.py diff --git a/mmgen/autosign.py b/mmgen/autosign.py index 8c1ad310..36b01a14 100755 --- a/mmgen/autosign.py +++ b/mmgen/autosign.py @@ -273,9 +273,14 @@ class Autosign: have_msg_dir = False - def __init__(self,cfg): + def init_cfg(self): # see test/overlay/fakemods/mmgen/autosign.py + self.mountpoint = Path(self.cfg.mountpoint or self.dfl_mountpoint) + self.wallet_dir = Path(self.cfg.wallet_dir or self.dfl_wallet_dir) + self.dev_label_path = Path(self.dfl_dev_label_dir) / self.dev_label + self.mount_cmd = 'mount' + self.umount_cmd = 'umount' - self.cfg = cfg + def __init__(self,cfg): if cfg.mnemonic_fmt: if cfg.mnemonic_fmt not in self.mn_fmts: @@ -283,21 +288,8 @@ class Autosign: cfg.mnemonic_fmt, fmt_list( self.mn_fmts, fmt='no_spc' ) )) - if pfx := cfg.test_suite_root_pfx: - subdir = 'online' if cfg.online else 'offline' - self.mountpoint = Path(f'{pfx}/{subdir}/{self.dfl_mountpoint}') - self.wallet_dir = Path(f'{pfx}/{subdir}/{self.dfl_wallet_dir}') - self.dev_label_path = Path(f'{pfx}/{subdir}/{self.dfl_dev_label_dir}') / self.dev_label - # mount --type=fuse-ext2 --options=rw+ ### current fuse-ext2 (0.4 29) is buggy - can’t use - self.fs_image_path = Path(f'{pfx}/removable_device_image') - self.mount_cmd = f'sudo mount {self.fs_image_path}' - self.umount_cmd = 'sudo umount' - else: - self.mountpoint = Path(cfg.mountpoint or self.dfl_mountpoint) - self.wallet_dir = Path(cfg.wallet_dir or self.dfl_wallet_dir) - self.dev_label_path = Path(self.dfl_dev_label_dir) / self.dev_label - self.mount_cmd = 'mount' - self.umount_cmd = 'umount' + self.cfg = cfg + self.init_cfg() self.tx_dir = self.mountpoint / 'tx' self.msg_dir = self.mountpoint / 'msg' diff --git a/mmgen/data/version b/mmgen/data/version index df01e33b..cd65be7b 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -14.1.dev11 +14.1.dev12 diff --git a/test/overlay/fakemods/mmgen/autosign.py b/test/overlay/fakemods/mmgen/autosign.py new file mode 100644 index 00000000..06432577 --- /dev/null +++ b/test/overlay/fakemods/mmgen/autosign.py @@ -0,0 +1,19 @@ +from .autosign_orig import * + +class overlay_fake_Autosign: + + def init_cfg(self): + if pfx := self.cfg.test_suite_root_pfx: + subdir = 'online' if self.cfg.online else 'offline' + self.mountpoint = Path(f'{pfx}/{subdir}/{self.dfl_mountpoint}') + self.wallet_dir = Path(f'{pfx}/{subdir}/{self.dfl_wallet_dir}') + self.dev_label_path = Path(f'{pfx}/{subdir}/{self.dfl_dev_label_dir}') / self.dev_label + # mount --type=fuse-ext2 --options=rw+ ### current fuse-ext2 (0.4 29) is buggy - can’t use + self.fs_image_path = Path(f'{pfx}/removable_device_image') + self.mount_cmd = f'sudo mount {self.fs_image_path}' + self.umount_cmd = 'sudo umount' + else: + self.init_cfg_orig() + +Autosign.init_cfg_orig = Autosign.init_cfg +Autosign.init_cfg = overlay_fake_Autosign.init_cfg