Browse Source

Merge #9824: qa: Check return code when stopping nodes

fa4cd2e qa: Check return code when stopping nodes (MarcoFalke)
0.15
Wladimir J. van der Laan 8 years ago
parent
commit
1d2a57e9fd
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 4
      qa/rpc-tests/fundrawtransaction.py
  2. 5
      qa/rpc-tests/rpcbind_test.py
  3. 19
      qa/rpc-tests/test_framework/util.py

4
qa/rpc-tests/fundrawtransaction.py

@ -469,7 +469,9 @@ class RawTransactionsTest(BitcoinTestFramework):
# locked wallet test # locked wallet test
self.nodes[1].encryptwallet("test") self.nodes[1].encryptwallet("test")
self.nodes.pop(1) self.nodes.pop(1)
stop_nodes(self.nodes) stop_node(self.nodes[0], 0)
stop_node(self.nodes[1], 2)
stop_node(self.nodes[2], 3)
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir) self.nodes = start_nodes(self.num_nodes, self.options.tmpdir)
# This test is not meant to test fee estimation and we'd like # This test is not meant to test fee estimation and we'd like

5
qa/rpc-tests/rpcbind_test.py

@ -35,10 +35,8 @@ class RPCBindTest(BitcoinTestFramework):
base_args += ['-rpcallowip=' + x for x in allow_ips] base_args += ['-rpcallowip=' + x for x in allow_ips]
binds = ['-rpcbind='+addr for addr in addresses] binds = ['-rpcbind='+addr for addr in addresses]
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, [base_args + binds], connect_to) self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, [base_args + binds], connect_to)
try:
pid = bitcoind_processes[0].pid pid = bitcoind_processes[0].pid
assert_equal(set(get_bind_addrs(pid)), set(expected)) assert_equal(set(get_bind_addrs(pid)), set(expected))
finally:
stop_nodes(self.nodes) stop_nodes(self.nodes)
def run_allowip_test(self, allow_ips, rpchost, rpcport): def run_allowip_test(self, allow_ips, rpchost, rpcport):
@ -48,12 +46,9 @@ class RPCBindTest(BitcoinTestFramework):
''' '''
base_args = ['-disablewallet', '-nolisten'] + ['-rpcallowip='+x for x in allow_ips] base_args = ['-disablewallet', '-nolisten'] + ['-rpcallowip='+x for x in allow_ips]
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, [base_args]) self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, [base_args])
try:
# connect to node through non-loopback interface # connect to node through non-loopback interface
node = get_rpc_proxy(rpc_url(0, "%s:%d" % (rpchost, rpcport)), 0) node = get_rpc_proxy(rpc_url(0, "%s:%d" % (rpchost, rpcport)), 0)
node.getnetworkinfo() node.getnetworkinfo()
finally:
node = None # make sure connection will be garbage collected and closed
stop_nodes(self.nodes) stop_nodes(self.nodes)
def run_test(self): def run_test(self):

19
qa/rpc-tests/test_framework/util.py

@ -375,28 +375,19 @@ def stop_node(node, i):
node.stop() node.stop()
except http.client.CannotSendRequest as e: except http.client.CannotSendRequest as e:
print("WARN: Unable to stop node: " + repr(e)) print("WARN: Unable to stop node: " + repr(e))
bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT) return_code = bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
assert_equal(return_code, 0)
del bitcoind_processes[i] del bitcoind_processes[i]
def stop_nodes(nodes): def stop_nodes(nodes):
for node in nodes: for i, node in enumerate(nodes):
try: stop_node(node, i)
node.stop() assert not bitcoind_processes.values() # All connections must be gone now
except http.client.CannotSendRequest as e:
print("WARN: Unable to stop node: " + repr(e))
del nodes[:] # Emptying array closes connections as a side effect
wait_bitcoinds()
def set_node_times(nodes, t): def set_node_times(nodes, t):
for node in nodes: for node in nodes:
node.setmocktime(t) node.setmocktime(t)
def wait_bitcoinds():
# Wait for all bitcoinds to cleanly exit
for bitcoind in bitcoind_processes.values():
bitcoind.wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
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))
from_connection.addnode(ip_port, "onetry") from_connection.addnode(ip_port, "onetry")

Loading…
Cancel
Save