(self)
| 45 | self.nodes[0].setmocktime(self.mock_time) |
| 46 | |
| 47 | def run_test(self): |
| 48 | self.mock_time = int(time.time()) |
| 49 | self.mock_forward(0) |
| 50 | |
| 51 | # Setup the p2p connections, making sure the connections are established before the mocktime is bumped |
| 52 | with self.nodes[0].assert_debug_log(['Added connection peer=0']): |
| 53 | no_verack_node = self.nodes[0].add_p2p_connection(TestP2PConn(), wait_for_verack=False) |
| 54 | with self.nodes[0].assert_debug_log(['Added connection peer=1']): |
| 55 | no_version_node = self.nodes[0].add_p2p_connection(TestP2PConn(), send_version=False, wait_for_verack=False) |
| 56 | with self.nodes[0].assert_debug_log(['Added connection peer=2']): |
| 57 | no_send_node = self.nodes[0].add_p2p_connection(TestP2PConn(), send_version=False, wait_for_verack=False) |
| 58 | |
| 59 | # Wait until we got the verack in response to the version. Though, don't wait for the other node to receive the |
| 60 | # verack, since we never sent one |
| 61 | no_verack_node.wait_for_verack() |
| 62 | |
| 63 | self.mock_forward(1) |
| 64 | |
| 65 | assert no_verack_node.is_connected |
| 66 | assert no_version_node.is_connected |
| 67 | assert no_send_node.is_connected |
| 68 | |
| 69 | with self.nodes[0].assert_debug_log(['Unsupported message "ping" prior to verack from peer=0']): |
| 70 | no_verack_node.send_message(msg_ping()) |
| 71 | with self.nodes[0].assert_debug_log(['non-version message before version handshake. Message "ping" from peer=1']): |
| 72 | no_version_node.send_message(msg_ping()) |
| 73 | |
| 74 | self.mock_forward(1) |
| 75 | |
| 76 | assert "version" in no_verack_node.last_message |
| 77 | |
| 78 | assert no_verack_node.is_connected |
| 79 | assert no_version_node.is_connected |
| 80 | assert no_send_node.is_connected |
| 81 | |
| 82 | no_verack_node.send_message(msg_ping()) |
| 83 | no_version_node.send_message(msg_ping()) |
| 84 | |
| 85 | expected_timeout_logs = [ |
| 86 | "version handshake timeout peer=0", |
| 87 | "socket no message in first 3 seconds, 1 0 peer=1", |
| 88 | "socket no message in first 3 seconds, 0 0 peer=2", |
| 89 | ] |
| 90 | |
| 91 | with self.nodes[0].assert_debug_log(expected_msgs=expected_timeout_logs): |
| 92 | self.mock_forward(2) |
| 93 | no_verack_node.wait_for_disconnect(timeout=1) |
| 94 | no_version_node.wait_for_disconnect(timeout=1) |
| 95 | no_send_node.wait_for_disconnect(timeout=1) |
| 96 | |
| 97 | |
| 98 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected