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

41 lines
1.3 KiB
Python

from transport_policy import (
Delivery,
delivery_for_packet_type,
is_snapshot_packet,
requires_application_sequence,
)
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")
assert requires_application_sequence("transform")
assert requires_application_sequence("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)
assert not requires_application_sequence(packet_type)
def test_unknown_packet_types_never_default_to_unreliable():
assert delivery_for_packet_type("futureControlPacket") is Delivery.RELIABLE_ORDERED
assert not requires_application_sequence("futureControlPacket")