Skip to content

Commit f83565d

Browse files
committed
Merge bitcoin/bitcoin#29394: test, assumeutxo: Add test to ensure failure when mempool not empty
8d20602 test, assumeutxo: Add test to ensure failure when mempool not empty (Hernan Marino) Pull request description: Add a test to ensure that loadtxoutset fails when the node's mempool is not empty, as suggested by maflcko here: bitcoin/bitcoin#27596 (comment) ACKs for top commit: maflcko: re-ACK 8d20602 BrandonOdiwuor: ACK 8d20602 Tree-SHA512: 97c9668c0f38897934bf0d326515d898d4e682ff219deba9d751b35125b5cf33d51c9df116a74117ecf0394f28995a3d0cae1266b1e5acb4365ff4f309ce3f6c
2 parents 37fdf5a + 8d20602 commit f83565d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/functional/feature_assumeutxo.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def set_test_params(self):
6060
self.extra_args = [
6161
[],
6262
["-fastprune", "-prune=1", "-blockfilterindex=1", "-coinstatsindex=1"],
63-
["-txindex=1", "-blockfilterindex=1", "-coinstatsindex=1"],
63+
["-persistmempool=0","-txindex=1", "-blockfilterindex=1", "-coinstatsindex=1"],
6464
]
6565

6666
def setup_network(self):
@@ -135,6 +135,19 @@ def expected_error(log_msg="", error_msg=""):
135135
rmtree(chainstate_snapshot_path)
136136
self.start_node(0)
137137

138+
def test_invalid_mempool_state(self, dump_output_path):
139+
self.log.info("Test bitcoind should fail when mempool not empty.")
140+
node=self.nodes[2]
141+
tx = MiniWallet(node).send_self_transfer(from_node=node)
142+
143+
assert tx['txid'] in node.getrawmempool()
144+
145+
# Attempt to load the snapshot on Node 2 and expect it to fail
146+
with node.assert_debug_log(expected_msgs=["[snapshot] can't activate a snapshot when mempool not empty"]):
147+
assert_raises_rpc_error(-32603, "Unable to load UTXO snapshot", node.loadtxoutset, dump_output_path)
148+
149+
self.restart_node(2, extra_args=self.extra_args[2])
150+
138151
def run_test(self):
139152
"""
140153
Bring up two (disconnected) nodes, mine some new blocks on the first,
@@ -197,6 +210,7 @@ def run_test(self):
197210

198211
assert_equal(n0.getblockchaininfo()["blocks"], FINAL_HEIGHT)
199212

213+
self.test_invalid_mempool_state(dump_output['path'])
200214
self.test_invalid_snapshot_scenarios(dump_output['path'])
201215
self.test_invalid_chainstate_scenarios()
202216

0 commit comments

Comments
 (0)