aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/util.py
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2019-04-08 19:33:25 +0100
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2019-04-09 14:28:07 +0100
commit90bce24576a52c9f3aacfa59f44443eb5328dda0 (patch)
tree7d04a9ffe1bbd5bbb6c01f8b3faffdc1a29c9a4d /test/functional/test_framework/util.py
parenta238fccce84bcd5544e88bdc37bf5b9b387d2164 (diff)
downloadbitcoin-90bce24576a52c9f3aacfa59f44443eb5328dda0.tar.xz
qa: Prevent concurrency issues reading .cookie file
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r--test/functional/test_framework/util.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index f771a37b99..190301b215 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -323,12 +323,14 @@ def get_auth_cookie(datadir):
if line.startswith("rpcpassword="):
assert password is None # Ensure that there is only one rpcpassword line
password = line.split("=")[1].strip("\n")
- if os.path.isfile(os.path.join(datadir, "regtest", ".cookie")) and os.access(os.path.join(datadir, "regtest", ".cookie"), os.R_OK):
+ try:
with open(os.path.join(datadir, "regtest", ".cookie"), 'r', encoding="ascii") as f:
userpass = f.read()
split_userpass = userpass.split(':')
user = split_userpass[0]
password = split_userpass[1]
+ except OSError:
+ pass
if user is None or password is None:
raise ValueError("No RPC credentials")
return user, password