def test_packet(self): packet = ChatPacket() packet.message = u"κόσμε" packet_buffer = PacketBuffer() packet.write(packet_buffer) packet_buffer.reset_cursor() # Read the length and packet id VarInt.read(packet_buffer) packet_id = VarInt.read(packet_buffer) self.assertEqual(packet_id, packet.id) deserialized = ChatPacket() deserialized.read(packet_buffer) self.assertEqual(packet.message, deserialized.message)
def test_packet(self): for protocol_version in SUPPORTED_PROTOCOL_VERSIONS: context = ConnectionContext(protocol_version=protocol_version) packet = ChatPacket(context) packet.message = u"κόσμε" packet_buffer = PacketBuffer() packet.write(packet_buffer) packet_buffer.reset_cursor() # Read the length and packet id VarInt.read(packet_buffer) packet_id = VarInt.read(packet_buffer) self.assertEqual(packet_id, packet.id) deserialized = ChatPacket(context) deserialized.read(packet_buffer) self.assertEqual(packet.message, deserialized.message)