Skip to content

Commit fa5b440

Browse files
author
MarcoFalke
committed
qa: Extract rpc_timewait as test param
Also increase it for wallet_dump and wallet_groups
1 parent c88529a commit fa5b440

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

test/functional/feature_dbcrash.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
4646
def set_test_params(self):
4747
self.num_nodes = 4
4848
self.setup_clean_chain = False
49+
# Need a bit of extra time for the nodes to start up for this test
50+
self.rpc_timewait = 90
4951

5052
# Set -maxmempool=0 to turn off mempool memory sharing with dbcache
5153
# Set -rpcservertimeout=900 to reduce socket disconnects in this
@@ -63,8 +65,7 @@ def set_test_params(self):
6365
self.extra_args = [self.node0_args, self.node1_args, self.node2_args, self.node3_args]
6466

6567
def setup_network(self):
66-
# Need a bit of extra time for the nodes to start up for this test
67-
self.add_nodes(self.num_nodes, extra_args=self.extra_args, timewait=90)
68+
self.add_nodes(self.num_nodes, extra_args=self.extra_args)
6869
self.start_nodes()
6970
# Leave them unconnected, we'll use submitblock directly in this test
7071

test/functional/feature_pruning.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class PruneTest(BitcoinTestFramework):
2828
def set_test_params(self):
2929
self.setup_clean_chain = True
3030
self.num_nodes = 6
31+
self.rpc_timewait = 900
3132

3233
# Create nodes 0 and 1 to mine.
3334
# Create node 2 to test pruning.
@@ -54,7 +55,7 @@ def setup_network(self):
5455
sync_blocks(self.nodes[0:5])
5556

5657
def setup_nodes(self):
57-
self.add_nodes(self.num_nodes, self.extra_args, timewait=900)
58+
self.add_nodes(self.num_nodes, self.extra_args)
5859
self.start_nodes()
5960

6061
def create_big_chain(self):

test/functional/test_framework/test_framework.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def __init__(self):
8686
self.nodes = []
8787
self.network_thread = None
8888
self.mocktime = 0
89+
self.rpc_timewait = 60 # Wait for up to 60 seconds for the RPC server to respond
8990
self.supports_cli = False
9091
self.bind_to_localhost_only = True
9192
self.set_test_params()
@@ -252,7 +253,7 @@ def run_test(self):
252253

253254
# Public helper methods. These can be accessed by the subclass test scripts.
254255

255-
def add_nodes(self, num_nodes, extra_args=None, rpchost=None, timewait=None, binary=None):
256+
def add_nodes(self, num_nodes, extra_args=None, *, rpchost=None, binary=None):
256257
"""Instantiate TestNode objects"""
257258
if self.bind_to_localhost_only:
258259
extra_confs = [["bind=127.0.0.1"]] * num_nodes
@@ -266,7 +267,7 @@ def add_nodes(self, num_nodes, extra_args=None, rpchost=None, timewait=None, bin
266267
assert_equal(len(extra_args), num_nodes)
267268
assert_equal(len(binary), num_nodes)
268269
for i in range(num_nodes):
269-
self.nodes.append(TestNode(i, get_datadir_path(self.options.tmpdir, i), rpchost=rpchost, timewait=timewait, bitcoind=binary[i], bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli))
270+
self.nodes.append(TestNode(i, get_datadir_path(self.options.tmpdir, i), rpchost=rpchost, timewait=self.rpc_timewait, bitcoind=binary[i], bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli))
270271

271272
def start_node(self, i, *args, **kwargs):
272273
"""Start a bitcoind"""
@@ -417,7 +418,7 @@ def _initialize_chain(self):
417418
args = [self.options.bitcoind, "-datadir=" + datadir]
418419
if i > 0:
419420
args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
420-
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), extra_conf=["bind=127.0.0.1"], extra_args=[], rpchost=None, timewait=None, bitcoind=self.options.bitcoind, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None))
421+
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), extra_conf=["bind=127.0.0.1"], extra_args=[], rpchost=None, timewait=self.rpc_timewait, bitcoind=self.options.bitcoind, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None))
421422
self.nodes[i].args = args
422423
self.start_node(i)
423424

test/functional/test_framework/test_node.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,13 @@ class TestNode():
5656
To make things easier for the test writer, any unrecognised messages will
5757
be dispatched to the RPC connection."""
5858

59-
def __init__(self, i, datadir, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False):
59+
def __init__(self, i, datadir, *, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False):
6060
self.index = i
6161
self.datadir = datadir
6262
self.stdout_dir = os.path.join(self.datadir, "stdout")
6363
self.stderr_dir = os.path.join(self.datadir, "stderr")
6464
self.rpchost = rpchost
65-
if timewait:
66-
self.rpc_timeout = timewait
67-
else:
68-
# Wait for up to 60 seconds for the RPC server to respond
69-
self.rpc_timeout = 60
65+
self.rpc_timeout = timewait
7066
self.binary = bitcoind
7167
self.coverage_dir = coverage_dir
7268
if extra_conf != None:

test/functional/wallet_dump.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,13 @@ class WalletDumpTest(BitcoinTestFramework):
8181
def set_test_params(self):
8282
self.num_nodes = 1
8383
self.extra_args = [["-keypool=90", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"]]
84+
self.rpc_timeout = 120
8485

8586
def setup_network(self, split=False):
86-
# Use 1 minute timeout because the initial getnewaddress RPC can take
87-
# longer than the default 30 seconds due to an expensive
88-
# CWallet::TopUpKeyPool call, and the encryptwallet RPC made later in
89-
# the test often takes even longer.
90-
self.add_nodes(self.num_nodes, extra_args=self.extra_args, timewait=60)
87+
self.add_nodes(self.num_nodes, extra_args=self.extra_args)
9188
self.start_nodes()
9289

93-
def run_test (self):
90+
def run_test(self):
9491
wallet_unenc_dump = os.path.join(self.nodes[0].datadir, "wallet.unencrypted.dump")
9592
wallet_enc_dump = os.path.join(self.nodes[0].datadir, "wallet.encrypted.dump")
9693

test/functional/wallet_groups.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def set_test_params(self):
2222
self.setup_clean_chain = True
2323
self.num_nodes = 3
2424
self.extra_args = [[], [], ['-avoidpartialspends']]
25+
self.rpc_timewait = 120
2526

2627
def run_test (self):
2728
# Mine some coins

0 commit comments

Comments
 (0)