Skip to content

Commit 257fd27

Browse files
committed
Merge bitcoin#32033: test: Check datadir cleanup after assumeutxo was successful
52482cb test: Check datadir cleanup after assumeutxo was successful (Fabian Jahr) Pull request description: I noticed that the proper datadir cleanup after a successful restart of an assumutxo node does not seem to be covered in our tests. This is added here. ACKs for top commit: l0rinc: utACK 52482cb mabu44: Re-ACK 52482cb Prabhat1308: re-ACK [`52482cb`](bitcoin@52482cb) TheCharlatan: Re-ACK 52482cb Tree-SHA512: cc941afeba250050eaccf5112255d961253fec9b2683545454a0d2fbe4d542178394b301d169a9dd79edbf6b5d478d95282727dbb0aca96ee79d4cd1ff80f19b
2 parents db2c57a + 52482cb commit 257fd27

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
@@ -349,6 +350,22 @@ def assert_only_network_limited_service(self, node):
349350
assert 'NETWORK' not in node_services
350351
assert 'NETWORK_LIMITED' in node_services
351352

353+
@contextlib.contextmanager
354+
def assert_disk_cleanup(self, node, assumeutxo_used):
355+
"""
356+
Ensure an assumeutxo node is cleaning up the background chainstate
357+
"""
358+
msg = []
359+
if assumeutxo_used:
360+
# Check that the snapshot actually existed before restart
361+
assert (node.datadir_path / node.chain / "chainstate_snapshot").exists()
362+
msg = ["cleaning up unneeded background chainstate"]
363+
364+
with node.assert_debug_log(msg):
365+
yield
366+
367+
assert not (node.datadir_path / node.chain / "chainstate_snapshot").exists()
368+
352369
def run_test(self):
353370
"""
354371
Bring up two (disconnected) nodes, mine some new blocks on the first,
@@ -656,7 +673,8 @@ def check_tx_counts(final: bool) -> None:
656673
for i in (0, 1):
657674
n = self.nodes[i]
658675
self.log.info(f"Restarting node {i} to ensure (Check|Load)BlockIndex passes")
659-
self.restart_node(i, extra_args=self.extra_args[i])
676+
with self.assert_disk_cleanup(n, i == 1):
677+
self.restart_node(i, extra_args=self.extra_args[i])
660678

661679
assert_equal(n.getblockchaininfo()["blocks"], FINAL_HEIGHT)
662680

@@ -733,7 +751,8 @@ def check_tx_counts(final: bool) -> None:
733751
for i in (0, 2):
734752
n = self.nodes[i]
735753
self.log.info(f"Restarting node {i} to ensure (Check|Load)BlockIndex passes")
736-
self.restart_node(i, extra_args=self.extra_args[i])
754+
with self.assert_disk_cleanup(n, i == 2):
755+
self.restart_node(i, extra_args=self.extra_args[i])
737756

738757
assert_equal(n.getblockchaininfo()["blocks"], FINAL_HEIGHT)
739758

0 commit comments

Comments
 (0)