Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions test/functional/feature_assumeutxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
The assumeutxo value generated and used here is committed to in
`CRegTestParams::m_assumeutxo_data` in `src/kernel/chainparams.cpp`.
"""
import contextlib
from shutil import rmtree

from dataclasses import dataclass
Expand Down Expand Up @@ -337,6 +338,22 @@ def assert_only_network_limited_service(self, node):
assert 'NETWORK' not in node_services
assert 'NETWORK_LIMITED' in node_services

@contextlib.contextmanager
def assert_disk_cleanup(self, node, assumeutxo_used):
"""
Ensure an assumeutxo node is cleaning up the background chainstate
"""
msg = []
if assumeutxo_used:
# Check that the snapshot actually existed before restart
assert (node.datadir_path / node.chain / "chainstate_snapshot").exists()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: node.datadir_path / node.chain / "chainstate_snapshot" could be extracted to obviate that it's checked multiple times

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do if I have to retouch

msg = ["cleaning up unneeded background chainstate"]

with node.assert_debug_log(msg):
yield

assert not (node.datadir_path / node.chain / "chainstate_snapshot").exists()

def run_test(self):
"""
Bring up two (disconnected) nodes, mine some new blocks on the first,
Expand Down Expand Up @@ -644,7 +661,8 @@ def check_tx_counts(final: bool) -> None:
for i in (0, 1):
n = self.nodes[i]
self.log.info(f"Restarting node {i} to ensure (Check|Load)BlockIndex passes")
self.restart_node(i, extra_args=self.extra_args[i])
with self.assert_disk_cleanup(n, i == 1):
self.restart_node(i, extra_args=self.extra_args[i])

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

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

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

Expand Down