Scripts to test this branch
This commit is contained in:
@@ -104,10 +104,10 @@ def initialize_datadir(dirname, n):
|
||||
f.write("showmetrics=0\n");
|
||||
f.write("rpcuser=hush\n");
|
||||
f.write("rpcpassword=puppy\n");
|
||||
#f.write("port="+str(p2p_port(n))+"\n");
|
||||
#rpcport = str(rpc_port(n))
|
||||
#f.write("rpcport="+rpcport+"\n");
|
||||
#print "RPC port=" + rpcport
|
||||
f.write("port="+str(p2p_port(n))+"\n");
|
||||
rpcport = str(rpc_port(n))
|
||||
f.write("rpcport="+rpcport+"\n");
|
||||
print "RPC port=" + rpcport
|
||||
f.write("listenonion=0\n");
|
||||
# TODO: maybe make these optional, via arg to initialize_datadir, defaulted to on for now
|
||||
f.write("addressindex=1\n");
|
||||
@@ -148,7 +148,7 @@ def initialize_chain(test_dir):
|
||||
rpcs = []
|
||||
for i in range(4):
|
||||
try:
|
||||
url = "http://rt:rt@127.0.0.1:%d"%(rpc_port(i),)
|
||||
url = "http://hush:puppy@127.0.0.1:%d"%(rpc_port(i),)
|
||||
rpcs.append(AuthServiceProxy(url))
|
||||
except:
|
||||
sys.stderr.write("Error connecting to "+url+"\n")
|
||||
@@ -165,11 +165,13 @@ def initialize_chain(test_dir):
|
||||
for j in range(25):
|
||||
set_node_times(rpcs, block_time)
|
||||
rpcs[peer].generate(1)
|
||||
block_time += 10*60
|
||||
# TODO: HUSH3 has 75s blocktime, other HSCs could be different
|
||||
block_time += 10*75
|
||||
# Must sync before next peer starts generating blocks
|
||||
sync_blocks(rpcs)
|
||||
|
||||
# Shut them down, and clean up cache directories:
|
||||
print("Stopping nodes")
|
||||
stop_nodes(rpcs)
|
||||
wait_bitcoinds()
|
||||
for i in range(4):
|
||||
@@ -182,8 +184,9 @@ def initialize_chain(test_dir):
|
||||
for i in range(4):
|
||||
from_dir = os.path.join("cache", "node"+str(i))
|
||||
to_dir = os.path.join(test_dir, "node"+str(i))
|
||||
print("Copying " + from_dir + " to " + to_dir)
|
||||
shutil.copytree(from_dir, to_dir)
|
||||
initialize_datadir(test_dir, i) # Overwrite port/rpcport in hush.conf
|
||||
initialize_datadir(test_dir, i) # Overwrite port/rpcport in HUSH3.conf
|
||||
|
||||
def initialize_chain_clean(test_dir, num_nodes):
|
||||
"""
|
||||
@@ -218,9 +221,10 @@ 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))
|
||||
datadir = os.path.join(dirname, "node"+str(i))
|
||||
# creating special config in case of cryptocondition asset chain test
|
||||
if extra_args[0] == '-ac_name=REGTEST':
|
||||
if len(extra_args) > 0 and extra_args[0] == '-ac_name=REGTEST':
|
||||
configpath = datadir + "/REGTEST.conf"
|
||||
with open(configpath, "w+") as config:
|
||||
config.write("regtest=1\n")
|
||||
@@ -259,7 +263,8 @@ 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 = extra_args[3]
|
||||
port = rpc_port(i)
|
||||
username = rpc_username()
|
||||
password = rpc_password()
|
||||
url = "http://%s:%s@%s:%d" % (username, password, rpchost or '127.0.0.1', int(port[9:]))
|
||||
@@ -276,6 +281,7 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None):
|
||||
"""
|
||||
Start multiple hushds, return RPC connections to them
|
||||
"""
|
||||
print("Starting " + str(num_nodes) + " nodes")
|
||||
if extra_args is None: extra_args = [ None for i in range(num_nodes) ]
|
||||
if binary is None: binary = [ None for i in range(num_nodes) ]
|
||||
return [ start_node(i, dirname, extra_args[i], rpchost, binary=binary[i]) for i in range(num_nodes) ]
|
||||
@@ -288,6 +294,7 @@ def check_node(i):
|
||||
return bitcoind_processes[i].returncode
|
||||
|
||||
def stop_node(node, i):
|
||||
print("Stopping node " + i)
|
||||
node.stop()
|
||||
bitcoind_processes[i].wait()
|
||||
del bitcoind_processes[i]
|
||||
@@ -298,11 +305,12 @@ def stop_nodes(nodes):
|
||||
del nodes[:] # Emptying array closes connections as a side effect
|
||||
|
||||
def set_node_times(nodes, t):
|
||||
print("Setting nodes time to " + t)
|
||||
for node in nodes:
|
||||
node.setmocktime(t)
|
||||
|
||||
def wait_bitcoinds():
|
||||
# Wait for all bitcoinds to cleanly exit
|
||||
print("Waiting for all nodes to cleanly exit")
|
||||
for bitcoind in bitcoind_processes.values():
|
||||
bitcoind.wait()
|
||||
bitcoind_processes.clear()
|
||||
|
||||
Reference in New Issue
Block a user