mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-26 14:59:16 +02:00
Merge bitcoin/bitcoin#30817: test: Add coverage for dumptxoutset failure robustness
c2b779da4erefactor: Manage dumptxoutset RAII classes with std::optional (Fabian Jahr)4b5bf335adtest: Add coverage for failing dumptxoutset behavior (Fabian Jahr) Pull request description: This adds a test that checks that network activity is not suspended if dumptxoutset fails in the middle of its process which is implemented with the `NetworkDisable` RAII class. I would have liked to add coverage for the `TemporaryRollback` RAII class but that seems a lot more tricky since the failure needs to happen at some point after the rollback and on the scale of our test chain here I couldn't find a way to do it yet. This was requested by pablomartin4btc here: https://github.com/bitcoin/bitcoin/pull/30808#pullrequestreview-2280450117. To test the test you can comment out the content of the destructor of `NetworkDisable`. It also addresses the feedback by ryanofsky to use `std::optional` instead of `std::unique_ptr` for the management of the RAII object: https://github.com/bitcoin/bitcoin/pull/30808#discussion_r1744149228 ACKs for top commit: achow101: ACKc2b779da4epablomartin4btc: cr & tACKc2b779da4etdb3: ACKc2b779da4eBrandonOdiwuor: Code Review ACKc2b779da4etheStack: ACKc2b779da4eTree-SHA512: 9556e75014a2599bb870b70faf887608b332f2312626333f771d4ec11c04f863a2cf17e223ec473d4e8b0c9e8008394a4e0c321561f7ef3a2eec713dcfaea58a
This commit is contained in:
@@ -28,7 +28,7 @@ class DumptxoutsetTest(BitcoinTestFramework):
|
||||
|
||||
FILENAME = 'txoutset.dat'
|
||||
out = node.dumptxoutset(FILENAME, "latest")
|
||||
expected_path = node.datadir_path / self.chain / FILENAME
|
||||
expected_path = node.chain_path / FILENAME
|
||||
|
||||
assert expected_path.is_file()
|
||||
|
||||
@@ -60,6 +60,16 @@ class DumptxoutsetTest(BitcoinTestFramework):
|
||||
assert_raises_rpc_error(
|
||||
-8, 'Invalid snapshot type "bogus" specified. Please specify "rollback" or "latest"', node.dumptxoutset, 'utxos.dat', "bogus")
|
||||
|
||||
self.log.info(f"Test that dumptxoutset failure does not leave the network activity suspended")
|
||||
rev_file = node.blocks_path / "rev00000.dat"
|
||||
bogus_file = node.blocks_path / "bogus.dat"
|
||||
rev_file.rename(bogus_file)
|
||||
assert_raises_rpc_error(
|
||||
-1, 'Could not roll back to requested height.', node.dumptxoutset, 'utxos.dat', rollback=99)
|
||||
assert_equal(node.getnetworkinfo()['networkactive'], True)
|
||||
|
||||
# Cleanup
|
||||
bogus_file.rename(rev_file)
|
||||
|
||||
if __name__ == '__main__':
|
||||
DumptxoutsetTest(__file__).main()
|
||||
|
||||
Reference in New Issue
Block a user