|
9 | 9 | The assumeutxo value generated and used here is committed to in
|
10 | 10 | `CRegTestParams::m_assumeutxo_data` in `src/kernel/chainparams.cpp`.
|
11 | 11 | """
|
| 12 | +import contextlib |
12 | 13 | from shutil import rmtree
|
13 | 14 |
|
14 | 15 | from dataclasses import dataclass
|
@@ -337,6 +338,22 @@ def assert_only_network_limited_service(self, node):
|
337 | 338 | assert 'NETWORK' not in node_services
|
338 | 339 | assert 'NETWORK_LIMITED' in node_services
|
339 | 340 |
|
| 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 | + |
340 | 357 | def run_test(self):
|
341 | 358 | """
|
342 | 359 | Bring up two (disconnected) nodes, mine some new blocks on the first,
|
@@ -644,7 +661,8 @@ def check_tx_counts(final: bool) -> None:
|
644 | 661 | for i in (0, 1):
|
645 | 662 | n = self.nodes[i]
|
646 | 663 | 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]) |
648 | 666 |
|
649 | 667 | assert_equal(n.getblockchaininfo()["blocks"], FINAL_HEIGHT)
|
650 | 668 |
|
@@ -721,7 +739,8 @@ def check_tx_counts(final: bool) -> None:
|
721 | 739 | for i in (0, 2):
|
722 | 740 | n = self.nodes[i]
|
723 | 741 | 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]) |
725 | 744 |
|
726 | 745 | assert_equal(n.getblockchaininfo()["blocks"], FINAL_HEIGHT)
|
727 | 746 |
|
|
0 commit comments