From de346d1470dfc3aad9202a6453dbdb753eac327e Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 24 Feb 2024 14:17:31 +0000 Subject: [PATCH] minor fixes and cleanups --- mmgen/autosign.py | 3 +-- scripts/exec_wrapper.py | 2 +- test/cmdtest_py_d/ct_autosign.py | 33 ++++++++++++++++++-------------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/mmgen/autosign.py b/mmgen/autosign.py index 7fa115d9..f6c4c2ca 100755 --- a/mmgen/autosign.py +++ b/mmgen/autosign.py @@ -13,6 +13,7 @@ autosign: Auto-sign MMGen transactions, message files and XMR wallet output file """ import sys,os,asyncio +from stat import S_ISDIR,S_IWUSR,S_IRUSR from pathlib import Path from subprocess import run,DEVNULL @@ -370,8 +371,6 @@ class Autosign: def do_mount(self,silent=False,no_dir_chk=False,no_xmr_chk=False): - from stat import S_ISDIR,S_IWUSR,S_IRUSR - def check_dir(cdir): try: ds = cdir.stat() diff --git a/scripts/exec_wrapper.py b/scripts/exec_wrapper.py index ac4a7feb..9d3f7a52 100755 --- a/scripts/exec_wrapper.py +++ b/scripts/exec_wrapper.py @@ -27,7 +27,7 @@ def exec_wrapper_init(): if exec_wrapper_os.path.dirname(exec_wrapper_sys.argv[1]) == 'test': # support running of test scripts under wrapper - exec_wrapper_sys.path[0] = exec_wrapper_os.getcwd() # assume we’re in repo root + exec_wrapper_sys.path[0] = exec_wrapper_os.path.join('test', 'overlay', 'tree') else: exec_wrapper_sys.path.pop(0) diff --git a/test/cmdtest_py_d/ct_autosign.py b/test/cmdtest_py_d/ct_autosign.py index e65a7622..561256e3 100755 --- a/test/cmdtest_py_d/ct_autosign.py +++ b/test/cmdtest_py_d/ct_autosign.py @@ -40,7 +40,9 @@ from ..include.common import ( stop_test_daemons, joinpath, imsg, - read_from_file + read_from_file, + silence, + end_silence, ) from .common import ref_dir,dfl_words_file,dfl_bip39_file @@ -156,6 +158,17 @@ class CmdTestAutosignBase(CmdTestBase): t.written_to_file('Autosign wallet') return t + @property + def device_inserted(self): + return self.asi.dev_label_path.exists() + + def insert_device(self): + self.asi.dev_label_path.touch() + + def remove_device(self): + if self.asi.dev_label_path.exists(): + self.asi.dev_label_path.unlink() + def _mount_ops(self, loc, cmd, *args, **kwargs): return getattr(getattr(self,loc),cmd)(*args, silent=self.silent_mount, **kwargs) @@ -222,17 +235,7 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase): time.sleep(0.5) imsg('') self.remove_device() - - @property - def device_inserted(self): - return self.asi.dev_label_path.exists() - - def insert_device(self): - self.asi.dev_label_path.touch() - - def remove_device(self): - if self.asi.dev_label_path.exists(): - self.asi.dev_label_path.unlink() + return 'ok' @property def device_inserted_online(self): @@ -387,14 +390,16 @@ class CmdTestAutosign(CmdTestAutosignBase): if op == 'set_count': return + silence() self.do_mount() + end_silence() for coindir,fn in data: src = joinpath(ref_dir,coindir,fn) if cfg.debug_utf8: ext = '.testnet.rawtx' if fn.endswith('.testnet.rawtx') else '.rawtx' fn = fn[:-len(ext)] + '-α' + ext - target = joinpath(self.asi.mountpoint,'tx',fn) + target = joinpath(self.asi.tx_dir, fn) if not op == 'remove_signed': shutil.copyfile(src,target) try: @@ -419,7 +424,7 @@ class CmdTestAutosign(CmdTestAutosignBase): self.do_mount() # create or delete 2 bad tx files self.spawn('',msg_only=True) - fns = [joinpath(self.asi.mountpoint,'tx',f'bad{n}.rawtx') for n in (1,2)] + fns = [joinpath(self.asi.tx_dir, f'bad{n}.rawtx') for n in (1,2)] if op == 'create': for fn in fns: with open(fn,'w') as fp: