Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_node_network_limited.py
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
node1.wait_for_addr() | node1.wait_for_addr() | ||||
# must relay address with NODE_NETWORK_LIMITED | # must relay address with NODE_NETWORK_LIMITED | ||||
assert_equal(node1.firstAddrnServices, expected_services) | assert_equal(node1.firstAddrnServices, expected_services) | ||||
self.nodes[0].disconnect_p2ps() | self.nodes[0].disconnect_p2ps() | ||||
node1.wait_for_disconnect() | node1.wait_for_disconnect() | ||||
# connect unsynced node 2 with pruned NODE_NETWORK_LIMITED peer | # connect unsynced node 2 with pruned NODE_NETWORK_LIMITED peer | ||||
# because node 2 is in IBD and node 0 is a NODE_NETWORK_LIMITED peer, sync must not be possible | # because node 2 is in IBD and node 0 is a NODE_NETWORK_LIMITED peer, | ||||
# sync must not be possible | |||||
connect_nodes_bi(self.nodes[0], self.nodes[2]) | connect_nodes_bi(self.nodes[0], self.nodes[2]) | ||||
try: | try: | ||||
sync_blocks([self.nodes[0], self.nodes[2]], timeout=5) | sync_blocks([self.nodes[0], self.nodes[2]], timeout=5) | ||||
except Exception: | except Exception: | ||||
pass | pass | ||||
# node2 must remain at heigh 0 | # node2 must remain at heigh 0 | ||||
assert_equal(self.nodes[2].getblockheader( | assert_equal(self.nodes[2].getblockheader( | ||||
self.nodes[2].getbestblockhash())['height'], 0) | self.nodes[2].getbestblockhash())['height'], 0) | ||||
# now connect also to node 1 (non pruned) | # now connect also to node 1 (non pruned) | ||||
connect_nodes_bi(self.nodes[1], self.nodes[2]) | connect_nodes_bi(self.nodes[1], self.nodes[2]) | ||||
# sync must be possible | # sync must be possible | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
# disconnect all peers | # disconnect all peers | ||||
self.disconnect_all() | self.disconnect_all() | ||||
# mine 10 blocks on node 0 (pruned node) | # mine 10 blocks on node 0 (pruned node) | ||||
self.nodes[0].generate(10) | self.nodes[0].generate(10) | ||||
# connect node1 (non pruned) with node0 (pruned) and check if the can sync | # connect node1 (non pruned) with node0 (pruned) and check if the can | ||||
# sync | |||||
connect_nodes_bi(self.nodes[0], self.nodes[1]) | connect_nodes_bi(self.nodes[0], self.nodes[1]) | ||||
# sync must be possible, node 1 is no longer in IBD and should therefore connect to node 0 (NODE_NETWORK_LIMITED) | # sync must be possible, node 1 is no longer in IBD and should | ||||
# therefore connect to node 0 (NODE_NETWORK_LIMITED) | |||||
sync_blocks([self.nodes[0], self.nodes[1]]) | sync_blocks([self.nodes[0], self.nodes[1]]) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
NodeNetworkLimitedTest().main() | NodeNetworkLimitedTest().main() |