test: Stop node before modifying config to support rpc_users.py --usecli
What changed, and why it matters
This is a minor fix to a Bitcoin Core functional test script. It changes the test setup so that the test nodes are stopped before their configuration files are edited, then started again afterward. Previously, the test restarted the nodes after editing the config, which could cause the command-line tool bitcoin-cli to read settings that had not yet taken effect. There is no change to production Bitcoin Core code and no security vulnerability in the software itself.
No security action required. This is a test-only change. Reviewers may optionally verify that the functional test rpc_users.py passes with --usecli.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/functional/rpc_users.py. It removes the supports_cli = False flag, stops nodes before appending rpcauth/rpcuser/rpcpassword entries to bitcoin.conf, and uses start_nodes() instead of restart_node(0)/restart_node(1). A second stop_node(1) is added before replacing rpcuser/rpcpassword entries in node 1’s config. These changes ensure that bitcoin-cli invocations during the test do not read a config file that is out of sync with the running node’s effective configuration. The change is purely in test infrastructure.
Changed components
test/functional/rpc_users.pyInspect captured patch +3 / −3
diff --git a/test/functional/rpc_users.py b/test/functional/rpc_users.py
index 9650480a..3eec97f1 100755
--- a/test/functional/rpc_users.py
+++ b/test/functional/rpc_users.py
@@ -36,7 +36,6 @@ def call_with_auth(node, user, password, method="getbestblockhash"):
class HTTPBasicsTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
- self.supports_cli = False
def conf_setup(self):
#Append rpcauth to bitcoin.conf before initialization
@@ -61,6 +60,7 @@ class HTTPBasicsTest(BitcoinTestFramework):
rpcauth3 = lines[1]
self.password = lines[3]
+ self.stop_nodes()
with open(self.nodes[0].datadir_path / "bitcoin.conf", "a") as f:
f.write(rpcauth + "\n")
f.write(rpcauth2 + "\n")
@@ -68,8 +68,7 @@ class HTTPBasicsTest(BitcoinTestFramework):
with open(self.nodes[1].datadir_path / "bitcoin.conf", "a") as f:
f.write("rpcuser={}\n".format(self.rpcuser))
f.write("rpcpassword={}\n".format(self.rpcpassword))
- self.restart_node(0)
- self.restart_node(1)
+ self.start_nodes()
def test_auth(self, node, user, password):
self.log.info('Correct...')
@@ -109,6 +108,7 @@ class HTTPBasicsTest(BitcoinTestFramework):
assert_equal(expected_perms, actual_perms)
# Remove any leftover rpc{user|password} config options from previous tests
+ self.stop_node(1)
self.nodes[1].replace_in_config([("rpcuser", "#rpcuser"), ("rpcpassword", "#rpcpassword")])
self.log.info('Check default cookie permission')
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.