From 6a7c86e63b654097d796f481032ac2e59bd47d0f Mon Sep 17 00:00:00 2001 From: Greg Pfeil Date: Thu, 1 Sep 2022 09:44:59 -0600 Subject: [PATCH] Fix display of binary name in error messages. Ensures that test failures report the name of the actual binary that was run. --- qa/rpc-tests/test_framework/util.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 9d283258c..638f94035 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -54,6 +54,9 @@ PORT_MIN = 11000 PORT_RANGE = 5000 +def bitcoind_binary(): + return os.getenv("ZCASHD", ZCASHD_BINARY) + class PortSeed: # Must be initialized with a unique integer for each process n = None @@ -211,7 +214,7 @@ def wait_for_bitcoind_start(process, url, i): ''' while True: if process.poll() is not None: - raise Exception('bitcoind exited with status %i during initialization' % process.returncode) + raise Exception('%s exited with status %i during initialization' % (bitcoind_binary(), process.returncode)) try: rpc = get_rpc_proxy(url, i) rpc.getblockcount() @@ -257,7 +260,7 @@ def initialize_chain(test_dir, num_nodes, cachedir, cache_behavior='current'): block_time = int(time.time()) - (200 * PRE_BLOSSOM_BLOCK_TARGET_SPACING) for i in range(MAX_NODES): datadir = initialize_datadir(cachedir, i) - args = [ os.getenv("ZCASHD", ZCASHD_BINARY), "-keypool=1", "-datadir="+datadir, "-discover=0" ] + args = [ bitcoind_binary(), "-keypool=1", "-datadir="+datadir, "-discover=0" ] args.extend([ '-nuparams=5ba81b19:1', # Overwinter '-nuparams=76b809bb:1', # Sapling @@ -267,7 +270,7 @@ def initialize_chain(test_dir, num_nodes, cachedir, cache_behavior='current'): args.append("-connect=127.0.0.1:"+str(p2p_port(0))) bitcoind_processes[i] = subprocess.Popen(args) if os.getenv("PYTHON_DEBUG", ""): - print("initialize_chain: bitcoind started, waiting for RPC to come up") + print("initialize_chain: %s started, waiting for RPC to come up" % bitcoind_binary()) wait_for_bitcoind_start(bitcoind_processes[i], rpc_url(i), i) if os.getenv("PYTHON_DEBUG", ""): print("initialize_chain: RPC successfully started") @@ -438,9 +441,9 @@ def assert_start_raises_init_error(i, dirname, extra_args=None, expected_msg=Non raise AssertionError("Expected error \"" + expected_msg + "\" not found in:\n" + stderr) else: if expected_msg is None: - assert_msg = "bitcoind should have exited with an error" + assert_msg = "%s should have exited with an error" % bitcoind_binary() else: - assert_msg = "bitcoind should have exited with expected error " + expected_msg + assert_msg = "%s should have exited with expected error %s" % (bitcoind_binary(), expected_msg) raise AssertionError(assert_msg) def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None):