Browse Source

test suite: minor cleanups

The MMGen Project 3 years ago
parent
commit
54e9799989
4 changed files with 19 additions and 23 deletions
  1. 5 3
      mmgen/wallet.py
  2. 3 3
      test/misc/opts.py
  3. 5 5
      test/test_py_d/ts_opts.py
  4. 6 12
      test/test_py_d/ts_regtest.py

+ 5 - 3
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

+ 3 - 3
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) ))

+ 5 - 5
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'),
 				)
 			)
 

+ 6 - 12
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