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.
test: Add feature_framework_rpc_failure.py
Verifies correct behavior when failing to connect to bitcoind RPC interface during setup. Parent commit fixes issues where a raised exception raised additional knock-on exceptions.
- Loading branch information
1 parent
e5a10cf
commit 042cee7
Showing
2 changed files
with
36 additions
and
0 deletions.
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,35 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2024 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 failure to connect to bitcoind's RPC interface only raises one exception. | ||
Multiple exceptions being raised muddies the waters of what actually went wrong. | ||
We should maintain this bar of only raising one exception as long as additional | ||
maintenance and complexity is low. | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
from test_framework.util import ( | ||
assert_raises_message, | ||
) | ||
from test_framework.test_framework import BitcoinTestFramework | ||
|
||
class FeatureFrameworkRPCFailure(BitcoinTestFramework): | ||
def set_test_params(self): | ||
self.num_nodes = 1 | ||
|
||
def setup_network(self): | ||
test_name = Path(__file__).name | ||
self.log.info(f"{test_name}: Setting RPC timeout to 0 to simulate an unresponsive bitcoind") | ||
self.rpc_timeout = 0 | ||
|
||
assert_raises_message(AssertionError, "[node 0] Unable to connect to bitcoind after 0s", BitcoinTestFramework.setup_network, self) | ||
|
||
def run_test(self): | ||
pass | ||
|
||
if __name__ == '__main__': | ||
FeatureFrameworkRPCFailure(__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