Skip to content

Commit 279fde5

Browse files
committed
Check for rpcuser/rpcpassword first then for cookie
Better to check that rpcuser and rpcpassword exist then to check for the cookie in the test framework. Name an argument for consistency in p2p-segwit.py
1 parent 3ec5ad8 commit 279fde5

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

test/functional/p2p-segwit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ def run_test(self):
19441944
self.test_signature_version_1()
19451945
self.test_non_standard_witness()
19461946
sync_blocks(self.nodes)
1947-
self.test_upgrade_after_activation(2)
1947+
self.test_upgrade_after_activation(node_id=2)
19481948
self.test_witness_sigops()
19491949

19501950

test/functional/test_framework/util.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,25 +192,26 @@ def get_datadir_path(dirname, n):
192192
return os.path.join(dirname, "node"+str(n))
193193

194194
def get_auth_cookie(datadir, n):
195-
if os.path.isfile(os.path.join(datadir, "regtest", ".cookie")):
196-
with open(os.path.join(datadir, "regtest", ".cookie"), 'r') as f:
197-
userpass = f.read()
198-
split_userpass = userpass.split(':')
199-
return split_userpass[0], split_userpass[1]
200-
else:
195+
user = None
196+
password = None
197+
if os.path.isfile(os.path.join(datadir, "bitcoin.conf")):
201198
with open(os.path.join(datadir, "bitcoin.conf"), 'r') as f:
202-
user = None
203-
password = None
204199
for line in f:
205200
if line.startswith("rpcuser="):
206201
assert user is None # Ensure that there is only one rpcuser line
207202
user = line.split("=")[1].strip("\n")
208203
if line.startswith("rpcpassword="):
209204
assert password is None # Ensure that there is only one rpcpassword line
210205
password = line.split("=")[1].strip("\n")
211-
if user is None and password is None:
212-
raise ValueError("No RPC credentials")
213-
return user, password
206+
if os.path.isfile(os.path.join(datadir, "regtest", ".cookie")):
207+
with open(os.path.join(datadir, "regtest", ".cookie"), 'r') as f:
208+
userpass = f.read()
209+
split_userpass = userpass.split(':')
210+
user = split_userpass[0]
211+
password = split_userpass[1]
212+
if user is None or password is None:
213+
raise ValueError("No RPC credentials")
214+
return user, password
214215

215216
def rpc_url(datadir, i, rpchost=None):
216217
rpc_u, rpc_p = get_auth_cookie(datadir, i)

0 commit comments

Comments
 (0)