Fully test the encryption package, and add a test for uncompressed packets when packet compression is enabled

This commit is contained in:
Ammar Askar committed 2015-04-03 21:30:31 +05:00
1 parent 89f788f3ea
commit ea11461e76
4 files changed
+66 -18

No files matched your search

+3 -1
View File
@@ -77,7 +77,7 @@ class Packet(object):
# compression_threshold of None means compression is disabled
if compression_threshold is not None:
if len(packet_buffer.get_writable()) > compression_threshold:
if len(packet_buffer.get_writable()) > compression_threshold != -1:
# compress the current payload
compressed_data = compress(packet_buffer.get_writable())
packet_buffer.reset()
@@ -87,8 +87,10 @@ class Packet(object):
packet_buffer.send(compressed_data)
else:
# write out a 0 to indicate uncompressed data
packet_data = packet_buffer.get_writable()
packet_buffer.reset()
VarInt.send(0, packet_buffer)
packet_buffer.send(packet_data)
VarInt.send(len(packet_buffer.get_writable()), socket) # Packet Size
socket.send(packet_buffer.get_writable()) # Packet Payload