diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py index 66204682e3c..df2fdc96435 100755 --- a/test/functional/feature_assumeutxo.py +++ b/test/functional/feature_assumeutxo.py @@ -9,6 +9,7 @@ to a hash that has been compiled into bitcoind. 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 @@ -349,6 +350,22 @@ class AssumeutxoTest(BitcoinTestFramework): 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() + 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, @@ -656,7 +673,8 @@ class AssumeutxoTest(BitcoinTestFramework): 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) @@ -733,7 +751,8 @@ class AssumeutxoTest(BitcoinTestFramework): 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)