Skip to content

Commit

Permalink
Merge bitcoin#13837: qa: Extract rpc_timewait as test param
Browse files Browse the repository at this point in the history
fa5b440 qa: Extract rpc_timewait as test param (MarcoFalke)

Pull request description:

  Also increase it for wallet_dump and wallet_groups

Tree-SHA512: 7367bc584228bda3010c453713a1505c54a8ef3d116be47dab9934d30594089dfeb27ffa862f7517fd0ec8b5dc07f4904d67ef2a53dd284cbe2a58982e410e2b
  • Loading branch information
laanwj authored and gades committed May 12, 2022
1 parent 69edf65 commit 9babfdf
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 22 deletions.
8 changes: 4 additions & 4 deletions test/functional/feature_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ class FullBlockTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
# Very large reorgs cause cs_main to be held for a very long time in ActivateBestChainStep,
# which causes RPC to hang, so we need to increase RPC timeouts
self.rpc_timeout = 180
# Must set '-dip3params=2000:2000' to create pre-dip3 blocks only
self.extra_args = [['-dip3params=2000:2000']]

def setup_nodes(self):
# Very large reorgs cause cs_main to be held for a very long time in ActivateBestChainStep,
# which causes RPC to hang, so we need to increase RPC timeouts
# TODO remove this when bitcoin#13837 gets backported and change it to use self.rpc_timeout
self.add_nodes(self.num_nodes, self.extra_args, timewait=180)
self.add_nodes(self.num_nodes, self.extra_args)
self.start_nodes()

def run_test(self):
Expand Down
5 changes: 3 additions & 2 deletions test/functional/feature_dbcrash.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 4
self.setup_clean_chain = False
# Need a bit of extra time for the nodes to start up for this test
self.rpc_timewait = 90

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

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

Expand Down
3 changes: 2 additions & 1 deletion test/functional/feature_pruning.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class PruneTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 6
self.rpc_timewait = 900

# Create nodes 0 and 1 to mine.
# Create node 2 to test pruning.
Expand All @@ -56,7 +57,7 @@ def setup_network(self):
self.sync_blocks(self.nodes[0:5])

def setup_nodes(self):
self.add_nodes(self.num_nodes, self.extra_args, timewait=900)
self.add_nodes(self.num_nodes, self.extra_args)
self.start_nodes()

def create_big_chain(self):
Expand Down
7 changes: 4 additions & 3 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(self):
self.nodes = []
self.network_thread = None
self.mocktime = 0
self.rpc_timewait = 60 # Wait for up to 60 seconds for the RPC server to respond
self.supports_cli = False
self.bind_to_localhost_only = True
self.extra_args_from_options = []
Expand Down Expand Up @@ -279,7 +280,7 @@ def run_test(self):

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

def add_nodes(self, num_nodes, extra_args=None, rpchost=None, timewait=None, binary=None):
def add_nodes(self, num_nodes, extra_args=None, *, rpchost=None, binary=None):
"""Instantiate TestNode objects"""
if self.bind_to_localhost_only:
extra_confs = [["bind=127.0.0.1"]] * num_nodes
Expand All @@ -294,7 +295,7 @@ def add_nodes(self, num_nodes, extra_args=None, rpchost=None, timewait=None, bin
assert_equal(len(binary), num_nodes)
old_num_nodes = len(self.nodes)
for i in range(num_nodes):
self.nodes.append(TestNode(old_num_nodes + i, get_datadir_path(self.options.tmpdir, old_num_nodes + i), self.extra_args_from_options, chain=self.chain, 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))
self.nodes.append(TestNode(old_num_nodes + i, get_datadir_path(self.options.tmpdir, old_num_nodes + i), self.extra_args_from_options, chain=self.chain, 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))

def start_node(self, i, *args, **kwargs):
"""Start a cosantad"""
Expand Down Expand Up @@ -465,7 +466,7 @@ def _initialize_chain(self, extra_args=None):
args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
if extra_args is not None:
args.extend(extra_args)
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), chain=self.chain, extra_conf=["bind=127.0.0.1"], extra_args=[], extra_args_from_options=self.extra_args_from_options, rpchost=None, timewait=None, bitcoind=self.options.bitcoind, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None))
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), chain=self.chain, extra_conf=["bind=127.0.0.1"], extra_args=[], extra_args_from_options=self.extra_args_from_options, rpchost=None, timewait=self.rpc_timewait, bitcoind=self.options.bitcoind, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None))
self.nodes[i].args = args
self.start_node(i)

Expand Down
8 changes: 2 additions & 6 deletions test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,15 @@ class TestNode():
To make things easier for the test writer, any unrecognised messages will
be dispatched to the RPC connection."""

def __init__(self, i, datadir, extra_args_from_options, chain, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False):
def __init__(self, i, datadir, extra_args_from_options, *, chain, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False):
self.index = i
self.datadir = datadir
self.chain = chain
self.bitcoinconf = os.path.join(self.datadir, "dash.conf")
self.stdout_dir = os.path.join(self.datadir, "stdout")
self.stderr_dir = os.path.join(self.datadir, "stderr")
self.rpchost = rpchost
if timewait:
self.rpc_timeout = timewait
else:
# Wait for up to 60 seconds for the RPC server to respond
self.rpc_timeout = 60
self.rpc_timeout = timewait
self.rpc_timeout *= Options.timeout_scale
self.binary = bitcoind
self.coverage_dir = coverage_dir
Expand Down
9 changes: 3 additions & 6 deletions test/functional/wallet_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
self.extra_args = [["-keypool=90", "-usehd=1"]]
self.rpc_timeout = 120

def setup_network(self):
# TODO remove this when usehd=1 becomes the default
Expand All @@ -91,14 +92,10 @@ def setup_network(self):
self.options.cachedir = os.path.join(self.options.cachedir, 'hd')
self._initialize_chain(extra_args=self.extra_args[0])
self.set_cache_mocktime()
# Use 1 minute timeout because the initial getnewaddress RPC can take
# longer than the default 30 seconds due to an expensive
# CWallet::TopUpKeyPool call, and the encryptwallet RPC made later in
# the test often takes even longer.
self.add_nodes(self.num_nodes, extra_args=self.extra_args, timewait=60)
self.add_nodes(self.num_nodes, extra_args=self.extra_args)
self.start_nodes()

def run_test (self):
def run_test(self):
wallet_unenc_dump = os.path.join(self.nodes[0].datadir, "wallet.unencrypted.dump")
wallet_enc_dump = os.path.join(self.nodes[0].datadir, "wallet.encrypted.dump")

Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 3
self.extra_args = [[], [], ['-avoidpartialspends']]
self.rpc_timewait = 120

def run_test (self):
# Mine some coins
Expand Down

0 comments on commit 9babfdf

Please sign in to comment.