Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show All 27 Lines | from .util import ( | ||||
get_mocktime, | get_mocktime, | ||||
get_rpc_proxy, | get_rpc_proxy, | ||||
initialize_datadir, | initialize_datadir, | ||||
get_datadir_path, | get_datadir_path, | ||||
log_filename, | log_filename, | ||||
p2p_port, | p2p_port, | ||||
rpc_url, | rpc_url, | ||||
set_node_times, | set_node_times, | ||||
start_node, | _start_node, | ||||
start_nodes, | _start_nodes, | ||||
stop_node, | _stop_node, | ||||
stop_nodes, | _stop_nodes, | ||||
sync_blocks, | sync_blocks, | ||||
sync_mempools, | sync_mempools, | ||||
wait_for_bitcoind_start, | wait_for_bitcoind_start, | ||||
) | ) | ||||
from .authproxy import JSONRPCException | from .authproxy import JSONRPCException | ||||
class TestStatus(Enum): | class TestStatus(Enum): | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | def setup_network(self): | ||||
for i in range(self.num_nodes - 1): | for i in range(self.num_nodes - 1): | ||||
connect_nodes_bi(self.nodes, i, i + 1) | connect_nodes_bi(self.nodes, i, i + 1) | ||||
self.sync_all() | self.sync_all() | ||||
def setup_nodes(self): | def setup_nodes(self): | ||||
extra_args = None | extra_args = None | ||||
if hasattr(self, "extra_args"): | if hasattr(self, "extra_args"): | ||||
extra_args = self.extra_args | extra_args = self.extra_args | ||||
self.nodes = start_nodes( | self.nodes = _start_nodes( | ||||
self.num_nodes, self.options.tmpdir, extra_args) | self.num_nodes, self.options.tmpdir, extra_args) | ||||
def run_test(self): | def run_test(self): | ||||
raise NotImplementedError | raise NotImplementedError | ||||
# Main function. This should not be overridden by the subclass test scripts. | # Main function. This should not be overridden by the subclass test scripts. | ||||
def main(self): | def main(self): | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | def main(self): | ||||
self.log.error( | self.log.error( | ||||
"Test failed. Test logging available at %s/test_framework.log", self.options.tmpdir) | "Test failed. Test logging available at %s/test_framework.log", self.options.tmpdir) | ||||
logging.shutdown() | logging.shutdown() | ||||
sys.exit(TEST_EXIT_FAILED) | sys.exit(TEST_EXIT_FAILED) | ||||
# Public helper methods. These can be accessed by the subclass test scripts. | # Public helper methods. These can be accessed by the subclass test scripts. | ||||
def start_node(self, i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, stderr=None): | def start_node(self, i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, stderr=None): | ||||
return start_node(i, dirname, extra_args, rpchost, timewait, binary, stderr) | return _start_node(i, dirname, extra_args, rpchost, timewait, binary, stderr) | ||||
def start_nodes(self, num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None): | def start_nodes(self, num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None): | ||||
return start_nodes(num_nodes, dirname, extra_args, rpchost, timewait, binary) | return _start_nodes(num_nodes, dirname, extra_args, rpchost, timewait, binary) | ||||
def stop_node(self, num_node): | def stop_node(self, num_node): | ||||
stop_node(self.nodes[num_node], num_node) | _stop_node(self.nodes[num_node], num_node) | ||||
def stop_nodes(self): | def stop_nodes(self): | ||||
stop_nodes(self.nodes) | _stop_nodes(self.nodes) | ||||
def split_network(self): | def split_network(self): | ||||
""" | """ | ||||
Split the network of four nodes into nodes 0/1 and 2/3. | Split the network of four nodes into nodes 0/1 and 2/3. | ||||
""" | """ | ||||
disconnect_nodes(self.nodes[1], 2) | disconnect_nodes(self.nodes[1], 2) | ||||
disconnect_nodes(self.nodes[2], 1) | disconnect_nodes(self.nodes[2], 1) | ||||
self.sync_all([self.nodes[:2], self.nodes[2:]]) | self.sync_all([self.nodes[:2], self.nodes[2:]]) | ||||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |