Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show All 40 Lines | class TestStatus(Enum): | ||||
FAILED = 2 | FAILED = 2 | ||||
SKIPPED = 3 | SKIPPED = 3 | ||||
TEST_EXIT_PASSED = 0 | TEST_EXIT_PASSED = 0 | ||||
TEST_EXIT_FAILED = 1 | TEST_EXIT_FAILED = 1 | ||||
TEST_EXIT_SKIPPED = 77 | TEST_EXIT_SKIPPED = 77 | ||||
# Timestamp is 01.01.2019 | # Timestamp is Dec. 1st, 2019 at 00:00:00 | ||||
TIMESTAMP_IN_THE_PAST = 1546300800 | TIMESTAMP_IN_THE_PAST = 1575158400 | ||||
class BitcoinTestFramework(): | class BitcoinTestFramework(): | ||||
"""Base class for a bitcoin test script. | """Base class for a bitcoin test script. | ||||
Individual bitcoin test scripts should subclass this class and override the set_test_params() and run_test() methods. | Individual bitcoin test scripts should subclass this class and override the set_test_params() and run_test() methods. | ||||
Individual tests can also override the following methods to customize the test setup: | Individual tests can also override the following methods to customize the test setup: | ||||
Show All 39 Lines | def main(self): | ||||
parser.add_argument("--coveragedir", dest="coveragedir", | parser.add_argument("--coveragedir", dest="coveragedir", | ||||
help="Write tested RPC commands into this directory") | help="Write tested RPC commands into this directory") | ||||
parser.add_argument("--configfile", dest="configfile", default=os.path.abspath(os.path.dirname(os.path.realpath( | parser.add_argument("--configfile", dest="configfile", default=os.path.abspath(os.path.dirname(os.path.realpath( | ||||
__file__)) + "/../../config.ini"), help="Location of the test framework config file (default: %(default)s)") | __file__)) + "/../../config.ini"), help="Location of the test framework config file (default: %(default)s)") | ||||
parser.add_argument("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true", | parser.add_argument("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true", | ||||
help="Attach a python debugger if test fails") | help="Attach a python debugger if test fails") | ||||
parser.add_argument("--usecli", dest="usecli", default=False, action="store_true", | parser.add_argument("--usecli", dest="usecli", default=False, action="store_true", | ||||
help="use bitcoin-cli instead of RPC for all commands") | help="use bitcoin-cli instead of RPC for all commands") | ||||
parser.add_argument("--with-gravitonactivation", dest="gravitonactivation", default=False, action="store_true", | parser.add_argument("--with-phononactivation", dest="phononactivation", default=False, action="store_true", | ||||
help="Activate graviton update on timestamp {}".format(TIMESTAMP_IN_THE_PAST)) | help="Activate phonon update on timestamp {}".format(TIMESTAMP_IN_THE_PAST)) | ||||
self.add_options(parser) | self.add_options(parser) | ||||
self.options = parser.parse_args() | self.options = parser.parse_args() | ||||
self.set_test_params() | self.set_test_params() | ||||
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()" | ||||
PortSeed.n = self.options.port_seed | PortSeed.n = self.options.port_seed | ||||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | def add_nodes(self, num_nodes, extra_args=None, *, rpchost=None, binary=None): | ||||
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, | ||||
)) | )) | ||||
if self.options.gravitonactivation: | if self.options.phononactivation: | ||||
self.nodes[i].extend_default_args( | self.nodes[i].extend_default_args( | ||||
["-gravitonactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) | ["-phononactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) | ||||
def start_node(self, i, *args, **kwargs): | def start_node(self, i, *args, **kwargs): | ||||
"""Start a bitcoind""" | """Start a bitcoind""" | ||||
node = self.nodes[i] | node = self.nodes[i] | ||||
node.start(*args, **kwargs) | node.start(*args, **kwargs) | ||||
node.wait_for_rpc_connection() | node.wait_for_rpc_connection() | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | def _initialize_chain(self): | ||||
coverage_dir=None | 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.phononactivation: | ||||
self.nodes[i].extend_default_args( | self.nodes[i].extend_default_args( | ||||
["-gravitonactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) | ["-phononactivationtime={}".format(TIMESTAMP_IN_THE_PAST)]) | ||||
self.start_node(i) | self.start_node(i) | ||||
# Wait for RPC connections to be ready | # Wait for RPC connections to be ready | ||||
for node in self.nodes: | for node in self.nodes: | ||||
node.wait_for_rpc_connection() | node.wait_for_rpc_connection() | ||||
# For backward compatibility of the python scripts with previous | # For backward compatibility of the python scripts with previous | ||||
# versions of the cache, set mocktime to Jan 1, | # versions of the cache, set mocktime to Jan 1, | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |