Browse Source

minor fixes and cleanups

The MMGen Project 6 months ago
parent
commit
b9a6e725d1

+ 1 - 1
mmgen/autosign.py

@@ -340,7 +340,7 @@ class Autosign:
 		to your fstab as described in this script’s help text.
 	"""
 
-	mn_fmts    = {
+	mn_fmts = {
 		'mmgen': 'words',
 		'bip39': 'bip39',
 	}

+ 1 - 1
mmgen/cfg.py

@@ -58,7 +58,7 @@ class GlobalConstants(Lockable):
 	if sys.platform not in ('linux', 'win32', 'darwin'):
 		die2(1,f'{sys.platform!r}: platform not supported by {proj_name}')
 
-	if os.getenv('HOME'):   # Linux or MSYS2
+	if os.getenv('HOME'):   # Linux, MSYS2, or macOS
 		home_dir = os.getenv('HOME')
 	elif sys.platform == 'win32': # Windows without MSYS2 - not supported
 		die2(1,f'$HOME not set!  {proj_name} for Windows must be run in MSYS2 environment')

+ 1 - 1
mmgen/filename.py

@@ -42,7 +42,7 @@ class File:
 
 		import stat
 		if stat.S_ISBLK(st.st_mode):
-			if sys.platform in ('win32',):
+			if sys.platform in ('win32', 'darwin'):
 				die(2, 'Access to raw block devices not supported on platform {sys.platform!r}')
 			mode = (os.O_RDONLY,os.O_RDWR)[bool(write)]
 			try:

+ 1 - 1
mmgen/fileutil.py

@@ -86,7 +86,7 @@ def _check_file_type_and_access(fname,ftype,blkdev_ok=False):
 			(stat.S_ISLNK,'symbolic link')
 		]
 		if blkdev_ok:
-			if not sys.platform in ('win32',):
+			if not sys.platform in ('win32', 'darwin'):
 				ok_types.append((stat.S_ISBLK, 'block device'))
 
 	try:

+ 1 - 1
mmgen/main_xmrwallet.py

@@ -115,7 +115,7 @@ opts_data = {
 	}
 }
 
-cfg = Config(opts_data=opts_data)
+cfg = Config(opts_data=opts_data, init_opts={'coin':'xmr'})
 
 cmd_args = cfg._args
 

+ 1 - 1
mmgen/tx/util.py

@@ -21,7 +21,7 @@ def get_autosign_obj(cfg):
 			'test_suite': cfg.test_suite,
 			'test_suite_root_pfx': cfg.test_suite_root_pfx,
 			'coins': cfg.coin,
-			'online': True, # used only in online environment (txcreate, txsend)
+			'online': not cfg.offline, # used only in online environment (xmrwallet, txcreate, txsend, txbump)
 		})
 	)
 

+ 1 - 12
mmgen/xmrwallet.py

@@ -57,6 +57,7 @@ from .proto.xmr.rpc import MoneroRPCClient,MoneroWalletRPCClient
 from .proto.xmr.daemon import MoneroWalletDaemon
 from .ui import keypress_confirm
 from .autosign import Autosign
+from .tx.util import get_autosign_obj
 
 xmrwallet_uargs = namedtuple('xmrwallet_uargs',[
 	'infile',
@@ -77,18 +78,6 @@ xmrwallet_uarg_info = (
 		r'(?:[^:]+):(?:\d+)'
 	)
 
-def get_autosign_obj(cfg):
-	from .cfg import Config
-	return Autosign(
-		Config({
-			'mountpoint': cfg.autosign_mountpoint,
-			'test_suite': cfg.test_suite,
-			'test_suite_root_pfx': cfg.test_suite_root_pfx,
-			'coins': 'xmr',
-			'online': not cfg.offline,
-		})
-	)
-
 # required to squelch pylint:
 def fmt_amt(amt):
 	return str(amt)

+ 3 - 0
test/cmdtest.py

@@ -997,6 +997,9 @@ if __name__ == '__main__':
 		tr.warn_skipped()
 		if tr.daemon_started:
 			stop_test_daemons(network_id)
+		if hasattr(tr, 'tg'):
+			del tr.tg
+		del tr
 	except KeyboardInterrupt:
 		if tr.daemon_started:
 			stop_test_daemons(network_id)

+ 1 - 1
test/cmdtest_py_d/ct_automount.py

@@ -249,7 +249,7 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtestBDBWallet)
 			t.expect('Only sent transactions')
 			t.expect(bad_tx_desc)
 		else:
-			t.expect(f'to deduct the fee from .* change output\): ', '\n', regex=True)
+			t.expect(r'to deduct the fee from .* change output\): ', '\n', regex=True)
 			t.expect(r'(Y/n): ', 'y')  # output OK?
 			t.expect('transaction fee: ', '200s\n')
 			t.expect(r'(Y/n): ', 'y')  # fee OK?

+ 15 - 11
test/cmdtest_py_d/ct_autosign.py

@@ -82,24 +82,28 @@ class CmdTestAutosignBase(CmdTestBase):
 
 	def _create_autosign_instances(self,create_dirs):
 		d = {'offline': {'name':'asi'}}
+
 		if self.have_online:
 			d['online'] =  {'name':'asi_online'}
+
 		for subdir,data in d.items():
+			asi = Autosign(
+				Config({
+					'coins': ','.join(self.coins),
+					'test_suite': True,
+					'test_suite_xmr_autosign': self.name == 'CmdTestXMRAutosign',
+					'test_suite_autosign_threaded': self.threaded,
+					'test_suite_root_pfx': None if self.live else self.tmpdir,
+					'online': subdir == 'online',
+				}))
+
 			if create_dirs and not self.live:
-				for k in ('mountpoint','wallet_dir','dev_label_dir'):
+				for k in ('mountpoint', 'wallet_dir', 'dev_label_dir'):
 					if k == 'wallet_dir' and subdir == 'online':
 						continue
 					(Path(self.tmpdir) / (subdir + getattr(Autosign,'dfl_'+k))).mkdir(parents=True,exist_ok=True)
-			setattr(self,data['name'],
-				Autosign(
-					Config({
-						'coins': ','.join(self.coins),
-						'test_suite': True,
-						'test_suite_xmr_autosign': self.name == 'CmdTestXMRAutosign',
-						'test_suite_autosign_threaded': self.threaded,
-						'test_suite_root_pfx': None if self.live else self.tmpdir,
-						'online': subdir == 'online',
-					})))
+
+			setattr(self, data['name'], asi)
 
 	def _create_removable_device(self):
 		redir = DEVNULL

+ 1 - 1
test/cmdtest_py_d/ct_input.py

@@ -471,7 +471,7 @@ class CmdTestInput(CmdTestBase):
 			from mmgen.mn_entry import mn_entry
 			mne = mn_entry( cfg, fmt, entry_mode )
 			t.expect('Type a number.*: ',str(mne.entry_modes.index(entry_mode)+1),regex=True)
-			t.expect('Using entry mode (\S+)',regex=True)
+			t.expect(r'Using entry mode (\S+)',regex=True)
 			mode = strip_ansi_escapes(t.p.match.group(1)).lower()
 			assert mode == mne.em.name.lower(), f'{mode} != {mne.em.name.lower()}'
 			stealth_mnemonic_entry(t,mne,mn,entry_mode=entry_mode)

+ 2 - 2
test/cmdtest_py_d/ct_misc.py

@@ -217,10 +217,10 @@ class CmdTestHelp(CmdTestBase):
 		if 'tx' not in self.proto.mmcaps:
 			scripts = [s for s in scripts if not (s == 'regtest' or s.startswith('tx'))]
 
-		if self.proto.coin not in ('BTC','XMR') and 'xmrwallet' in scripts:
+		if 'xmrwallet' in scripts and (cfg.no_altcoin or not self.proto.coin in ('BTC','XMR')):
 			scripts.remove('xmrwallet')
 
-		if sys.platform == 'win32' and 'autosign' in scripts:
+		if 'autosign' in scripts and sys.platform == 'win32':
 			scripts.remove('autosign')
 
 		for s in sorted(scripts):