Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | def __init__(self): | ||||
# Wait for up to 60 seconds for the RPC server to respond | # Wait for up to 60 seconds for the RPC server to respond | ||||
self.rpc_timeout = 60 | self.rpc_timeout = 60 | ||||
self.supports_cli = True | self.supports_cli = True | ||||
self.bind_to_localhost_only = True | self.bind_to_localhost_only = True | ||||
# We run parse_args before set_test_params for tests who need to | # We run parse_args before set_test_params for tests who need to | ||||
# know the parser options during setup. | # know the parser options during setup. | ||||
self.parse_args() | self.parse_args() | ||||
self.set_test_params() | self.set_test_params() | ||||
if self.options.timeout_factor == 0: | |||||
self.options.timeout_factor = 99999 | |||||
# optionally, increase timeout by a factor | # optionally, increase timeout by a factor | ||||
self.rpc_timeout = int(self.rpc_timeout * self.options.factor) | self.rpc_timeout = int(self.rpc_timeout * self.options.timeout_factor) | ||||
def main(self): | def main(self): | ||||
"""Main function. This should not be overridden by the subclass test scripts.""" | """Main function. This should not be overridden by the subclass test scripts.""" | ||||
assert hasattr( | assert hasattr( | ||||
self, "num_nodes"), "Test must set self.num_nodes in set_test_params()" | self, "num_nodes"), "Test must set self.num_nodes in set_test_params()" | ||||
try: | try: | ||||
self.setup() | self.setup() | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | def parse_args(self): | ||||
help="profile running nodes with perf for the duration of the test") | help="profile running nodes with perf for the duration of the test") | ||||
parser.add_argument("--valgrind", dest="valgrind", default=False, action="store_true", | parser.add_argument("--valgrind", dest="valgrind", default=False, action="store_true", | ||||
help="run nodes under the valgrind memory error detector: expect at least a ~10x slowdown, valgrind 3.14 or later required") | help="run nodes under the valgrind memory error detector: expect at least a ~10x slowdown, valgrind 3.14 or later required") | ||||
parser.add_argument("--randomseed", type=int, | parser.add_argument("--randomseed", type=int, | ||||
help="set a random seed for deterministically reproducing a previous test run") | help="set a random seed for deterministically reproducing a previous test run") | ||||
parser.add_argument("--with-axionactivation", dest="axionactivation", default=False, action="store_true", | parser.add_argument("--with-axionactivation", dest="axionactivation", default=False, action="store_true", | ||||
help="Activate axion update on timestamp {}".format(TIMESTAMP_IN_THE_PAST)) | help="Activate axion update on timestamp {}".format(TIMESTAMP_IN_THE_PAST)) | ||||
parser.add_argument( | parser.add_argument( | ||||
'--factor', | '--timeout-factor', | ||||
dest="timeout_factor", | |||||
type=float, | type=float, | ||||
default=1.0, | default=1.0, | ||||
help='adjust test timeouts by a factor') | help='adjust test timeouts by a factor. ' | ||||
'Setting it to 0 disables all timeouts') | |||||
self.add_options(parser) | self.add_options(parser) | ||||
self.options = parser.parse_args() | self.options = parser.parse_args() | ||||
def setup(self): | def setup(self): | ||||
"""Call this method to start up the test framework object with options set.""" | """Call this method to start up the test framework object with options set.""" | ||||
PortSeed.n = self.options.port_seed | PortSeed.n = self.options.port_seed | ||||
▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | def add_nodes(self, num_nodes, extra_args=None, | ||||
self.nodes.append(TestNode( | self.nodes.append(TestNode( | ||||
i, | i, | ||||
get_datadir_path(self.options.tmpdir, i), | get_datadir_path(self.options.tmpdir, i), | ||||
chain=self.chain, | chain=self.chain, | ||||
host=host, | host=host, | ||||
rpc_port=rpc_port(i), | rpc_port=rpc_port(i), | ||||
p2p_port=p2p_port(i), | p2p_port=p2p_port(i), | ||||
timewait=self.rpc_timeout, | timewait=self.rpc_timeout, | ||||
factor=self.options.factor, | timeout_factor=self.options.timeout_factor, | ||||
bitcoind=binary[i], | bitcoind=binary[i], | ||||
bitcoin_cli=self.options.bitcoincli, | bitcoin_cli=self.options.bitcoincli, | ||||
coverage_dir=self.options.coveragedir, | coverage_dir=self.options.coveragedir, | ||||
cwd=self.options.tmpdir, | cwd=self.options.tmpdir, | ||||
extra_conf=extra_confs[i], | extra_conf=extra_confs[i], | ||||
extra_args=extra_args[i], | extra_args=extra_args[i], | ||||
use_cli=self.options.usecli, | use_cli=self.options.usecli, | ||||
emulator=self.options.emulator, | emulator=self.options.emulator, | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | def _initialize_chain(self): | ||||
cache_node_dir, | cache_node_dir, | ||||
chain=self.chain, | chain=self.chain, | ||||
extra_conf=["bind=127.0.0.1"], | extra_conf=["bind=127.0.0.1"], | ||||
extra_args=['-disablewallet'], | extra_args=['-disablewallet'], | ||||
host=None, | host=None, | ||||
rpc_port=rpc_port(CACHE_NODE_ID), | rpc_port=rpc_port(CACHE_NODE_ID), | ||||
p2p_port=p2p_port(CACHE_NODE_ID), | p2p_port=p2p_port(CACHE_NODE_ID), | ||||
timewait=self.rpc_timeout, | timewait=self.rpc_timeout, | ||||
factor=self.options.factor, | timeout_factor=self.options.timeout_factor, | ||||
bitcoind=self.options.bitcoind, | bitcoind=self.options.bitcoind, | ||||
bitcoin_cli=self.options.bitcoincli, | bitcoin_cli=self.options.bitcoincli, | ||||
coverage_dir=None, | coverage_dir=None, | ||||
cwd=self.options.tmpdir, | cwd=self.options.tmpdir, | ||||
emulator=self.options.emulator, | emulator=self.options.emulator, | ||||
)) | )) | ||||
if self.options.axionactivation: | if self.options.axionactivation: | ||||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |