forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
qa: Add feature_framework_rpc_failure_details.py
- Loading branch information
1 parent
23bc6bf
commit c9e549d
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2024-present The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
""" | ||
Verify timing out in connecting to bitcoind's RPC interface throws an exception | ||
including details on what kind of failures happened before timing out. | ||
""" | ||
|
||
from test_framework.test_node import ( | ||
FailedToStartError, | ||
TestNode, | ||
) | ||
from test_framework.util import ( | ||
assert_raises_message, | ||
rpc_port, | ||
) | ||
from test_framework.test_framework import BitcoinTestFramework | ||
|
||
import re | ||
|
||
class FeatureFrameworkRPCFailureDetails(BitcoinTestFramework): | ||
def set_test_params(self): | ||
self.num_nodes = 1 | ||
# Lower the timeout so we don't wait that long | ||
self.rpc_timeout = 3 | ||
|
||
# Overridden to avoid syncing non-started nodes. | ||
def setup_network(self): | ||
self.setup_nodes() | ||
|
||
# Overridden to avoid starting nodes before run_test. | ||
def setup_nodes(self): | ||
self.add_nodes(self.num_nodes, self.extra_args) | ||
|
||
def run_test(self): | ||
e = assert_raises_message( | ||
exc=AssertionError, | ||
message="[node 0] Unable to connect to bitcoind after ", | ||
fun=BitcoinTestFramework.start_node, | ||
self=self, | ||
i=0, | ||
# Override RPC port to something TestNode isn't expecting so that we are | ||
# unable to establish an RPC connection. | ||
extra_args=[f'-rpcport={rpc_port(2)}'], | ||
) | ||
assert re.match( | ||
r"^\[node 0\] Unable to connect to bitcoind after \ds \(ignored errors: {'.*'OSError ECONNREFUSED': .*, latest error: .*$", \ | ||
str(e)), \ | ||
f'Didn\'t find expected details in "{e}"' | ||
self.log.info("One WARNING expected - Explicitly stopping the node to verify it completes cleanly during the test") | ||
self.nodes[0].stop_node(avoid_exceptions=True) | ||
|
||
if __name__ == '__main__': | ||
FeatureFrameworkRPCFailureDetails(__file__).main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters