Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_framework.py
Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | class BitcoinTestFramework(): | ||||
def setup_network(self): | def setup_network(self): | ||||
"""Override this method to customize test network topology""" | """Override this method to customize test network topology""" | ||||
self.setup_nodes() | self.setup_nodes() | ||||
# Connect the nodes as a "chain". This allows us | # Connect the nodes as a "chain". This allows us | ||||
# to split the network between nodes 1 and 2 to get | # to split the network between nodes 1 and 2 to get | ||||
# two halves that can work on competing chains. | # two halves that can work on competing chains. | ||||
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], self.nodes[i + 1]) | ||||
self.sync_all() | self.sync_all() | ||||
def setup_nodes(self): | def setup_nodes(self): | ||||
"""Override this method to customize test node setup""" | """Override this method to customize test node setup""" | ||||
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.add_nodes(self.num_nodes, extra_args) | self.add_nodes(self.num_nodes, extra_args) | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | def split_network(self): | ||||
disconnect_nodes(self.nodes[1], self.nodes[2]) | disconnect_nodes(self.nodes[1], self.nodes[2]) | ||||
disconnect_nodes(self.nodes[2], self.nodes[1]) | disconnect_nodes(self.nodes[2], self.nodes[1]) | ||||
self.sync_all([self.nodes[:2], self.nodes[2:]]) | self.sync_all([self.nodes[:2], self.nodes[2:]]) | ||||
def join_network(self): | def join_network(self): | ||||
""" | """ | ||||
Join the (previously split) network halves together. | Join the (previously split) network halves together. | ||||
""" | """ | ||||
connect_nodes_bi(self.nodes, 1, 2) | connect_nodes_bi(self.nodes[1], self.nodes[2]) | ||||
self.sync_all() | self.sync_all() | ||||
def sync_all(self, node_groups=None): | def sync_all(self, node_groups=None): | ||||
if not node_groups: | if not node_groups: | ||||
node_groups = [self.nodes] | node_groups = [self.nodes] | ||||
for group in node_groups: | for group in node_groups: | ||||
sync_blocks(group) | sync_blocks(group) | ||||
▲ Show 20 Lines • Show All 168 Lines • Show Last 20 Lines |