diff options
author | MarcoFalke <falke.marco@gmail.com> | 2017-05-02 20:02:55 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2017-05-02 20:03:03 +0200 |
commit | dc8fc0c73bebbc1c48ac5540026030c9cc00ec23 (patch) | |
tree | 7f3a0bbb5ed9d64f4fe62a7e47abd2a8595a17eb /test/functional/test_framework/test_framework.py | |
parent | 8f3e38477e30abd9dd0e24a4d612126117f7793c (diff) | |
parent | c9cc76dcaad85aa9441f18d38298f27a0ffd852a (diff) | |
download | bitcoin-dc8fc0c73bebbc1c48ac5540026030c9cc00ec23.tar.xz |
Merge #10198: [tests] Remove is_network_split from functional test framework
c9cc76d [tests] Remove is_network_split from funtional test cases (John Newbery)
Tree-SHA512: a43ec63a7dc20cbe9048f8d3af755aef55e9247f605d6481e6d665112882a749af7514f29c83ca9d761421b8e0f7282e5b9f8fc471985d222de826da7cc80ccf
Diffstat (limited to 'test/functional/test_framework/test_framework.py')
-rwxr-xr-x | test/functional/test_framework/test_framework.py | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 473b7c14a9..e912dcbaff 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -17,6 +17,7 @@ from .util import ( initialize_chain, start_nodes, connect_nodes_bi, + disconnect_nodes, sync_blocks, sync_mempools, stop_nodes, @@ -56,52 +57,42 @@ class BitcoinTestFramework(object): stop_node(self.nodes[num_node], num_node) def setup_nodes(self): - return start_nodes(self.num_nodes, self.options.tmpdir) + extra_args = None + if hasattr(self, "extra_args"): + extra_args = self.extra_args + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, extra_args) - def setup_network(self, split = False): - self.nodes = self.setup_nodes() + def setup_network(self): + self.setup_nodes() # Connect the nodes as a "chain". This allows us # to split the network between nodes 1 and 2 to get # two halves that can work on competing chains. - - # If we joined network halves, connect the nodes from the joint - # on outward. This ensures that chains are properly reorganised. - if not split: - connect_nodes_bi(self.nodes, 1, 2) - sync_blocks(self.nodes[1:3]) - sync_mempools(self.nodes[1:3]) - - connect_nodes_bi(self.nodes, 0, 1) - connect_nodes_bi(self.nodes, 2, 3) - self.is_network_split = split + for i in range(self.num_nodes - 1): + connect_nodes_bi(self.nodes, i, i + 1) self.sync_all() def split_network(self): """ Split the network of four nodes into nodes 0/1 and 2/3. """ - assert not self.is_network_split - stop_nodes(self.nodes) - self.setup_network(True) - - def sync_all(self): - if self.is_network_split: - sync_blocks(self.nodes[:2]) - sync_blocks(self.nodes[2:]) - sync_mempools(self.nodes[:2]) - sync_mempools(self.nodes[2:]) - else: - sync_blocks(self.nodes) - sync_mempools(self.nodes) + disconnect_nodes(self.nodes[1], 2) + disconnect_nodes(self.nodes[2], 1) + self.sync_all([self.nodes[:2], self.nodes[2:]]) + + def sync_all(self, node_groups=None): + if not node_groups: + node_groups = [self.nodes] + + [sync_blocks(group) for group in node_groups] + [sync_mempools(group) for group in node_groups] def join_network(self): """ Join the (previously split) network halves together. """ - assert self.is_network_split - stop_nodes(self.nodes) - self.setup_network(False) + connect_nodes_bi(self.nodes, 1, 2) + self.sync_all() def main(self): |