Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | class BitcoinTestFramework(): | ||||
def __init__(self): | def __init__(self): | ||||
"""Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method""" | """Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method""" | ||||
self.setup_clean_chain = False | self.setup_clean_chain = False | ||||
self.nodes = [] | self.nodes = [] | ||||
self.network_thread = None | self.network_thread = None | ||||
self.mocktime = 0 | self.mocktime = 0 | ||||
# 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_timewait = 60 | self.rpc_timeout = 60 | ||||
self.supports_cli = False | self.supports_cli = False | ||||
self.bind_to_localhost_only = True | self.bind_to_localhost_only = True | ||||
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.""" | ||||
parser = argparse.ArgumentParser(usage="%(prog)s [options]") | parser = argparse.ArgumentParser(usage="%(prog)s [options]") | ||||
parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true", | parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true", | ||||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | def add_nodes(self, num_nodes, extra_args=None, *, rpchost=None, binary=None): | ||||
assert_equal(len(binary), num_nodes) | assert_equal(len(binary), num_nodes) | ||||
for i in range(num_nodes): | for i in range(num_nodes): | ||||
self.nodes.append(TestNode( | self.nodes.append(TestNode( | ||||
i, | i, | ||||
get_datadir_path(self.options.tmpdir, i), | get_datadir_path(self.options.tmpdir, i), | ||||
host=rpchost, | host=rpchost, | ||||
rpc_port=rpc_port(i), | rpc_port=rpc_port(i), | ||||
p2p_port=p2p_port(i), | p2p_port=p2p_port(i), | ||||
timewait=self.rpc_timewait, | timewait=self.rpc_timeout, | ||||
bitcoind=binary[i], | bitcoind=binary[i], | ||||
bitcoin_cli=self.options.bitcoincli, | bitcoin_cli=self.options.bitcoincli, | ||||
mocktime=self.mocktime, | mocktime=self.mocktime, | ||||
coverage_dir=self.options.coveragedir, | coverage_dir=self.options.coveragedir, | ||||
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, | ||||
)) | )) | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | def _initialize_chain(self): | ||||
# find and delete old cache directories if any exist | # find and delete old cache directories if any exist | ||||
for i in range(MAX_NODES): | for i in range(MAX_NODES): | ||||
if os.path.isdir(get_datadir_path(self.options.cachedir, i)): | if os.path.isdir(get_datadir_path(self.options.cachedir, i)): | ||||
shutil.rmtree(get_datadir_path(self.options.cachedir, i)) | shutil.rmtree(get_datadir_path(self.options.cachedir, i)) | ||||
# Create cache directories, run bitcoinds: | # Create cache directories, run bitcoinds: | ||||
for i in range(MAX_NODES): | for i in range(MAX_NODES): | ||||
datadir = initialize_datadir(self.options.cachedir, i) | datadir = initialize_datadir(self.options.cachedir, i) | ||||
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), extra_conf=["bind=127.0.0.1"], extra_args=[], host=None, rpc_port=rpc_port( | self.nodes.append(TestNode( | ||||
i), p2p_port=p2p_port(i), timewait=self.rpc_timewait, bitcoind=self.options.bitcoind, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None)) | i, | ||||
get_datadir_path(self.options.cachedir, i), | |||||
extra_conf=["bind=127.0.0.1"], | |||||
extra_args=[], | |||||
host=None, | |||||
rpc_port=rpc_port(i), | |||||
p2p_port=p2p_port(i), | |||||
timewait=self.rpc_timeout, | |||||
bitcoind=self.options.bitcoind, | |||||
bitcoin_cli=self.options.bitcoincli, | |||||
mocktime=self.mocktime, | |||||
coverage_dir=None | |||||
)) | |||||
self.nodes[i].clear_default_args() | self.nodes[i].clear_default_args() | ||||
self.nodes[i].extend_default_args(["-datadir=" + datadir]) | self.nodes[i].extend_default_args(["-datadir=" + datadir]) | ||||
self.nodes[i].extend_default_args(["-disablewallet"]) | self.nodes[i].extend_default_args(["-disablewallet"]) | ||||
if i > 0: | if i > 0: | ||||
self.nodes[i].extend_default_args( | self.nodes[i].extend_default_args( | ||||
["-connect=127.0.0.1:" + str(p2p_port(0))]) | ["-connect=127.0.0.1:" + str(p2p_port(0))]) | ||||
if self.options.gravitonactivation: | if self.options.gravitonactivation: | ||||
self.nodes[i].extend_default_args( | self.nodes[i].extend_default_args( | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |