def msg_ping(self, msg: PingMessage): nonce = msg.nonce() assumed_request_time = time.time( ) - nonce_generator.get_timestamp_from_nonce(nonce) self.inbound_peer_latency = assumed_request_time hooks.add_measurement(self.peer_desc, MeasurementType.PING_INCOMING, assumed_request_time, self.peer_id) self.enqueue_msg( PongMessage(nonce=nonce, timestamp=nonce_generator.get_nonce()))
def test_ping_response_msg(self): ping = PingMessage(nonce=50) self.assertEqual(50, ping.nonce()) msg = bloxroute_message_factory.create_message_from_buffer(ping.buf) self.assertEqual(50, msg.nonce())