Browse Source

cmdtest autosign,xmr_autosign: minor cleanups

The MMGen Project 1 year ago
parent
commit
2e8e22fcde
2 changed files with 25 additions and 26 deletions
  1. 4 4
      test/cmdtest_py_d/ct_autosign.py
  2. 21 22
      test/cmdtest_py_d/ct_xmr_autosign.py

+ 4 - 4
test/cmdtest_py_d/ct_autosign.py

@@ -68,8 +68,8 @@ class CmdTestAutosignBase(CmdTestBase):
 	networks     = ('btc',)
 	networks     = ('btc',)
 	tmpdir_nums  = [18]
 	tmpdir_nums  = [18]
 	color        = True
 	color        = True
+	win_skip     = True
 	no_insert_check = True
 	no_insert_check = True
-	win_skip = True
 	have_online = False
 	have_online = False
 
 
 	def __init__(self,trunner,cfgs,spawn):
 	def __init__(self,trunner,cfgs,spawn):
@@ -531,7 +531,7 @@ class CmdTestAutosignLive(CmdTestAutosignBTC):
 
 
 		omsg(purple(f'Running autosign test with {opts_msg}'))
 		omsg(purple(f'Running autosign test with {opts_msg}'))
 
 
-		self.do_umount_online()
+		self.do_umount()
 		prompt_remove()
 		prompt_remove()
 		omsg(green(info_msg))
 		omsg(green(info_msg))
 		t = self.spawn(
 		t = self.spawn(
@@ -541,9 +541,9 @@ class CmdTestAutosignLive(CmdTestAutosignBTC):
 			omsg('')
 			omsg('')
 		prompt_insert_sign(t)
 		prompt_insert_sign(t)
 
 
-		self.do_mount_online() # race condition due to device insertion detection
+		self.do_mount() # race condition due to device insertion detection
 		self.remove_signed_txfiles()
 		self.remove_signed_txfiles()
-		self.do_umount_online()
+		self.do_umount()
 
 
 		imsg(purple('\nKilling wait loop!'))
 		imsg(purple('\nKilling wait loop!'))
 		t.kill(2) # 2 = SIGINT
 		t.kill(2) # 2 = SIGINT

+ 21 - 22
test/cmdtest_py_d/ct_xmr_autosign.py

@@ -44,10 +44,10 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignBase):
 	"""
 	"""
 	Monero autosigning operations
 	Monero autosigning operations
 	"""
 	"""
-
 	tmpdir_nums = [39]
 	tmpdir_nums = [39]
 
 
 	# ct_xmrwallet attrs:
 	# ct_xmrwallet attrs:
+	tx_relay_user = 'miner'
 	user_data = (
 	user_data = (
 		('miner', '98831F3A', False, 130, '1', []),
 		('miner', '98831F3A', False, 130, '1', []),
 		('alice', 'FE3C6545', True,  150, '1-2', []),
 		('alice', 'FE3C6545', True,  150, '1-2', []),
@@ -60,7 +60,6 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignBase):
 	live         = False
 	live         = False
 	simulate_led = False
 	simulate_led = False
 	bad_tx_count = 0
 	bad_tx_count = 0
-	tx_relay_user = 'miner'
 	no_insert_check = False
 	no_insert_check = False
 	win_skip = True
 	win_skip = True
 	have_online = True
 	have_online = True
@@ -126,8 +125,8 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignBase):
 
 
 		self.burn_addr = make_burn_addr()
 		self.burn_addr = make_burn_addr()
 
 
-		self.opts.append('--xmrwallets={}'.format(self.users['alice'].kal_range))     # mmgen-autosign opts
-		self.autosign_opts = ['--autosign']                                           # mmgen-xmrwallet opts
+		self.opts.append('--xmrwallets={}'.format(self.users['alice'].kal_range)) # mmgen-autosign opts
+		self.autosign_opts = ['--autosign']                                       # mmgen-xmrwallet opts
 		self.tx_count = 1
 		self.tx_count = 1
 		self.spawn_env['MMGEN_TEST_SUITE_XMR_AUTOSIGN'] = '1'
 		self.spawn_env['MMGEN_TEST_SUITE_XMR_AUTOSIGN'] = '1'
 
 
@@ -294,8 +293,8 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignBase):
 		self.do_umount_online()
 		self.do_umount_online()
 		return self._create_transfer_tx('0.257')
 		return self._create_transfer_tx('0.257')
 
 
-	def _wait_signed(self,dtype):
-		oqmsg_r(gray(f'→ offline wallet{"s" if dtype.endswith("s") else ""} signing {dtype}'))
+	def _wait_signed(self,desc):
+		oqmsg_r(gray(f'→ offline wallet{"s" if desc.endswith("s") else ""} signing {desc}'))
 		assert not self.device_inserted, f'‘{self.asi.dev_label_path}’ is inserted!'
 		assert not self.device_inserted, f'‘{self.asi.dev_label_path}’ is inserted!'
 		assert not self.asi.mountpoint.is_mount(), f'‘{self.asi.mountpoint}’ is mounted!'
 		assert not self.asi.mountpoint.is_mount(), f'‘{self.asi.mountpoint}’ is mounted!'
 		self.insert_device()
 		self.insert_device()
@@ -316,14 +315,14 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignBase):
 	def _xmr_autosign_op(
 	def _xmr_autosign_op(
 			self,
 			self,
 			op,
 			op,
-			desc        = None,
-			dtype       = None,
-			ext         = None,
-			wallet_arg  = None,
-			add_opts    = [],
-			wait_signed = False):
+			desc          = None,
+			signable_desc = None,
+			ext           = None,
+			wallet_arg    = None,
+			add_opts      = [],
+			wait_signed   = False):
 		if wait_signed:
 		if wait_signed:
-			self._wait_signed(dtype)
+			self._wait_signed(signable_desc)
 		data = self.users['alice']
 		data = self.users['alice']
 		args = (
 		args = (
 			self.extra_opts
 			self.extra_opts
@@ -379,11 +378,11 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignBase):
 	def _submit_transfer_tx(self,relay_parm=None,ext=None,op='submit',check_bal=True):
 	def _submit_transfer_tx(self,relay_parm=None,ext=None,op='submit',check_bal=True):
 		self.insert_device_online()
 		self.insert_device_online()
 		t = self._xmr_autosign_op(
 		t = self._xmr_autosign_op(
-			op       = op,
-			add_opts = [f'--tx-relay-daemon={relay_parm}'] if relay_parm else [],
-			ext      = ext,
-			dtype    = 'transaction',
-			wait_signed = op == 'submit' )
+			op            = op,
+			add_opts      = [f'--tx-relay-daemon={relay_parm}'] if relay_parm else [],
+			ext           = ext,
+			signable_desc = 'transaction',
+			wait_signed   = op == 'submit')
 		t.expect( f'{op.capitalize()} transaction? (y/N): ', 'y' )
 		t.expect( f'{op.capitalize()} transaction? (y/N): ', 'y' )
 		t.written_to_file('Submitted transaction')
 		t.written_to_file('Submitted transaction')
 		self.remove_device_online()
 		self.remove_device_online()
@@ -412,10 +411,10 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignBase):
 	def _import_key_images(self,wallet_arg):
 	def _import_key_images(self,wallet_arg):
 		self.insert_device_online()
 		self.insert_device_online()
 		t = self._xmr_autosign_op(
 		t = self._xmr_autosign_op(
-			op    = 'import-key-images',
-			wallet_arg = wallet_arg,
-			dtype = 'wallet outputs',
-			wait_signed = True )
+			op            = 'import-key-images',
+			wallet_arg    = wallet_arg,
+			signable_desc = 'wallet outputs',
+			wait_signed   = True)
 		t.read()
 		t.read()
 		self.remove_device_online()
 		self.remove_device_online()
 		return t
 		return t