Skip to content

Commit cd8089c

Browse files
committed
Merge bitcoin#32069: test: fix intermittent failure in wallet_reorgsrestore.py
36b0713 test: fix intermittent failure in wallet_reorgsrestore.py (furszy) Pull request description: In response to bitcoin#32066 intermittent failure. Wait until the node's process has fully stopped before starting a new instance of it. Same behavior as in the [tool_wallet.py](https://github.com/bitcoin/bitcoin/blob/698f86964c68041d938aaf54fdd39466266c371c/test/functional/tool_wallet.py#L540) test. ACKs for top commit: maflcko: lgtm ACK 36b0713 Chand-ra: tACK [36b0713](bitcoin@36b0713) Tree-SHA512: 8e01493ef1fb58589479f3e12d7429d02ca75a2183d5f79d3b6a2fbf13334878926274a20857f1b4729afc1d30b65789daed229ce06ba236b91d949b73f45d5a
2 parents 70a0ee8 + 36b0713 commit cd8089c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

test/functional/test_framework/test_node.py

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

+1-4
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

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