./test.sh now runs successfully and we can now write RPC tests

This commit is contained in:
Duke
2025-08-12 22:17:18 -04:00
parent c8e1b598bc
commit 465fe58e6a
4 changed files with 51 additions and 44 deletions

View File

@@ -134,10 +134,10 @@ class BitcoinTestFramework(object):
stop_nodes(self.nodes)
wait_bitcoinds()
else:
print("Note: hushds were not stopped and may still be running")
print("Note: nodes were not stopped and may still be running")
if not self.options.nocleanup and not self.options.noshutdown:
print("Cleaning up")
print("Deleting %s" % self.options.tmpdir)
shutil.rmtree(self.options.tmpdir)
if success:

View File

@@ -57,7 +57,9 @@ def sync_blocks(rpc_connections, wait=1):
break
time.sleep(wait)
# Now that the block counts are in sync, wait for the internal
return
# Now that the block counts are in sync, wait for the internal
# notifications to finish
while True:
notified = [ x.getblockchaininfo()['fullyNotified'] for x in rpc_connections ]
@@ -80,6 +82,7 @@ def sync_mempools(rpc_connections, wait=1):
break
time.sleep(wait)
return
# Now that the mempools are in sync, wait for the internal
# notifications to finish
while True:
@@ -91,13 +94,14 @@ def sync_mempools(rpc_connections, wait=1):
bitcoind_processes = {}
def initialize_datadir(dirname, n):
datadir = os.path.join(dirname, "node"+str(n))
datadir = os.path.join(datadir,"HUSH3")
datadir = os.path.join(dirname, "node"+str(n), "regtest")
#datadir = os.path.join(datadir,"ZZZ")
if not os.path.isdir(datadir):
print("Creating dirs %s" % datadir)
os.makedirs(datadir)
print("Writing to " + os.path.join(datadir,"HUSH3.conf"))
with open(os.path.join(datadir, "HUSH3.conf"), 'w') as f:
print("Writing to " + os.path.join(datadir,"ZZZ.conf"))
with open(os.path.join(datadir, "ZZZ.conf"), 'w') as f:
f.write("regtest=1\n");
f.write("txindex=1\n");
f.write("server=1\n");
@@ -113,7 +117,9 @@ def initialize_datadir(dirname, n):
f.write("addressindex=1\n");
f.write("spentindex=1\n");
f.write("timestampindex=1\n");
f.write("zindex=1\n");
#f.write("zindex=1\n");
print("Done writing to %s" % os.path.join(datadir,"ZZZ.conf") )
return datadir
def initialize_chain(test_dir):
@@ -221,14 +227,14 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
"""
Start a hushd and return RPC connection to it
"""
print("Starting node " + str(i) + "in dir " + dirname)
datadir = os.path.join(dirname, "node"+str(i))
# creating special config in case of cryptocondition asset chain test
print("Starting node " + str(i) + " in dir " + dirname)
datadir = os.path.join(dirname, "node"+str(i), "regtest")
# creating special config
if len(extra_args) > 0 and extra_args[0] == '-ac_name=ZZZ':
configpath = datadir + "/ZZZ.conf"
with open(configpath, "w+") as config:
config.write("rpcuser=rt\n")
config.write("rpcpassword=rt\n")
config.write("rpcuser=hush\n")
config.write("rpcpassword=puppy\n")
port = extra_args[3]
config.write("rpcport=" + (port[9:]) + "\n")
config.write("server=1\n")
@@ -236,18 +242,22 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
config.write("rpcworkqueue=256\n")
config.write("rpcallowip=127.0.0.1\n")
config.write("bind=127.0.0.1\n")
config.write("rpcbind=127.0.0.1")
config.write("rpcbind=127.0.0.1\n")
print("Done writing to %s" % configpath)
if binary is None:
binary = os.getenv("BITCOIND", "src/hushd")
args = [ binary, "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ]
if extra_args is not None: args.extend(extra_args)
#print("args=" + ' '.join(args))
print("args=" + ' '.join(args))
bitcoind_processes[i] = subprocess.Popen(args)
devnull = open("/dev/null", "w+")
cmd = os.getenv("BITCOINCLI", "src/hush-cli")
print("cmd=" + cmd)
cmd_args = ' '.join(extra_args) + " -rpcwait getblockcount "
args = [ extra_args[0], "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ]
cmd_args = ' '.join(args) + " -rpcwait getblockcount "
if os.getenv("PYTHON_DEBUG", ""):
print("start_node: hushd started, calling : " + cmd + " " + cmd_args)
strcmd = cmd + " " + cmd_args
@@ -262,12 +272,12 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
if os.getenv("PYTHON_DEBUG", ""):
print("start_node: calling hush-cli -rpcwait getblockcount returned")
devnull.close()
#port = extra_args[3]
port = rpc_port(i)
port = extra_args[3]
#port = rpc_port(i)
print("port=%s" % port)
username = rpc_username()
password = rpc_password()
url = "http://%s:%s@%s:%s" % (username, password, rpchost or '127.0.0.1', port)
url = "http://%s:%s@%s:%s" % (username, password, rpchost or '127.0.0.1', port[9:])
print("connecting to " + url)
if timewait is not None:
proxy = AuthServiceProxy(url, timeout=timewait)