Files
Commonwealth-Online-Server/server/tests/test_transport_policy.py
T

32 lines
1.1 KiB
Python

from transport_policy import Delivery, delivery_for_packet_type, is_snapshot_packet
def test_snapshot_packets_use_unreliable_sequenced_delivery():
assert delivery_for_packet_type("transform") is Delivery.UNRELIABLE_SEQUENCED
assert delivery_for_packet_type("npcState") is Delivery.UNRELIABLE_SEQUENCED
assert is_snapshot_packet("transform")
assert is_snapshot_packet("npcState")
def test_gameplay_and_control_packets_use_reliable_ordered_delivery():
reliable_types = (
"hello",
"sessionReady",
"worldState",
"combatHit",
"npcAuthority",
"positionCorrection",
"disconnect",
"sessionEnded",
"equipmentState",
"actionEvent",
"playerState",
)
for packet_type in reliable_types:
assert delivery_for_packet_type(packet_type) is Delivery.RELIABLE_ORDERED
assert not is_snapshot_packet(packet_type)
def test_unknown_packet_types_never_default_to_unreliable():
assert delivery_for_packet_type("futureControlPacket") is Delivery.RELIABLE_ORDERED