aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-09-13 16:12:19 -0400
committerAva Chow <github@achow101.com>2024-09-13 16:12:19 -0400
commit87d54500bfa350c0f8c458b46ab78ea2b410978f (patch)
tree95b0af355133cf854e62151f7227129ef16fa2c4 /test/functional
parent71af7435ef934a29d854bbe23c0e8602730ebe10 (diff)
parent72c9a1fe94f927220d3159f516fda684ae9d4caa (diff)
Merge bitcoin/bitcoin#30892: test: Check already deactivated network stays suspended after dumptxoutset
72c9a1fe94f927220d3159f516fda684ae9d4caa 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 72c9a1fe94f927220d3159f516fda684ae9d4caa pablomartin4btc: ACK 72c9a1fe94f927220d3159f516fda684ae9d4caa theStack: utACK 72c9a1fe94f927220d3159f516fda684ae9d4caa tdb3: tested ACK 72c9a1fe94f927220d3159f516fda684ae9d4caa Tree-SHA512: 18a57c5782e99a018414db0597e88debeb32666712c2a75dddbb55135d8f1ddd1eeacba8bbbd35fc03b6c4ab0522fe074ec08edea729560b018f51efabf00e89
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/rpc_dumptxoutset.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/test/functional/rpc_dumptxoutset.py b/test/functional/rpc_dumptxoutset.py
index 3262c664ad..ad05060210 100755
--- a/test/functional/rpc_dumptxoutset.py
+++ b/test/functional/rpc_dumptxoutset.py
@@ -19,6 +19,17 @@ class DumptxoutsetTest(BitcoinTestFramework):
self.setup_clean_chain = True
self.num_nodes = 1
+ def check_expected_network(self, node, active):
+ 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'], active)
+
+ # Cleanup
+ bogus_file.rename(rev_file)
+
def run_test(self):
"""Test a trivial usage of the dumptxoutset RPC command."""
node = self.nodes[0]
@@ -60,16 +71,14 @@ 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)
+ self.log.info(f"Test that dumptxoutset failure does not leave the network activity suspended when it was on previously")
+ self.check_expected_network(node, True)
+
+ self.log.info(f"Test that dumptxoutset failure leaves the network activity suspended when it was off")
+ node.setnetworkactive(False)
+ self.check_expected_network(node, False)
+ node.setnetworkactive(True)
- # Cleanup
- bogus_file.rename(rev_file)
if __name__ == '__main__':
DumptxoutsetTest(__file__).main()