Skip to content

Commit

Permalink
test: Add feature_framework_rpc_failure.py
Browse files Browse the repository at this point in the history
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
hodlinator committed Nov 8, 2024
1 parent c10e3a0 commit 68b0530
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/functional/feature_framework_rpc_failure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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 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):
self.log.info(f"Setting RPC timeout to 0 to simulate an unresponsive bitcoind, expect one warning.")
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()
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@
'p2p_handshake.py --v2transport',
'feature_dirsymlinks.py',
'feature_help.py',
'feature_framework_rpc_failure.py',
'feature_shutdown.py',
'wallet_migration.py',
'p2p_ibd_txrelay.py',
Expand Down

0 comments on commit 68b0530

Please sign in to comment.