aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/util.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-07-31 14:11:32 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-07-31 17:00:25 -0400
commitfa8a1d7ba30040f8c74f93fc41a61276c255a6a6 (patch)
treeb5a686fcc62909c549c5a38f86d81678123b2dad /test/functional/test_framework/util.py
parent68f546635d5de2ccfedadeabc7bc79e12e5eca6a (diff)
downloadbitcoin-fa8a1d7ba30040f8c74f93fc41a61276c255a6a6.tar.xz
test: Adapt test framework for chains other than "regtest"
Co-Authored-By: Jorge Timón <jtimon@jtimon.cc>
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r--test/functional/test_framework/util.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index efd962ea93..8730157c74 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -271,8 +271,8 @@ def p2p_port(n):
def rpc_port(n):
return PORT_MIN + PORT_RANGE + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES)
-def rpc_url(datadir, i, rpchost=None):
- rpc_u, rpc_p = get_auth_cookie(datadir)
+def rpc_url(datadir, i, chain, rpchost):
+ rpc_u, rpc_p = get_auth_cookie(datadir, chain)
host = '127.0.0.1'
port = rpc_port(i)
if rpchost:
@@ -286,13 +286,13 @@ def rpc_url(datadir, i, rpchost=None):
# Node functions
################
-def initialize_datadir(dirname, n):
+def initialize_datadir(dirname, n, chain):
datadir = get_datadir_path(dirname, n)
if not os.path.isdir(datadir):
os.makedirs(datadir)
with open(os.path.join(datadir, "bitcoin.conf"), 'w', encoding='utf8') as f:
- f.write("regtest=1\n")
- f.write("[regtest]\n")
+ f.write("{}=1\n".format(chain))
+ f.write("[{}]\n".format(chain))
f.write("port=" + str(p2p_port(n)) + "\n")
f.write("rpcport=" + str(rpc_port(n)) + "\n")
f.write("server=1\n")
@@ -312,7 +312,7 @@ def append_config(datadir, options):
for option in options:
f.write(option + "\n")
-def get_auth_cookie(datadir):
+def get_auth_cookie(datadir, chain):
user = None
password = None
if os.path.isfile(os.path.join(datadir, "bitcoin.conf")):
@@ -325,7 +325,7 @@ def get_auth_cookie(datadir):
assert password is None # Ensure that there is only one rpcpassword line
password = line.split("=")[1].strip("\n")
try:
- with open(os.path.join(datadir, "regtest", ".cookie"), 'r', encoding="ascii") as f:
+ with open(os.path.join(datadir, chain, ".cookie"), 'r', encoding="ascii") as f:
userpass = f.read()
split_userpass = userpass.split(':')
user = split_userpass[0]
@@ -337,10 +337,10 @@ def get_auth_cookie(datadir):
return user, password
# If a cookie file exists in the given datadir, delete it.
-def delete_cookie_file(datadir):
- if os.path.isfile(os.path.join(datadir, "regtest", ".cookie")):
+def delete_cookie_file(datadir, chain):
+ if os.path.isfile(os.path.join(datadir, chain, ".cookie")):
logger.debug("Deleting leftover cookie file")
- os.remove(os.path.join(datadir, "regtest", ".cookie"))
+ os.remove(os.path.join(datadir, chain, ".cookie"))
def get_bip9_status(node, key):
info = node.getblockchaininfo()