Skip to content

Commit

Permalink
Speed up stopping of nodes in tests by splitting up stop and wait (#2587
Browse files Browse the repository at this point in the history
)

Especially speed up MN based tests which currently spend multiple seconds
waiting for nodes to stop.
  • Loading branch information
codablock authored and UdjinM6 committed Dec 28, 2018
1 parent 0c9fb69 commit ce5a511
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions qa/rpc-tests/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,25 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, timewait=None
def log_filename(dirname, n_node, logname):
return os.path.join(dirname, "node"+str(n_node), "regtest", logname)

def stop_node(node, i):
def wait_node(i):
return_code = bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
assert_equal(return_code, 0)
del bitcoind_processes[i]

def stop_node(node, i, wait=True):
try:
node.stop()
except http.client.CannotSendRequest as e:
print("WARN: Unable to stop node: " + repr(e))
return_code = bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
assert_equal(return_code, 0)
del bitcoind_processes[i]
if wait:
wait_node(i)

def stop_nodes(nodes):
def stop_nodes(nodes, fast=True):
for i, node in enumerate(nodes):
stop_node(node, i)
stop_node(node, i, not fast)
if fast:
for i, node in enumerate(nodes):
wait_node(i)
assert not bitcoind_processes.values() # All connections must be gone now

def set_node_times(nodes, t):
Expand Down

0 comments on commit ce5a511

Please sign in to comment.