cmdtest.py xmrswap: whitespace, cleanups

This commit is contained in:
The MMGen Project 2026-10-23 17:01:26 +00:00
commit cc8ed19ee9
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 28 additions and 20 deletions

View file

@ -666,6 +666,9 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
return 'silent'
def wait_loop_kill(self):
self.spawn(msg_only=True)
if self.cfg.no_daemon_stop:
return 'skip_msg'
return self._kill_process_from_pid_file('autosign_thread_pid', 'autosign wait loop')
def _wait_signed(self, desc):

View file

@ -136,8 +136,13 @@ 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)
pid = int(self.read_from_tmpfile(fn))
try:
pid = int(self.read_from_tmpfile(fn))
except Exception as e:
if 'Unable to open file' in str(e):
imsg(f'PID file {fn!r} not found, skipping')
return 'skip_msg'
raise
self.delete_tmpfile(fn)
from signal import SIGTERM
imsg(purple(f'Killing {desc} [PID {pid}]'))

View file

@ -131,18 +131,18 @@ class CmdTestXMRSwap(CmdTestXMRSwapMethods, CmdTestSwap):
xmr_prompt = 'efresh balances:\b'
cmd_group_in = (
('setup', 'regtest (Bob and Alice) mode setup'),
('subgroup.ltc_setup', []),
('subgroup.xmr_setup', []),
('subgroup.swap', ['ltc_setup', 'xmr_setup']),
('subgroup.xmr_swap', ['swap']),
('xmr_wait_loop_kill', 'stopping autosign wait loop'),
('xmr_stop_daemons', 'stopping the XMR daemons'))
('setup', 'regtest (Bob and Alice) mode setup'),
('subgroup.ltc_setup', []),
('subgroup.xmr_setup', []),
('subgroup.swap', ['ltc_setup', 'xmr_setup']),
('subgroup.xmr_swap', ['swap']),
('xmr_wait_loop_kill', ''),
('xmr_stop_daemons', ''))
cmd_subgroups = {
'ltc_setup': (
'creating Bob’s MMGen wallet and tracking wallet',
('walletconv_bob', 'wallet creation (Bob)'),
'setting up Bob’s MMGen wallet and tracking wallet',
('walletconv_bob', 'MMGen wallet creation (Bob)'),
('addrgen_bob', 'address generation (Bob)'),
('addrimport_bob', 'importing Bob’s addresses'),
('bob_import_miner_addr', 'importing miner’s coinbase addr into Bob’s wallet'),
@ -153,7 +153,7 @@ class CmdTestXMRSwap(CmdTestXMRSwapMethods, CmdTestSwap):
('bob_bal1', 'Bob’s balance'),
),
'xmr_setup': (
'setting miner’s and user’s XMR tracking wallets',
'setting up miner’s and Bob’s XMR tracking wallets',
('xmr_autosign_setup', ''),
('xmr_autosign_xmr_setup', ''),
('xmr_addrimport_user', ''),
@ -176,27 +176,27 @@ class CmdTestXMRSwap(CmdTestXMRSwapMethods, CmdTestSwap):
('rune_addrimport', 'importing RUNE addresses'),
('rune_bal_refresh', 'refreshing balances in RUNE tracking wallet'),
('remote_get_refnum', 'getting the reference number'),
('swaptxcreate_refreq1', 'creating an LTC->XMR swap transaction (refreq, auto chg, auto dest)'),
('swaptxcreate_refreq1', 'creating an LTC->XMR registration transaction (auto chg, auto dest)'),
('swaptxcreate_abort1', 'aborting the transaction'),
('swaptxcreate_refreq2', 'creating an LTC->XMR swap transaction (refreq, auto chg, 1:0)'),
('swaptxcreate_refreq2', 'creating an LTC->XMR registration transaction (auto chg, 1:0)'),
('swaptxcreate_abort2', 'aborting the transaction'),
('swaptxcreate_refreq3', 'creating an LTC->XMR swap transaction (refreq, auto chg, mmid dest)'),
('swaptxcreate_refreq3', 'creating an LTC->XMR registration transaction (auto chg, mmid dest)'),
('swaptxsend_refreq1', 'sending the transaction'),
('swaptxcreate_refreq4', 'creating an LTC->XMR swap transaction (refreq, auto chg, 1:1)'),
('swaptxcreate_refreq4', 'creating an LTC->XMR registration transaction (auto chg, 1:1)'),
('swaptxsend_refreq2', 'sending the transaction'),
('swaptxcreate_refnum1', 'creating an LTC->XMR swap transaction (swap, auto chg, auto dest)'),
('swaptxcreate_refnum1', 'creating an LTC->XMR swap transaction (auto chg, auto dest)'),
('swaptxsend_refnum1', 'sending the swap transaction'),
('generate_ltc', 'generating a block'),
('swaptxcreate_refnum2', 'creating an LTC->XMR swap transaction (swap, no chg, auto dest)'),
('swaptxcreate_refnum2', 'creating an LTC->XMR swap transaction (no chg, auto dest)'),
('swaptxsend_refnum2', 'sending the swap transaction'),
('generate_ltc', 'generating a block'),
('bob_bal2', 'Bob’s balance')),
'xmr_swap': (
'swap operations (XMR -> LTC)',
('remote_get_refnum_xmr', 'getting the reference number'),
('swaptxcreate_refreq7', 'creating an XMR->LTC swap transaction (refreq, auto chg, auto dest)'),
('swaptxcreate_refreq7', 'creating an XMR->LTC registration transaction (auto chg, auto dest)'),
('swaptxsend_refreq7', 'sending the transaction'),
('swaptxcreate_refnum7', 'creating an XMR->LTC swap transaction (swap, auto chg, auto dest)'),
('swaptxcreate_refnum7', 'creating an XMR->LTC swap transaction (auto chg, auto dest)'),
('swaptxsend_refnum7', 'sending the transaction'),
('xmr_mine_blocks_10', ''),
('swaptxstatus_refnum7', 'getting the transaction status'))}