Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p-acceptblock.py
Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
-1, "Block not found on disk", self.nodes[0].getblock, all_blocks[-1].hash) | -1, "Block not found on disk", self.nodes[0].getblock, all_blocks[-1].hash) | ||||
# 5. Test handling of unrequested block on the node that didn't process | # 5. Test handling of unrequested block on the node that didn't process | ||||
# Should still not be processed (even though it has a child that has more | # Should still not be processed (even though it has a child that has more | ||||
# work). | # work). | ||||
# The node should have requested the blocks at some point, so | # The node should have requested the blocks at some point, so | ||||
# disconnect/reconnect first | # disconnect/reconnect first | ||||
self.nodes[0].disconnect_p2p() | self.nodes[0].disconnect_p2ps() | ||||
test_node = self.nodes[0].add_p2p_connection(NodeConnCB()) | test_node = self.nodes[0].add_p2p_connection(NodeConnCB()) | ||||
test_node.wait_for_verack() | test_node.wait_for_verack() | ||||
test_node.send_message(msg_block(block_h1f)) | test_node.send_message(msg_block(block_h1f)) | ||||
test_node.sync_with_ping() | test_node.sync_with_ping() | ||||
assert_equal(self.nodes[0].getblockcount(), 2) | assert_equal(self.nodes[0].getblockcount(), 2) | ||||
self.log.info( | self.log.info( | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# without assuming whether we will be disconnected or not | # without assuming whether we will be disconnected or not | ||||
try: | try: | ||||
# Only wait a short while so the test doesn't take forever if we do get | # Only wait a short while so the test doesn't take forever if we do get | ||||
# disconnected | # disconnected | ||||
test_node.sync_with_ping(timeout=1) | test_node.sync_with_ping(timeout=1) | ||||
except AssertionError: | except AssertionError: | ||||
test_node.wait_for_disconnect() | test_node.wait_for_disconnect() | ||||
self.nodes[0].disconnect_p2p() | self.nodes[0].disconnect_p2ps() | ||||
test_node = self.nodes[0].add_p2p_connection(NodeConnCB()) | test_node = self.nodes[0].add_p2p_connection(NodeConnCB()) | ||||
NetworkThread().start() # Start up network handling in another thread | NetworkThread().start() # Start up network handling in another thread | ||||
test_node.wait_for_verack() | test_node.wait_for_verack() | ||||
# We should have failed reorg and switched back to 290 (but have block 291) | # We should have failed reorg and switched back to 290 (but have block 291) | ||||
assert_equal(self.nodes[0].getblockcount(), 290) | assert_equal(self.nodes[0].getblockcount(), 290) | ||||
assert_equal(self.nodes[0].getbestblockhash(), all_blocks[286].hash) | assert_equal(self.nodes[0].getbestblockhash(), all_blocks[286].hash) | ||||
Show All 22 Lines |