Skip to content

Commit 4b5bf33

Browse files
committed
test: Add coverage for failing dumptxoutset behavior
In case of a failure to create the dump, the node should not be left in an inconsistent state like deactivated network activity or an invalidated blockchain.
1 parent b8d2f58 commit 4b5bf33

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/functional/rpc_dumptxoutset.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run_test(self):
2828

2929
FILENAME = 'txoutset.dat'
3030
out = node.dumptxoutset(FILENAME, "latest")
31-
expected_path = node.datadir_path / self.chain / FILENAME
31+
expected_path = node.chain_path / FILENAME
3232

3333
assert expected_path.is_file()
3434

@@ -60,6 +60,16 @@ def run_test(self):
6060
assert_raises_rpc_error(
6161
-8, 'Invalid snapshot type "bogus" specified. Please specify "rollback" or "latest"', node.dumptxoutset, 'utxos.dat', "bogus")
6262

63+
self.log.info(f"Test that dumptxoutset failure does not leave the network activity suspended")
64+
rev_file = node.blocks_path / "rev00000.dat"
65+
bogus_file = node.blocks_path / "bogus.dat"
66+
rev_file.rename(bogus_file)
67+
assert_raises_rpc_error(
68+
-1, 'Could not roll back to requested height.', node.dumptxoutset, 'utxos.dat', rollback=99)
69+
assert_equal(node.getnetworkinfo()['networkactive'], True)
70+
71+
# Cleanup
72+
bogus_file.rename(rev_file)
6373

6474
if __name__ == '__main__':
6575
DumptxoutsetTest(__file__).main()

0 commit comments

Comments
 (0)