|
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
|
@@ -349,6 +350,22 @@ def assert_only_network_limited_service(self, node):
|
349 | 350 | assert 'NETWORK' not in node_services
|
350 | 351 | assert 'NETWORK_LIMITED' in node_services
|
351 | 352 |
|
| 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 | + |
352 | 369 | def run_test(self):
|
353 | 370 | """
|
354 | 371 | Bring up two (disconnected) nodes, mine some new blocks on the first,
|
@@ -656,7 +673,8 @@ def check_tx_counts(final: bool) -> None:
|
656 | 673 | for i in (0, 1):
|
657 | 674 | n = self.nodes[i]
|
658 | 675 | 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]) |
660 | 678 |
|
661 | 679 | assert_equal(n.getblockchaininfo()["blocks"], FINAL_HEIGHT)
|
662 | 680 |
|
@@ -733,7 +751,8 @@ def check_tx_counts(final: bool) -> None:
|
733 | 751 | for i in (0, 2):
|
734 | 752 | n = self.nodes[i]
|
735 | 753 | 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]) |
737 | 756 |
|
738 | 757 | assert_equal(n.getblockchaininfo()["blocks"], FINAL_HEIGHT)
|
739 | 758 |
|
|
0 commit comments