|
|
@ -59,7 +59,7 @@ def sync_mempools(rpc_connections): |
|
|
|
time.sleep(1) |
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bitcoind_processes = [] |
|
|
|
bitcoind_processes = {} |
|
|
|
|
|
|
|
|
|
|
|
def initialize_datadir(dir, n): |
|
|
|
def initialize_datadir(dir, n): |
|
|
|
datadir = os.path.join(dir, "node"+str(n)) |
|
|
|
datadir = os.path.join(dir, "node"+str(n)) |
|
|
@ -88,7 +88,7 @@ def initialize_chain(test_dir): |
|
|
|
args = [ "bitcoind", "-keypool=1", "-datadir="+datadir ] |
|
|
|
args = [ "bitcoind", "-keypool=1", "-datadir="+datadir ] |
|
|
|
if i > 0: |
|
|
|
if i > 0: |
|
|
|
args.append("-connect=127.0.0.1:"+str(p2p_port(0))) |
|
|
|
args.append("-connect=127.0.0.1:"+str(p2p_port(0))) |
|
|
|
bitcoind_processes.append(subprocess.Popen(args)) |
|
|
|
bitcoind_processes[i] = subprocess.Popen(args) |
|
|
|
subprocess.check_call([ "bitcoin-cli", "-datadir="+datadir, |
|
|
|
subprocess.check_call([ "bitcoin-cli", "-datadir="+datadir, |
|
|
|
"-rpcwait", "getblockcount"], stdout=devnull) |
|
|
|
"-rpcwait", "getblockcount"], stdout=devnull) |
|
|
|
devnull.close() |
|
|
|
devnull.close() |
|
|
@ -149,7 +149,7 @@ def start_node(i, dir, extra_args=None, rpchost=None): |
|
|
|
datadir = os.path.join(dir, "node"+str(i)) |
|
|
|
datadir = os.path.join(dir, "node"+str(i)) |
|
|
|
args = [ "bitcoind", "-datadir="+datadir, "-keypool=1" ] |
|
|
|
args = [ "bitcoind", "-datadir="+datadir, "-keypool=1" ] |
|
|
|
if extra_args is not None: args.extend(extra_args) |
|
|
|
if extra_args is not None: args.extend(extra_args) |
|
|
|
bitcoind_processes.append(subprocess.Popen(args)) |
|
|
|
bitcoind_processes[i] = subprocess.Popen(args) |
|
|
|
devnull = open("/dev/null", "w+") |
|
|
|
devnull = open("/dev/null", "w+") |
|
|
|
subprocess.check_call([ "bitcoin-cli", "-datadir="+datadir] + |
|
|
|
subprocess.check_call([ "bitcoin-cli", "-datadir="+datadir] + |
|
|
|
_rpchost_to_args(rpchost) + |
|
|
|
_rpchost_to_args(rpchost) + |
|
|
@ -168,6 +168,11 @@ def start_nodes(num_nodes, dir, extra_args=None, rpchost=None): |
|
|
|
def debug_log(dir, n_node): |
|
|
|
def debug_log(dir, n_node): |
|
|
|
return os.path.join(dir, "node"+str(n_node), "regtest", "debug.log") |
|
|
|
return os.path.join(dir, "node"+str(n_node), "regtest", "debug.log") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def stop_node(node, i): |
|
|
|
|
|
|
|
node.stop() |
|
|
|
|
|
|
|
bitcoind_processes[i].wait() |
|
|
|
|
|
|
|
del bitcoind_processes[i] |
|
|
|
|
|
|
|
|
|
|
|
def stop_nodes(nodes): |
|
|
|
def stop_nodes(nodes): |
|
|
|
for i in range(len(nodes)): |
|
|
|
for i in range(len(nodes)): |
|
|
|
nodes[i].stop() |
|
|
|
nodes[i].stop() |
|
|
@ -175,9 +180,9 @@ def stop_nodes(nodes): |
|
|
|
|
|
|
|
|
|
|
|
def wait_bitcoinds(): |
|
|
|
def wait_bitcoinds(): |
|
|
|
# Wait for all bitcoinds to cleanly exit |
|
|
|
# Wait for all bitcoinds to cleanly exit |
|
|
|
for bitcoind in bitcoind_processes: |
|
|
|
for bitcoind in bitcoind_processes.values(): |
|
|
|
bitcoind.wait() |
|
|
|
bitcoind.wait() |
|
|
|
del bitcoind_processes[:] |
|
|
|
bitcoind_processes.clear() |
|
|
|
|
|
|
|
|
|
|
|
def connect_nodes(from_connection, node_num): |
|
|
|
def connect_nodes(from_connection, node_num): |
|
|
|
ip_port = "127.0.0.1:"+str(p2p_port(node_num)) |
|
|
|
ip_port = "127.0.0.1:"+str(p2p_port(node_num)) |
|
|
|