From fa8a1d7ba30040f8c74f93fc41a61276c255a6a6 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 31 Jul 2019 14:11:32 -0400 Subject: test: Adapt test framework for chains other than "regtest" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Jorge Timón --- test/functional/test_framework/util.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test/functional/test_framework/util.py') 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() -- cgit v1.2.3