aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests
diff options
context:
space:
mode:
Diffstat (limited to 'qa/rpc-tests')
-rwxr-xr-xqa/rpc-tests/fundrawtransaction.py4
-rwxr-xr-xqa/rpc-tests/pruning.py7
-rwxr-xr-xqa/rpc-tests/rpcbind_test.py19
-rw-r--r--qa/rpc-tests/test_framework/util.py19
4 files changed, 21 insertions, 28 deletions
diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py
index e789641298..7892e85e22 100755
--- a/qa/rpc-tests/fundrawtransaction.py
+++ b/qa/rpc-tests/fundrawtransaction.py
@@ -470,7 +470,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/pruning.py b/qa/rpc-tests/pruning.py
index bfb4ea6d2e..ace8ced422 100755
--- a/qa/rpc-tests/pruning.py
+++ b/qa/rpc-tests/pruning.py
@@ -16,6 +16,11 @@ import os
MIN_BLOCKS_TO_KEEP = 288
+# Rescans start at the earliest block up to 2 hours before a key timestamp, so
+# the manual prune RPC avoids pruning blocks in the same window to be
+# compatible with pruning based on key creation time.
+RESCAN_WINDOW = 2 * 60 * 60
+
def calc_usage(blockdir):
return sum(os.path.getsize(blockdir+f) for f in os.listdir(blockdir) if os.path.isfile(blockdir+f)) / (1024. * 1024.)
@@ -237,7 +242,7 @@ class PruneTest(BitcoinTestFramework):
def height(index):
if use_timestamp:
- return node.getblockheader(node.getblockhash(index))["time"]
+ return node.getblockheader(node.getblockhash(index))["time"] + RESCAN_WINDOW
else:
return index
diff --git a/qa/rpc-tests/rpcbind_test.py b/qa/rpc-tests/rpcbind_test.py
index 89d74753cb..499fe33679 100755
--- a/qa/rpc-tests/rpcbind_test.py
+++ b/qa/rpc-tests/rpcbind_test.py
@@ -34,11 +34,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):
'''
@@ -47,13 +45,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 3a3e0dbd84..e838a40582 100644
--- a/qa/rpc-tests/test_framework/util.py
+++ b/qa/rpc-tests/test_framework/util.py
@@ -371,28 +371,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")