Browse Source

minor cleanups

The MMGen Project 1 year ago
parent
commit
0c5b361da8
5 changed files with 38 additions and 16 deletions
  1. 10 8
      mmgen/cfg.py
  2. 3 2
      mmgen/main_xmrwallet.py
  3. 4 1
      mmgen/util.py
  4. 13 2
      test/cmdtest_py_d/ct_input.py
  5. 8 3
      test/cmdtest_py_d/ct_xmr_autosign.py

+ 10 - 8
mmgen/cfg.py

@@ -157,14 +157,12 @@ class Config(Lockable):
 	devtools             = False
 
 	# rpc:
-	rpc_host                   = ''
-	rpc_port                   = 0
-	rpc_user                   = ''
-	rpc_password               = ''
-	monero_wallet_rpc_user     = 'monero'
-	monero_wallet_rpc_password = ''
-	aiohttp_rpc_queue_len      = 16
-	cached_balances            = False
+	rpc_host              = ''
+	rpc_port              = 0
+	rpc_user              = ''
+	rpc_password          = ''
+	aiohttp_rpc_queue_len = 16
+	cached_balances       = False
 
 	# daemons
 	daemon_data_dir       = '' # set by user
@@ -195,6 +193,10 @@ class Config(Lockable):
 	carol        = False
 	regtest_user = ''
 
+	# Monero:
+	monero_wallet_rpc_user     = 'monero'
+	monero_wallet_rpc_password = ''
+
 	# test suite:
 	bogus_send               = False
 	bogus_unspent_data       = ''

+ 3 - 2
mmgen/main_xmrwallet.py

@@ -20,9 +20,10 @@
 mmgen-xmrwallet: Perform various Monero wallet and transacting operations for
                  addresses in an MMGen XMR key-address file
 """
+import asyncio
 
 from .cfg import gc,Config
-from .util import die,async_run
+from .util import die
 from .xmrwallet import (
 	MoneroWalletOps,
 	xmrwallet_uarg_info,
@@ -146,7 +147,7 @@ op_cls = getattr(MoneroWalletOps,op.replace('-','_'))
 
 m = op_cls(cfg, xmrwallet_uargs(infile, wallets, spec))
 
-if async_run(m.main()):
+if asyncio.run(m.main()):
 	m.post_main_success()
 else:
 	m.post_main_failure()

+ 4 - 1
mmgen/util.py

@@ -208,12 +208,15 @@ def fmt_dict(mapping,fmt='dfl',kconv=None,vconv=None):
 	"pretty-format a dict"
 	kc,vc,sep,fs = {
 		'dfl':           ( str, str,  ", ",  "'{}' ({})" ),
+		'dfl_compact':   ( str, str,  " ",   "{} ({})" ),
 		'square':        ( str, str,  ", ",  "'{}' [{}]" ),
+		'square_compact':( str, str,  " ",   "{} [{}]" ),
 		'equal':         ( str, str,  ", ",  "'{}'={}" ),
 		'equal_spaced':  ( str, str,  ", ",  "'{}' = {}" ),
-		'equal_compact': ( str, str,  ",",   "'{}'={}" ),
+		'equal_compact': ( str, str,  " ",   "{}={}" ),
 		'kwargs':        ( str, repr, ", ",  "{}={}" ),
 		'colon':         ( str, repr, ", ",  "{}:{}" ),
+		'colon_compact': ( str, str,  " ",   "{}:{}" ),
 	}[fmt]
 	kconv = kconv or kc
 	vconv = vconv or vc

+ 13 - 2
test/cmdtest_py_d/ct_input.py

@@ -383,7 +383,14 @@ class CmdTestInput(CmdTestBase):
 		t.expect(sample_mn[fmt]['hex'])
 		return t
 
-	def _user_seed_entry(self,fmt,usr_rand=False,out_fmt=None,entry_mode='full',mn=None):
+	def _user_seed_entry(
+			self,
+			fmt,
+			usr_rand    = False,
+			out_fmt     = None,
+			entry_mode  = 'full',
+			mn          = None):
+
 		wcls = get_wallet_cls(fmt_code=fmt)
 		wf = os.path.join(ref_dir,f'FE3C6545.{wcls.ext}')
 		if wcls.base_type == 'mnemonic':
@@ -392,7 +399,11 @@ class CmdTestInput(CmdTestBase):
 			mn = mn or list(remove_whitespace(read_from_file(wf)))
 			for idx,val in ((5,'x'),(18,'0'),(30,'7'),(44,'9')):
 				mn.insert(idx,val)
-		t = self.spawn('mmgen-walletconv',['-r10','-S','-i',fmt,'-o',out_fmt or fmt])
+		t = self.spawn(
+			'mmgen-walletconv',
+			['--usr-randchars=10', '--stdout']
+			+ [f'--in-fmt={fmt}', f'--out-fmt={out_fmt or fmt}']
+		)
 		t.expect(f'{capfirst(wcls.base_type or wcls.type)} type:.*{wcls.mn_type}',regex=True)
 		t.expect(wcls.choose_seedlen_prompt,'1')
 		t.expect('(Y/n): ','y')

+ 8 - 3
test/cmdtest_py_d/ct_xmr_autosign.py

@@ -87,12 +87,12 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignThreaded):
 		('export_outputs3',          'exporting outputs from Alice’s watch-only wallets'),
 		('import_key_images2',       'importing signed key images into Alice’s online wallets'),
 		('sync_chkbal3',             'syncing Alice’s wallets and checking balance'),
-		('txlist',                   'listing Alice’s submitted transactions'),
 		('autosign_kill_thread',     'stopping autosign wait loop'),
 		('stop_daemons',             'stopping all wallet and coin daemons'),
-		('check_tx_dirs',            'cleaning and checking signable file directories'),
 		('view',                     'viewing Alice’s wallet in offline mode (wallet #1)'),
 		('listview',                 'list-viewing Alice’s wallet in offline mode (wallet #2)'),
+		('txlist',                   'listing Alice’s submitted transactions'),
+		('check_tx_dirs',            'cleaning and checking signable file directories'),
 	)
 
 	def __init__(self,trunner,cfgs,spawn):
@@ -243,7 +243,12 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignThreaded):
 
 	def _create_transfer_tx(self,amt):
 		self.insert_device_online()
-		t = self.do_op('transfer','alice',f'1:0:{self.burn_addr},{amt}',no_relay=True,do_ret=True)
+		t = self.do_op(
+			'transfer',
+			'alice',
+			f'1:0:{self.burn_addr},{amt}',
+			no_relay = True,
+			do_ret   = True)
 		t.read() # required!
 		self.remove_device_online()
 		return t