Skip to content

Commit 87d5450

Browse files
committed
Merge bitcoin/bitcoin#30892: test: Check already deactivated network stays suspended after dumptxoutset
72c9a1f test: Check that network stays suspended after dumptxoutset if it was off before (Fabian Jahr) Pull request description: Follow-up to #30817 which covered the robustness of `dumptxoutset`: network is deactivated during the run but re-activated even when an issue was encountered. But it did not cover the case if the user had deactivated the network themselves before. In that case the user may want the network to stay off so the network is not reactivated after `dumptxoutset` finishes. A test for this behavior is added here. ACKs for top commit: achow101: ACK 72c9a1f pablomartin4btc: ACK 72c9a1f theStack: utACK 72c9a1f tdb3: tested ACK 72c9a1f Tree-SHA512: 18a57c5782e99a018414db0597e88debeb32666712c2a75dddbb55135d8f1ddd1eeacba8bbbd35fc03b6c4ab0522fe074ec08edea729560b018f51efabf00e89
2 parents 71af743 + 72c9a1f commit 87d5450

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

test/functional/rpc_dumptxoutset.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ def set_test_params(self):
1919
self.setup_clean_chain = True
2020
self.num_nodes = 1
2121

22+
def check_expected_network(self, node, active):
23+
rev_file = node.blocks_path / "rev00000.dat"
24+
bogus_file = node.blocks_path / "bogus.dat"
25+
rev_file.rename(bogus_file)
26+
assert_raises_rpc_error(
27+
-1, 'Could not roll back to requested height.', node.dumptxoutset, 'utxos.dat', rollback=99)
28+
assert_equal(node.getnetworkinfo()['networkactive'], active)
29+
30+
# Cleanup
31+
bogus_file.rename(rev_file)
32+
2233
def run_test(self):
2334
"""Test a trivial usage of the dumptxoutset RPC command."""
2435
node = self.nodes[0]
@@ -60,16 +71,14 @@ def run_test(self):
6071
assert_raises_rpc_error(
6172
-8, 'Invalid snapshot type "bogus" specified. Please specify "rollback" or "latest"', node.dumptxoutset, 'utxos.dat', "bogus")
6273

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)
74+
self.log.info(f"Test that dumptxoutset failure does not leave the network activity suspended when it was on previously")
75+
self.check_expected_network(node, True)
76+
77+
self.log.info(f"Test that dumptxoutset failure leaves the network activity suspended when it was off")
78+
node.setnetworkactive(False)
79+
self.check_expected_network(node, False)
80+
node.setnetworkactive(True)
7081

71-
# Cleanup
72-
bogus_file.rename(rev_file)
7382

7483
if __name__ == '__main__':
7584
DumptxoutsetTest(__file__).main()

0 commit comments

Comments
 (0)