예제 #1
0
def test_decode_packed_with_remaining_data():
    data = (
        b"\x01\x00\x00\x00\x00\x00\x02\xf3\x47\x00\xff\xff\x00\xfe\xfe\xfe\xfe"
        b"\xfd\xfd\xfd\xfd\x12\x34\x56\x78\x00\x05\x27\x00\xaa\x0a\x23\xa3"
    ) + b"LOL"
    with pytest.raises(RemainingDataException):
        decode_packet(data)
예제 #2
0
def test_decode_packet():
    data = (
        b"\x01\x00\x00\x00\x00\x00\x02\xf3\x47\x00\xff\xff\x00\xfe\xfe\xfe\xfe"
        b"\xfd\xfd\xfd\xfd\x12\x34\x56\x78\x00\x05\x27\x00\xaa\x0a\x23\xa3"
    )
    packet = decode_packet(data)
    assert packet.id == 0x01
    assert type(packet) == packets.UnconnectedPing
예제 #3
0
def test_decode_disconnection_notification():
    packet = decode_packet(b"\x15")
    assert packet.id == 0x15
    assert type(packet) == packets.DisconnectionNotification
예제 #4
0
def test_decode_invalid_packet():
    with pytest.raises(UnknownPacketException):
        decode_packet(b"\xff\x00\x00\x00\x00")