From 0c5b361da888d9ecfa9f39cf47982ec9f0768635 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 11 Mar 2024 10:28:39 +0000 Subject: [PATCH] minor cleanups --- mmgen/cfg.py | 18 ++++++++++-------- mmgen/main_xmrwallet.py | 5 +++-- mmgen/util.py | 5 ++++- test/cmdtest_py_d/ct_input.py | 15 +++++++++++++-- test/cmdtest_py_d/ct_xmr_autosign.py | 11 ++++++++--- 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index be84a905..e2db18a1 100755 --- a/mmgen/cfg.py +++ b/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 = '' diff --git a/mmgen/main_xmrwallet.py b/mmgen/main_xmrwallet.py index f5df6c2f..ebf78d87 100755 --- a/mmgen/main_xmrwallet.py +++ b/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() diff --git a/mmgen/util.py b/mmgen/util.py index 7ef68bf7..5749d67f 100755 --- a/mmgen/util.py +++ b/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 diff --git a/test/cmdtest_py_d/ct_input.py b/test/cmdtest_py_d/ct_input.py index da01ec26..129900fc 100755 --- a/test/cmdtest_py_d/ct_input.py +++ b/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') diff --git a/test/cmdtest_py_d/ct_xmr_autosign.py b/test/cmdtest_py_d/ct_xmr_autosign.py index dbe29621..f2b4a0da 100755 --- a/test/cmdtest_py_d/ct_xmr_autosign.py +++ b/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