aboutsummaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2017-02-22 11:29:43 +0100
committerMarcoFalke <falke.marco@gmail.com>2017-02-23 03:05:43 +0100
commitfa4cd2e998e0ebebe283a6243f7f752123a105ab (patch)
tree691fa6bf7ffa07cc0676bba2d5fe21ae6854e08f /qa
parent8ad31f9aa3111e079dd5024e8f6b069abb564b81 (diff)
qa: Check return code when stopping nodes
This includes work by jnewbery
Diffstat (limited to 'qa')
-rwxr-xr-xqa/rpc-tests/fundrawtransaction.py4
-rwxr-xr-xqa/rpc-tests/rpcbind_test.py19
-rw-r--r--qa/rpc-tests/test_framework/util.py19
3 files changed, 15 insertions, 27 deletions
diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py
index 7396ba46a4..8d2bc73c0c 100755
--- a/qa/rpc-tests/fundrawtransaction.py
+++ b/qa/rpc-tests/fundrawtransaction.py
@@ -469,7 +469,9 @@ class RawTransactionsTest(BitcoinTestFramework):
# locked wallet test
self.nodes[1].encryptwallet("test")
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)
# This test is not meant to test fee estimation and we'd like
diff --git a/qa/rpc-tests/rpcbind_test.py b/qa/rpc-tests/rpcbind_test.py
index d78d0b884e..1010c54aa5 100755
--- a/qa/rpc-tests/rpcbind_test.py
+++ b/qa/rpc-tests/rpcbind_test.py
@@ -35,11 +35,9 @@ class RPCBindTest(BitcoinTestFramework):
base_args += ['-rpcallowip=' + x for x in allow_ips]
binds = ['-rpcbind='+addr for addr in addresses]
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, [base_args + binds], connect_to)
- try:
- pid = bitcoind_processes[0].pid
- assert_equal(set(get_bind_addrs(pid)), set(expected))
- finally:
- stop_nodes(self.nodes)
+ pid = bitcoind_processes[0].pid
+ assert_equal(set(get_bind_addrs(pid)), set(expected))
+ stop_nodes(self.nodes)
def run_allowip_test(self, allow_ips, rpchost, rpcport):
'''
@@ -48,13 +46,10 @@ class RPCBindTest(BitcoinTestFramework):
'''
base_args = ['-disablewallet', '-nolisten'] + ['-rpcallowip='+x for x in allow_ips]
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, [base_args])
- try:
- # connect to node through non-loopback interface
- node = get_rpc_proxy(rpc_url(0, "%s:%d" % (rpchost, rpcport)), 0)
- node.getnetworkinfo()
- finally:
- node = None # make sure connection will be garbage collected and closed
- stop_nodes(self.nodes)
+ # connect to node through non-loopback interface
+ node = get_rpc_proxy(rpc_url(0, "%s:%d" % (rpchost, rpcport)), 0)
+ node.getnetworkinfo()
+ stop_nodes(self.nodes)
def run_test(self):
# due to OS-specific network stats queries, this test works only on Linux
diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py
index dc8555c44c..ec151c2a65 100644
--- a/qa/rpc-tests/test_framework/util.py
+++ b/qa/rpc-tests/test_framework/util.py
@@ -375,28 +375,19 @@ def stop_node(node, i):
node.stop()
except http.client.CannotSendRequest as 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]
def stop_nodes(nodes):
- for node in nodes:
- try:
- node.stop()
- 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()
+ for i, node in enumerate(nodes):
+ stop_node(node, i)
+ assert not bitcoind_processes.values() # All connections must be gone now
def set_node_times(nodes, t):
for node in nodes:
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):
ip_port = "127.0.0.1:"+str(p2p_port(node_num))
from_connection.addnode(ip_port, "onetry")