Skip to content

Commit 52482cb

Browse files
committed
test: Check datadir cleanup after assumeutxo was successful
1 parent 4571939 commit 52482cb

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

test/functional/feature_assumeutxo.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
The assumeutxo value generated and used here is committed to in
1010
`CRegTestParams::m_assumeutxo_data` in `src/kernel/chainparams.cpp`.
1111
"""
12+
import contextlib
1213
from shutil import rmtree
1314

1415
from dataclasses import dataclass
@@ -337,6 +338,22 @@ def assert_only_network_limited_service(self, node):
337338
assert 'NETWORK' not in node_services
338339
assert 'NETWORK_LIMITED' in node_services
339340

341+
@contextlib.contextmanager
342+
def assert_disk_cleanup(self, node, assumeutxo_used):
343+
"""
344+
Ensure an assumeutxo node is cleaning up the background chainstate
345+
"""
346+
msg = []
347+
if assumeutxo_used:
348+
# Check that the snapshot actually existed before restart
349+
assert (node.datadir_path / node.chain / "chainstate_snapshot").exists()
350+
msg = ["cleaning up unneeded background chainstate"]
351+
352+
with node.assert_debug_log(msg):
353+
yield
354+
355+
assert not (node.datadir_path / node.chain / "chainstate_snapshot").exists()
356+
340357
def run_test(self):
341358
"""
342359
Bring up two (disconnected) nodes, mine some new blocks on the first,
@@ -644,7 +661,8 @@ def check_tx_counts(final: bool) -> None:
644661
for i in (0, 1):
645662
n = self.nodes[i]
646663
self.log.info(f"Restarting node {i} to ensure (Check|Load)BlockIndex passes")
647-
self.restart_node(i, extra_args=self.extra_args[i])
664+
with self.assert_disk_cleanup(n, i == 1):
665+
self.restart_node(i, extra_args=self.extra_args[i])
648666

649667
assert_equal(n.getblockchaininfo()["blocks"], FINAL_HEIGHT)
650668

@@ -721,7 +739,8 @@ def check_tx_counts(final: bool) -> None:
721739
for i in (0, 2):
722740
n = self.nodes[i]
723741
self.log.info(f"Restarting node {i} to ensure (Check|Load)BlockIndex passes")
724-
self.restart_node(i, extra_args=self.extra_args[i])
742+
with self.assert_disk_cleanup(n, i == 2):
743+
self.restart_node(i, extra_args=self.extra_args[i])
725744

726745
assert_equal(n.getblockchaininfo()["blocks"], FINAL_HEIGHT)
727746

0 commit comments

Comments
 (0)