test: Set TestNode url field early, so that feature_loadblock.py --usecli works
What changed, and why it matters
This is a minor test-framework bug fix. It moves one line of code earlier so that a test-only URL field is set before creating a command-line RPC connection. This allows a specific functional test to run with the --usecli option. It does not affect the Bitcoin Core software that users run, nor does it touch network code, wallets, consensus, or any production security mechanism.
No security action needed. Treat as a normal test-framework fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch changes test/functional/test_framework/test_node.py so that self.url is assigned from rpc.rpc_url immediately after rpc_connected is set, before self.cli is created. Previously self.url was assigned only after the CLI connection was created, which meant self.url was unset when use_cli mode returned early. The feature_loadblock.py test is updated by removing self.supports_cli = False, enabling it to work with –usecli. The change is purely in the Python functional-test harness and has no runtime security implications.
Changed components
test/functional/test_framework/test_node.pytest/functional/feature_loadblock.pyInspect captured patch +1 / −2
diff --git a/test/functional/feature_loadblock.py b/test/functional/feature_loadblock.py
index fc942cad..417ecff5 100755
--- a/test/functional/feature_loadblock.py
+++ b/test/functional/feature_loadblock.py
@@ -25,7 +25,6 @@ class LoadblockTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 2
- self.supports_cli = False
def run_test(self):
self.nodes[1].setnetworkactive(state=False)
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 1d564a86..22d76cac 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -379,11 +379,11 @@ class TestNode():
self.log.debug("RPC successfully started")
# Set rpc_connected even if we are in use_cli mode so that we know we can call self.stop() if needed.
self.rpc_connected = True
+ self.url = rpc.rpc_url
self.cli = self.create_new_rpc_connection(mode="CLI")
if self.use_cli:
return
self._rpc = rpc
- self.url = self._rpc.rpc_url
return
except JSONRPCException as e:
# Suppress these as they are expected during initialization.
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.