test suite autosign: refactor wait loop thread

This commit is contained in:
The MMGen Project 2024-09-02 09:43:47 +00:00
commit d9bd57c1cf
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 20 additions and 19 deletions

View file

@ -43,7 +43,7 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtestBDBWallet)
('alice_txcreate_bad_have_unsigned', 'creating the transaction again (error)'),
('copy_wallet', 'copying Alice’s wallet'),
('alice_run_autosign_setup', 'running ‘autosign setup’ (with default wallet)'),
('autosign_start_thread', 'starting autosign wait loop'),
('wait_loop_start', 'starting autosign wait loop'),
('alice_txstatus1', 'getting transaction status (unsigned)'),
('alice_txstatus2', 'getting transaction status (unsent)'),
('alice_txcreate_bad_have_unsent', 'creating the transaction again (error)'),
@ -66,7 +66,7 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtestBDBWallet)
('alice_txsend2', 'sending the transaction'),
('alice_txbump3', 'bumping the transaction'),
('alice_txsend3', 'sending the bumped transaction'),
('autosign_kill_thread', 'stopping autosign wait loop'),
('wait_loop_kill', 'stopping autosign wait loop'),
('stop', 'stopping regtest daemon'),
('txview', 'viewing transactions'),
)

View file

@ -33,7 +33,7 @@ class CmdTestAutosignETH(CmdTestAutosignThreaded, CmdTestEthdev):
('fund_mmgen_address', 'funding an MMGen address'),
('create_tx', 'creating a transaction'),
('run_autosign_setup', 'running ‘autosign setup’'),
('autosign_start_thread', 'starting autosign wait loop'),
('wait_loop_start', 'starting autosign wait loop'),
('send_tx', 'sending the transaction'),
('token_compile1', 'compiling ERC20 token #1'),
('token_deploy1a', 'deploying ERC20 token #1 (SafeMath)'),
@ -47,7 +47,7 @@ class CmdTestAutosignETH(CmdTestAutosignThreaded, CmdTestEthdev):
('create_token_tx', 'creating a token transaction'),
('send_token_tx', 'sending a token transaction'),
('token_bal2', f'the {cfg.coin} balance and token balance'),
('autosign_kill_thread', 'stopping autosign wait loop'),
('wait_loop_kill', 'stopping autosign wait loop'),
('stop', 'stopping daemon'),
('txview', 'viewing transactions'),
)

View file

@ -406,22 +406,23 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
no_insert_check = False
threaded = True
def autosign_start_thread(self):
def run():
t = self.spawn(
'mmgen-autosign',
self.opts + ['--full-summary', 'wait'],
direct_exec = True,
no_passthru_opts = True,
spawn_env_override = self.spawn_env | {'EXEC_WRAPPER_DO_RUNTIME_MSG': ''})
self.write_to_tmpfile('autosign_thread_pid',str(t.ep.pid))
import threading
threading.Thread(target=run, name='Autosign wait loop').start()
time.sleep(0.2)
def _wait_loop_start(self):
t = self.spawn(
'mmgen-autosign',
self.opts + ['--full-summary', 'wait'],
direct_exec = True,
no_passthru_opts = True,
spawn_env_override = self.spawn_env | {'EXEC_WRAPPER_DO_RUNTIME_MSG': ''})
self.write_to_tmpfile('autosign_thread_pid', str(t.ep.pid))
return t
def wait_loop_start(self):
import threading
threading.Thread(target=self._wait_loop_start, name='Autosign wait loop').start()
time.sleep(0.1) # try to ensure test output is displayed before next test starts
return 'silent'
def autosign_kill_thread(self):
def wait_loop_kill(self):
self.spawn('',msg_only=True)
pid = int(self.read_from_tmpfile('autosign_thread_pid'))
self.delete_tmpfile('autosign_thread_pid')

View file

@ -69,7 +69,7 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignThreaded):
('check_bal_alice1', 'mining, checking balance (wallet #1)'),
('fund_alice2', 'sending funds to Alice (wallet #2)'),
('check_bal_alice2', 'mining, checking balance (wallet #2)'),
('autosign_start_thread', 'starting autosign wait loop'),
('wait_loop_start', 'starting autosign wait loop'),
('export_outputs1', 'exporting outputs from Alice’s watch-only wallet #1'),
('create_transfer_tx1', 'creating a transfer TX'),
('submit_transfer_tx1', 'submitting the transfer TX'),
@ -90,7 +90,7 @@ 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'),
('autosign_kill_thread', 'stopping autosign wait loop'),
('wait_loop_kill', 'stopping autosign wait loop'),
('stop_daemons', 'stopping all wallet and coin daemons'),
('view', 'viewing Alice’s wallet in offline mode (wallet #1)'),
('listview', 'list-viewing Alice’s wallet in offline mode (wallet #2)'),