Skip to content

Commit 36b0713

Browse files
committed
test: fix intermittent failure in wallet_reorgsrestore.py
Wait until the node's process has fully stopped before starting a new instance. Since the same code is used in tool_wallet.py, this consolidates the behavior into a 'kill_process()' function.
1 parent 698f869 commit 36b0713

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

test/functional/test_framework/test_node.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,11 @@ def wait_until_stopped(self, *, timeout=BITCOIND_PROC_WAIT_TIMEOUT, expect_error
443443
kwargs["expected_ret_code"] = 1 if expect_error else 0 # Whether node shutdown return EXIT_FAILURE or EXIT_SUCCESS
444444
self.wait_until(lambda: self.is_node_stopped(**kwargs), timeout=timeout)
445445

446+
def kill_process(self):
447+
self.process.kill()
448+
self.wait_until_stopped(expected_ret_code=1 if platform.system() == "Windows" else -9)
449+
assert self.is_node_stopped()
450+
446451
def replace_in_config(self, replacements):
447452
"""
448453
Perform replacements in the configuration file.

test/functional/tool_wallet.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""Test bitcoin-wallet."""
66

77
import os
8-
import platform
98
import random
109
import stat
1110
import string
@@ -536,9 +535,7 @@ def test_dump_unclean_lsns(self):
536535
# Next cause a bunch of writes by filling the keypool
537536
wallet.keypoolrefill(wallet.getwalletinfo()["keypoolsize"] + 100)
538537
# Lastly kill bitcoind so that the LSNs don't get reset
539-
self.nodes[0].process.kill()
540-
self.nodes[0].wait_until_stopped(expected_ret_code=1 if platform.system() == "Windows" else -9)
541-
assert self.nodes[0].is_node_stopped()
538+
self.nodes[0].kill_process()
542539

543540
wallet_dump = self.nodes[0].datadir_path / "unclean_lsn.dump"
544541
self.assert_raises_tool_error("LSNs are not reset, this database is not completely flushed. Please reopen then close the database with a version that has BDB support", "-wallet=unclean_lsn", f"-dumpfile={wallet_dump}", "dump")

test/functional/wallet_reorgsrestore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_reorg_handling_during_unclean_shutdown(self):
115115
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], True)
116116

117117
# Abort process abruptly to mimic an unclean shutdown (no chain state flush to disk)
118-
node.process.kill()
118+
node.kill_process()
119119

120120
# Restart the node and confirm that it has not persisted the last chain state changes to disk
121121
self.start_node(0)

0 commit comments

Comments
 (0)