mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 06:49:38 -04:00
Merge bitcoin/bitcoin#32033: test: Check datadir cleanup after assumeutxo was successful
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
52482cb244
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: utACK52482cb244
mabu44: Re-ACK52482cb244
Prabhat1308: re-ACK [`52482cb`](52482cb244
) TheCharlatan: Re-ACK52482cb244
Tree-SHA512: cc941afeba250050eaccf5112255d961253fec9b2683545454a0d2fbe4d542178394b301d169a9dd79edbf6b5d478d95282727dbb0aca96ee79d4cd1ff80f19b
This commit is contained in:
commit
257fd27e4b
1 changed files with 21 additions and 2 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue