From 54e9799989d7320513e78ca7ab6556d435758392 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 19 Jan 2022 11:43:52 +0000 Subject: [PATCH] test suite: minor cleanups --- mmgen/wallet.py | 8 +++++--- test/misc/opts.py | 6 +++--- test/test_py_d/ts_opts.py | 10 +++++----- test/test_py_d/ts_regtest.py | 18 ++++++------------ 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/mmgen/wallet.py b/mmgen/wallet.py index 5f5d2dc8..3d4572a1 100755 --- a/mmgen/wallet.py +++ b/mmgen/wallet.py @@ -73,7 +73,8 @@ class Wallet(MMGenObject,metaclass=WalletMeta): passchg = False, in_data = None, ignore_in_fmt = False, - in_fmt = None ): + in_fmt = None, + passwd_file = None ): in_fmt = in_fmt or opt.in_fmt @@ -129,9 +130,10 @@ class Wallet(MMGenObject,metaclass=WalletMeta): passchg = False, in_data = None, ignore_in_fmt = False, - in_fmt = None ): + in_fmt = None, + passwd_file = None ): - self.passwd_file = opt.passwd_file + self.passwd_file = passwd_file or opt.passwd_file self.ssdata = self.WalletData() self.msg = {} self.in_data = in_data diff --git a/test/misc/opts.py b/test/misc/opts.py index ca5927a9..5b73355a 100755 --- a/test/misc/opts.py +++ b/test/misc/opts.py @@ -23,8 +23,8 @@ opts_data = { outputs (default: 1) -p, --hash-preset= p Use the scrypt hash parameters defined by preset 'p' -P, --passwd-file= f Get wallet passphrase from file 'f' --u, --subseeds= n The number of subseed pairs to scan for -q, --quiet Be quieter +-X, --cached-balances Use cached balances (Ethereum only) -v, --verbose Be more verbose """, 'notes': """ @@ -57,7 +57,7 @@ for k in ( 'fee_estimate_mode', # autoset_opts 'passwd_file', # infile_opts - check_infile() 'outdir', # check_outdir() - 'subseeds', # opt_sets_global + 'cached_balances', # opt_sets_global 'minconf', # global_sets_opt 'hidden_incog_input_params', ): @@ -65,7 +65,7 @@ for k in ( msg('') for k in ( - 'subseeds', # opt_sets_global + 'cached_balances', # opt_sets_global 'minconf', # global_sets_opt ): msg('{:30} {}'.format( f'g.{k}:', getattr(opt,k) )) diff --git a/test/test_py_d/ts_opts.py b/test/test_py_d/ts_opts.py index c04c15a4..74738374 100755 --- a/test/test_py_d/ts_opts.py +++ b/test/test_py_d/ts_opts.py @@ -64,9 +64,9 @@ class TestSuiteOpts(TestSuiteBase): ('opt.fee_estimate_mode', 'conservative'), # autoset_opts ('opt.passwd_file', 'None'), # infile_opts - check_infile() ('opt.outdir', 'None'), # check_outdir() - ('opt.subseeds', 'None'), # opt_sets_global + ('opt.cached_balances', 'None'), # opt_sets_global ('opt.minconf', '1'), # global_sets_opt - ('g.subseeds', 'None'), + ('g.cached_balances', 'None'), ('g.minconf', '1'), ) ) @@ -81,7 +81,7 @@ class TestSuiteOpts(TestSuiteBase): '--fee-estimate-mode=E', '--passwd-file='+pf, '--outdir='+self.tmpdir, - '--subseeds=200', + '--cached-balances', f'--hidden-incog-input-params={pf},123', ], ( @@ -90,9 +90,9 @@ class TestSuiteOpts(TestSuiteBase): ('opt.fee_estimate_mode', 'economical'), ('opt.passwd_file', pf), ('opt.outdir', self.tmpdir), - ('opt.subseeds', '200'), + ('opt.cached_balances', 'True'), ('opt.hidden_incog_input_params', pf+',123'), - ('g.subseeds', '200'), + ('g.cached_balances', 'True'), ) ) diff --git a/test/test_py_d/ts_regtest.py b/test/test_py_d/ts_regtest.py index 3a8c5699..8e7249c9 100755 --- a/test/test_py_d/ts_regtest.py +++ b/test/test_py_d/ts_regtest.py @@ -258,7 +258,6 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): ('stop', 'stopping regtest daemon'), ) - usr_subsids = { 'bob': {}, 'alice': {} } def __init__(self,trunner,cfgs,spawn): TestSuiteBase.__init__(self,trunner,cfgs,spawn) @@ -278,6 +277,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): self.miner_wif = 'cTEkSYCWKvNo757uwFPd4yuCXsbZvfJDipHsHWFRapXpnikMHvgn' os.environ['MMGEN_BOGUS_SEND'] = '' + self.write_to_tmpfile('wallet_password',rt_pw) def __del__(self): os.environ['MMGEN_BOGUS_SEND'] = '1' @@ -334,17 +334,11 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared): return os.path.basename(get_file_with_ext(self._user_dir(user),'mmdat'))[:8] def _get_user_subsid(self,user,subseed_idx): - - if subseed_idx in self.usr_subsids[user]: - return self.usr_subsids[user][subseed_idx] - - wcls = MMGenWallet - fn = get_file_with_ext(self._user_dir(user),wcls.ext) - t = self.spawn('mmgen-tool',['get_subseed',subseed_idx,'wallet='+fn],no_msg=True,no_exec_wrapper=True) - t.passphrase(wcls.desc,rt_pw) - sid = t.read().strip()[:8] - self.usr_subsids[user][subseed_idx] = sid - return sid + fn = get_file_with_ext(self._user_dir(user),MMGenWallet.ext) + silence() + w = Wallet( fn=fn, passwd_file=os.path.join(self.tmpdir,'wallet_password') ) + end_silence() + return w.seed.subseed(subseed_idx).sid def addrgen(self,user,wf=None,addr_range='1-5',subseed_idx=None,mmtypes=[]): from mmgen.addr import MMGenAddrType