Browse Source

minor fixes and cleanups

The MMGen Project 1 year ago
parent
commit
de346d1470
3 changed files with 21 additions and 17 deletions
  1. 1 2
      mmgen/autosign.py
  2. 1 1
      scripts/exec_wrapper.py
  3. 19 14
      test/cmdtest_py_d/ct_autosign.py

+ 1 - 2
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()

+ 1 - 1
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)
 

+ 19 - 14
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: