test: [move-only] Extract create_new_rpc_connection
What changed, and why it matters
This is a harmless code cleanup in Bitcoin Core's internal test framework. A developer extracted a small block of code that creates an RPC connection into a reusable helper function. No behavior changed, no user-facing code was modified, and there is no security issue.
No action required. This is a benign test-framework refactor with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors test/functional/test_framework/test_node.py by moving the RPC proxy creation logic from wait_for_rpc_connection() into a new method create_new_rpc_connection(). The new method is intended for future use by test threads that need their own RPC connection instead of sharing one. The diff is move-only and the commit message explicitly states it does not change behavior. The change is confined to the functional test framework and does not touch consensus, networking, wallet, or RPC server code.
Changed components
test/functional/test_framework/test_node.pyInspect captured patch +12 / −7
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 1ba2e09b..c3384007 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -301,6 +301,17 @@ class TestNode():
if self.start_perf:
self._start_perf()
+ def create_new_rpc_connection(self):
+ """Create an additional RPC connection, likely to be used in a new thread."""
+ rpc = get_rpc_proxy(
+ rpc_url(self.datadir_path, self.index, self.chain, self.rpchost),
+ self.index,
+ timeout=self.rpc_timeout // 2, # Shorter timeout to allow for one retry in case of ETIMEDOUT
+ coveragedir=self.coverage_dir,
+ )
+ rpc.auth_service_proxy_instance.reuse_http_connections = self.reuse_http_connections
+ return rpc
+
def wait_for_rpc_connection(self, *, wait_for_import=True):
"""Sets up an RPC connection to the bitcoind process. Returns False if unable to connect."""
# Poll at a rate of four times per second
@@ -322,13 +333,7 @@ class TestNode():
raise FailedToStartError(self._node_msg(
f'bitcoind exited with status {self.process.returncode} during initialization. {str_error}'))
try:
- rpc = get_rpc_proxy(
- rpc_url(self.datadir_path, self.index, self.chain, self.rpchost),
- self.index,
- timeout=self.rpc_timeout // 2, # Shorter timeout to allow for one retry in case of ETIMEDOUT
- coveragedir=self.coverage_dir,
- )
- rpc.auth_service_proxy_instance.reuse_http_connections = self.reuse_http_connections
+ rpc = self.create_new_rpc_connection()
rpc.getblockcount()
# If the call to getblockcount() succeeds then the RPC connection is up
if self.version_is_at_least(190000) and wait_for_import:
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.