Browse Source

cmdtest.spawn_wrapper(): make `cmd` a keyword arg

The MMGen Project 2 weeks ago
parent
commit
79e008ce43

+ 1 - 1
test/cmdtest.py

@@ -543,7 +543,7 @@ class CmdTestRunner:
 
 	def spawn_wrapper(
 			self,
-			cmd,
+			cmd             = '',
 			args            = [],
 			extra_desc      = '',
 			no_output       = False,

+ 8 - 8
test/cmdtest_d/ct_autosign.py

@@ -181,12 +181,12 @@ class CmdTestAutosignBase(CmdTestBase):
 			pass
 
 	def start_daemons(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		start_test_daemons(*self.network_ids)
 		return 'ok'
 
 	def stop_daemons(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		stop_test_daemons(*self.network_ids, remove_datadir=True)
 		return 'ok'
 
@@ -378,7 +378,7 @@ class CmdTestAutosignClean(CmdTestAutosignBase):
 
 	def _clean(self, coins):
 
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 
 		self.insert_device()
 
@@ -589,7 +589,7 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
 		return self._mount_ops('asi_online', 'do_umount', *args, **kwargs)
 
 	async def txview(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		self.insert_device()
 		self.do_mount()
 		src = Path(self.asi.txauto_dir)
@@ -754,7 +754,7 @@ class CmdTestAutosign(CmdTestAutosignBase):
 		return t
 
 	def copy_tx_files(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		return self.tx_file_ops('copy')
 
 	def remove_signed_txfiles(self):
@@ -822,7 +822,7 @@ class CmdTestAutosign(CmdTestAutosignBase):
 		self.insert_device()
 		self.do_mount()
 		# create or delete 2 bad tx files
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		fns = [joinpath(self.asi.tx_dir, f'bad{n}.rawtx') for n in (1, 2)]
 		if op == 'create':
 			for fn in fns:
@@ -853,7 +853,7 @@ class CmdTestAutosign(CmdTestAutosignBase):
 		return self.msgfile_ops('remove_invalid')
 
 	def msgfile_ops(self, op):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		destdir = joinpath(self.asi.mountpoint, 'msg')
 		self.insert_device()
 		self.do_mount()
@@ -1060,7 +1060,7 @@ class CmdTestAutosignLive(CmdTestAutosignBTC):
 			info_msg = 'Running ‘mmgen-autosign wait’'
 			insert_msg = 'Insert removable device '
 
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 
 		self.do_umount()
 		prompt_remove()

+ 1 - 1
test/cmdtest_d/ct_base.py

@@ -125,7 +125,7 @@ class CmdTestBase:
 		return [f'--cashaddr={val}'] if self.proto.coin == 'BCH' else []
 
 	def _kill_process_from_pid_file(self, fn, desc):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		pid = int(self.read_from_tmpfile(fn))
 		self.delete_tmpfile(fn)
 		from signal import SIGTERM

+ 9 - 9
test/cmdtest_d/ct_ethdev.py

@@ -472,7 +472,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
 			time.sleep(0.5)
 
 	async def setup(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 
 		d = self.daemon
 
@@ -848,7 +848,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
 		if not self.daemon.id == 'geth':
 			return 'skip'
 
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 
 		sig = '0x' + create_signature_mmgen()
 		sig_chk = await create_signature_rpc()
@@ -1002,7 +1002,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
 		if not self.using_solc:
 			imsg(f'Using precompiled contract data in {odir}')
 			return 'skip' if os.path.exists(odir) else False
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		cmd_args = [f'--{k}={v}' for k, v in list(token_data.items())]
 		imsg("Compiling solidity token contract '{}' with 'solc'".format(token_data['symbol']))
 		try:
@@ -1103,7 +1103,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
 		return await self.token_deploy(num=2, key='Token',   gas=4_000_000)
 
 	async def token_transfer_ops(self, op, amt=1000, num_tokens=2):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		sid = dfl_sid
 		from mmgen.tool.wallet import tool_cmd
 		usr_mmaddrs = [f'{sid}:E:{i}' for i in (11, 21)][:num_tokens]
@@ -1503,7 +1503,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
 		return t
 
 	async def twmove(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		from mmgen.tw.ctl import TwCtl
 		twctl = await TwCtl(cfg, self.proto, no_wallet_init=True)
 		imsg('Moving tracking wallet')
@@ -1526,7 +1526,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
 		return self.twimport(add_args=['ignore_checksum=true'], expect_str='ignoring incorrect checksum')
 
 	def tw_chktotal(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		from mmgen.tw.json import TwJSON
 		fn = joinpath(self.tmpdir, TwJSON.Base(cfg, self.proto).dump_fn)
 		res = json.loads(read_from_file(fn))
@@ -1534,7 +1534,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
 		return 'ok'
 
 	async def twcompare(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		from mmgen.tw.ctl import TwCtl
 		twctl = await TwCtl(cfg, self.proto, no_wallet_init=True)
 		fn = twctl.tw_path
@@ -1545,7 +1545,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
 		return 'ok'
 
 	def edit_json_twdump(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		from mmgen.tw.json import TwJSON
 		fn = TwJSON.Base(cfg, self.proto).dump_fn
 		text = json.loads(self.read_from_tmpfile(fn))
@@ -1555,7 +1555,7 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
 		return 'ok'
 
 	def stop(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		if not cfg.no_daemon_stop:
 			if not stop_test_daemons(self.proto.coin+'_rt', remove_datadir=True):
 				return False

+ 1 - 1
test/cmdtest_d/ct_input.py

@@ -108,7 +108,7 @@ class CmdTestInput(CmdTestBase):
 	}
 
 	def get_seed_from_stdin(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		from subprocess import run, PIPE
 		cmd = ['python3', 'cmds/mmgen-walletconv', '--skip-cfg-file', '--in-fmt=words', '--out-fmt=words', '--outdir=test/trash']
 		mn = sample_mn['mmgen']['mn']

+ 1 - 1
test/cmdtest_d/ct_main.py

@@ -433,7 +433,7 @@ class CmdTestMain(CmdTestBase, CmdTestShared):
 			return 'skip'
 		for wf in [f for f in os.listdir(cfg.data_dir) if f[-6:]=='.mmdat']:
 			os.unlink(joinpath(cfg.data_dir, wf))
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		self.have_dfl_wallet = False
 		return 'ok'
 

+ 4 - 4
test/cmdtest_d/ct_regtest.py

@@ -723,7 +723,7 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
 	async def bob_recreate_tracking_wallet(self):
 		if not self.deterministic:
 			return 'skip'
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		await self.rt.stop()
 		from shutil import rmtree
 		imsg('Deleting Bob’s old tracking wallet')
@@ -1253,7 +1253,7 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
 
 	def _get_mempool(self, do_msg=False):
 		if do_msg:
-			self.spawn('', msg_only=True)
+			self.spawn(msg_only=True)
 		return self._do_mmgen_regtest(['mempool'], decode_json=True)
 
 	def _get_mempool_compare_txid(self, txid1, txid2):
@@ -1534,7 +1534,7 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
 		return self._bob_twprune_selected(resp='sssSpP', npruned=7)
 
 	def bob_edit_json_twdump(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		from mmgen.tw.json import TwJSON
 		fn = TwJSON.Base(cfg, self.proto).dump_fn
 		text = json.loads(self.read_from_tmpfile(fn))
@@ -2257,7 +2257,7 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
 		return self._user_bal_cli('bob', chks=['499.99990287', '46.51845565'])
 
 	def stop(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		if cfg.no_daemon_stop:
 			msg_r(f'(leaving regtest daemon{suf(self.protos)} running by user request)')
 			imsg('')

+ 1 - 1
test/cmdtest_d/ct_swap.py

@@ -728,7 +728,7 @@ class CmdTestSwap(CmdTestRegtest, CmdTestAutosignThreaded):
 		return self._mempool(2)
 
 	def _mempool(self, proto_idx):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		data = self._do_cli(['getrawmempool'], add_opts=[f'--coin={self.protos[proto_idx].coin}'])
 		assert data
 		return 'ok'

+ 3 - 3
test/cmdtest_d/ct_xmr_autosign.py

@@ -123,7 +123,7 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 		self.spawn_env['MMGEN_TEST_SUITE_XMR_AUTOSIGN'] = '1'
 
 	def create_tmp_wallets(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		data = self.users['alice']
 		from mmgen.wallet import Wallet
 		from mmgen.xmrwallet import op
@@ -191,7 +191,7 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 
 	def _delete_files(self, *ext_list):
 		data = self.users['alice']
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		for ext in ext_list:
 			get_file_with_ext(data.udir, ext, no_dot=True, delete_all=True)
 		return 'ok'
@@ -432,7 +432,7 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded):
 		return t
 
 	def txview_all(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		self.insert_device()
 		self.do_mount()
 		imsg(blue('Opening transaction directory: ') + cyan(f'{self.asi.xmr_tx_dir}'))

+ 4 - 8
test/cmdtest_d/ct_xmrwallet.py

@@ -423,14 +423,14 @@ class CmdTestXMRWallet(CmdTestBase):
 			r'Creating new address for wallet .*4.*, account .*#2.* with label .*‘Alice’s new address .*y/N\): ')
 
 	async def mine_initial_coins(self):
-		self.spawn('', msg_only=True, extra_desc='(opening wallet)')
+		self.spawn(msg_only=True, extra_desc='(opening wallet)')
 		await self.open_wallet_user('miner', 1)
 		ok()
 		# NB: a large balance is required to avoid ‘insufficient outputs’ error
 		return await self.mine_chk('miner', 1, 0, lambda x: x.ub > 2000, 'unlocked balance > 2000')
 
 	async def fund_alice(self, wallet=1, amt=1234567891234):
-		self.spawn('', msg_only=True, extra_desc='(transferring funds from Miner wallet)')
+		self.spawn(msg_only=True, extra_desc='(transferring funds from Miner wallet)')
 		await self.transfer(
 			'miner',
 			amt,
@@ -887,11 +887,7 @@ class CmdTestXMRWallet(CmdTestBase):
 		return ret['status']
 
 	def do_msg(self, extra_desc=None):
-		self.spawn(
-			'',
-			msg_only = True,
-			extra_desc = f'({extra_desc})' if extra_desc else None
-		)
+		self.spawn(msg_only=True, extra_desc=f'({extra_desc})' if extra_desc else None)
 
 	async def transfer(self, user, amt, addr):
 		return self.users[user].wd_rpc.call('transfer', destinations=[{'amount':amt, 'address':addr}])
@@ -904,7 +900,7 @@ class CmdTestXMRWallet(CmdTestBase):
 			v.md.start()
 
 	def stop_daemons(self):
-		self.spawn('', msg_only=True)
+		self.spawn(msg_only=True)
 		if cfg.no_daemon_stop:
 			omsg('[not stopping daemons at user request]')
 		else: