From 4cc7e0491a916acd9656b13619bc53d65a80da89 Mon Sep 17 00:00:00 2001 From: DanS Date: Sun, 30 Aug 2026 21:29:08 -0500 Subject: [PATCH] qa: finish the python3 port far enough to build the shared test chain Follow-up to 5e0a70683, which got start_node() working. Three more defects sat behind it: - initialize_chain() builds the 4-node cache with its own daemon invocation, which 5e0a70683 did not touch. It therefore still omitted -regtest (so those cache nodes ran on MAINNET) and -asmap (so they refused to start at all). Every test that uses the cache -- which is most of the wallet suite -- died there. - reindex.py and getblocktemplate_longpoll.py each carried a single python2 print statement, which is the whole reason they would not even parse under python3. Shebangs updated to match. The suite still does not pass: initialize_chain hits a remaining py2 str+int concatenation, and getblocktemplate.py reaches a real test assertion. Both are beyond this commit, but the harness now gets far enough to start nodes, answer RPC and begin building the shared chain, which it could not do before. --- qa/rpc-tests/getblocktemplate_longpoll.py | 4 ++-- qa/rpc-tests/reindex.py | 4 ++-- qa/rpc-tests/test_framework/util.py | 8 +++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/qa/rpc-tests/getblocktemplate_longpoll.py b/qa/rpc-tests/getblocktemplate_longpoll.py index b836fe8e5..3d7a43159 100755 --- a/qa/rpc-tests/getblocktemplate_longpoll.py +++ b/qa/rpc-tests/getblocktemplate_longpoll.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Copyright (c) 2016-2024 The Hush developers # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the GPLv3 software license, see the accompanying @@ -52,7 +52,7 @@ class GetBlockTemplateLPTest(BitcoinTestFramework): ''' def run_test(self): - print "Warning: this test will take about 70 seconds in the best case. Be patient." + print("Warning: this test will take about 70 seconds in the best case. Be patient.") self.nodes[0].generate(10) templat = self.nodes[0].getblocktemplate() longpollid = templat['longpollid'] diff --git a/qa/rpc-tests/reindex.py b/qa/rpc-tests/reindex.py index fa1454bae..a79207b50 100755 --- a/qa/rpc-tests/reindex.py +++ b/qa/rpc-tests/reindex.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2016-2024 The Hush developers # Released under the GPLv3 @@ -28,7 +28,7 @@ class ReindexTest(BitcoinTestFramework): wait_bitcoinds() self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug", "-reindex", "-checkblockindex=1"]) assert_equal(self.nodes[0].getblockcount(), 3) - print "Success" + print("Success") if __name__ == '__main__': ReindexTest().main() diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index e44f3ea38..05205c8ce 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -145,7 +145,13 @@ def initialize_chain(test_dir): # Create cache directories, run hushds: for i in range(4): datadir=initialize_datadir("cache", i) - args = [ os.getenv("BITCOIND", "dragonxd"), "-keypool=1", "-datadir="+datadir, "-discover=0" ] + # Same two requirements as start_node(): -regtest must be a command-line flag (the + # conf key is ignored, and without it this cache node runs on MAINNET), and -asmap + # must be absolute or dragonxd refuses to start. + args = [ os.getenv("BITCOIND", "dragonxd"), "-regtest", "-connect=0", "-keypool=1", "-datadir="+datadir, "-discover=0" ] + _am = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../asmap.dat") + if os.path.exists(_am): + args.append("-asmap=" + os.path.realpath(_am)) if i > 0: args.append("-connect=127.0.0.1:"+str(p2p_port(0))) bitcoind_processes[i] = subprocess.Popen(args)