ChillerDragon
0988cff4c9
Rename `name` -> `message_name` Replaced `GameMessage` and `SysMessage` with duck typed `NetMessage` Split up packet.py in multiple files
23 lines
691 B
Python
23 lines
691 B
Python
from twnet_parser.packet import *
|
|
|
|
def test_parse_7_close():
|
|
packet = parse7(b'\x04\x0a\x00\xcf\x2e\xde\x1d\04') # 0.7 close
|
|
|
|
assert packet.version == '0.7'
|
|
assert packet.header.flags.control == True
|
|
|
|
assert packet.messages[0].message_name == 'close'
|
|
assert len(packet.messages) == 1
|
|
|
|
def test_parse_7_close_with_reason():
|
|
packet = parse7(b'\x04\x0a\x00\xcf\x2e\xde\x1d\04shutdown\x00') # 0.7 close
|
|
|
|
assert packet.version == '0.7'
|
|
assert packet.header.flags.control == True
|
|
|
|
assert packet.messages[0].message_name == 'close'
|
|
assert len(packet.messages) == 1
|
|
|
|
# TODO: uncomment when implemented
|
|
# assert packet.messages[0].reason == 'shutdown'
|