Removes the version-mismatch guard from Protocol.decode_snapshot() and the PROTOCOL_VERSION constant from the client (server side done in #874). Core changes: - protocol.gd: remove const PROTOCOL_VERSION, remove version mismatch guard, remove "version" from return dict, add gauntlet_mode/room_id decode - sim_bridge.gd: remove handshake version check; relax handshake guard to require only a valid Dictionary (server no longer sends protocol_version); emit handshake_complete(0) for API compat - loading_screen.gd: drop "· protocol N" suffix from version label - test_harness.gd: replace Protocol.PROTOCOL_VERSION with literal 23 Test updates (21 files): replace "version": Protocol.PROTOCOL_VERSION with "version": 23 in all snapshot bytes dicts; remove snapshot.version == N assertions; remove version-rejection tests (test_rejects_version_6, test_decode_snapshot_rejects_missing_version, test_decode_snapshot_rejects_old_version, test_protocol_rejects_version_mismatch, test_sim_bridge_test_snapshot_uses_current_protocol_version). Also includes: #872 bookmark_catalog carry-forward regression test, and #873 merge-path flow tests (test_merge_path_flows_sprint37.gd). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
176 lines
6.7 KiB
GDScript
176 lines
6.7 KiB
GDScript
## D-030 Layer 1: Cross-language IPC fixture tests (#271)
|
|
## Validates that Protocol.gd decodes the #271 named fixtures identically to Rust.
|
|
## Fixtures generated by: cargo test --test gen_fixtures -- --ignored
|
|
## Rust validation: server/tests/serialization.rs (fixture_* tests)
|
|
class_name TestIpcFixtures
|
|
extends GdUnitTestSuite
|
|
|
|
const FIXTURE_DIR = "res://tests/fixtures/msgpack/"
|
|
|
|
|
|
func _load_fixture(name: String) -> PackedByteArray:
|
|
var path = FIXTURE_DIR + name + ".msgpack"
|
|
var file = FileAccess.open(path, FileAccess.READ)
|
|
assert_that(file).is_not_null().override_failure_message(
|
|
"Fixture not found: %s — run 'make fixtures' to regenerate" % path
|
|
)
|
|
return file.get_buffer(file.get_length())
|
|
|
|
|
|
# -- snapshot_minimal ----------------------------------------------------------
|
|
|
|
func test_fixture_snapshot_minimal_tick() -> void:
|
|
var bytes = _load_fixture("snapshot_minimal")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.tick).is_equal(0)
|
|
|
|
|
|
func test_fixture_snapshot_minimal_entity_count() -> void:
|
|
var bytes = _load_fixture("snapshot_minimal")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.entities.size()).is_equal(1)
|
|
|
|
|
|
func test_fixture_snapshot_minimal_entity_kind() -> void:
|
|
var bytes = _load_fixture("snapshot_minimal")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
var entity = snapshot.entities[0]
|
|
assert_that(entity.entity_id).is_equal(1)
|
|
# entity.kind is {"variant": "Player", "data": null} from _decode_enum_variant
|
|
assert_that(entity.kind.variant).is_equal("Player")
|
|
|
|
|
|
func test_fixture_snapshot_minimal_no_monologue() -> void:
|
|
var bytes = _load_fixture("snapshot_minimal")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.current_monologue).is_null()
|
|
|
|
|
|
func test_fixture_snapshot_minimal_no_dialogue() -> void:
|
|
var bytes = _load_fixture("snapshot_minimal")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.dialogue_response).is_null()
|
|
|
|
|
|
# -- snapshot_full -------------------------------------------------------------
|
|
|
|
func test_fixture_snapshot_full_tick() -> void:
|
|
var bytes = _load_fixture("snapshot_full")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot).is_not_null()
|
|
assert_that(snapshot.tick).is_equal(42)
|
|
|
|
|
|
func test_fixture_snapshot_full_monologue_id() -> void:
|
|
var bytes = _load_fixture("snapshot_full")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.current_monologue).is_not_null()
|
|
assert_that(snapshot.current_monologue.id).is_equal("test_monologue_001")
|
|
|
|
|
|
func test_fixture_snapshot_full_monologue_text() -> void:
|
|
var bytes = _load_fixture("snapshot_full")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.current_monologue.text).is_equal("Something feels off about this place.")
|
|
|
|
|
|
func test_fixture_snapshot_full_dialogue_speaker() -> void:
|
|
var bytes = _load_fixture("snapshot_full")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.dialogue_response).is_not_null()
|
|
# dialogue_response has: line_id, text, speaker_entity_id (per protocol.gd v8 decode)
|
|
assert_that(snapshot.dialogue_response.speaker_entity_id).is_equal(99)
|
|
|
|
|
|
func test_fixture_snapshot_full_inventory() -> void:
|
|
var bytes = _load_fixture("snapshot_full")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.player_inventory.size()).is_equal(1)
|
|
assert_that(snapshot.player_inventory[0].name).is_equal("Forged Customs Cert")
|
|
|
|
|
|
func test_fixture_snapshot_full_poi_list() -> void:
|
|
var bytes = _load_fixture("snapshot_full")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.poi_list.size()).is_equal(1)
|
|
assert_that(snapshot.poi_list[0].poi_id).is_equal("docking_bay_7")
|
|
|
|
|
|
func test_fixture_snapshot_full_player_knowledge_entity() -> void:
|
|
var bytes = _load_fixture("snapshot_full")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.player_knowledge).is_not_null()
|
|
assert_that(snapshot.player_knowledge.entities.size()).is_equal(1)
|
|
assert_that(snapshot.player_knowledge.entities[0].name).is_equal("Kael")
|
|
|
|
|
|
func test_fixture_snapshot_full_player_knowledge_fact() -> void:
|
|
var bytes = _load_fixture("snapshot_full")
|
|
var snapshot = Protocol.decode_snapshot(bytes)
|
|
assert_that(snapshot.player_knowledge.facts.size()).is_equal(1)
|
|
assert_that(snapshot.player_knowledge.facts[0].fact_id).is_equal("poi.docking_bay_7")
|
|
|
|
|
|
# -- player_input_move ---------------------------------------------------------
|
|
|
|
func test_fixture_player_input_move_tick() -> void:
|
|
var bytes = _load_fixture("player_input_move")
|
|
var input = Protocol.decode_player_input(bytes)
|
|
assert_that(input).is_not_null()
|
|
assert_that(input.tick).is_equal(1)
|
|
|
|
|
|
func test_fixture_player_input_move_action() -> void:
|
|
var bytes = _load_fixture("player_input_move")
|
|
var input = Protocol.decode_player_input(bytes)
|
|
# action is {"variant": "MoveNorth", "data": null} from _decode_enum_variant
|
|
assert_that(input.action.variant).is_equal("MoveNorth")
|
|
|
|
|
|
# -- player_input_interact -----------------------------------------------------
|
|
|
|
func test_fixture_player_input_interact_tick() -> void:
|
|
var bytes = _load_fixture("player_input_interact")
|
|
var input = Protocol.decode_player_input(bytes)
|
|
assert_that(input).is_not_null()
|
|
assert_that(input.tick).is_equal(2)
|
|
|
|
|
|
func test_fixture_player_input_interact_action() -> void:
|
|
var bytes = _load_fixture("player_input_interact")
|
|
var input = Protocol.decode_player_input(bytes)
|
|
# Interact is a struct variant: {"variant": "Interact", "data": {"target_entity_id": 99, "verb": "Talk"}}
|
|
assert_that(input.action.variant).is_equal("Interact")
|
|
|
|
|
|
func test_fixture_player_input_interact_target() -> void:
|
|
var bytes = _load_fixture("player_input_interact")
|
|
var input = Protocol.decode_player_input(bytes)
|
|
assert_that(input.action.data.target_entity_id).is_equal(99)
|
|
|
|
|
|
func test_fixture_player_input_interact_verb() -> void:
|
|
var bytes = _load_fixture("player_input_interact")
|
|
var input = Protocol.decode_player_input(bytes)
|
|
assert_that(input.action.data.verb).is_equal("Talk")
|
|
|
|
|
|
# -- malformed -----------------------------------------------------------------
|
|
|
|
func test_fixture_malformed_snapshot_fails() -> void:
|
|
var bytes = _load_fixture("malformed")
|
|
# Intentionally truncated — decode_snapshot must return null (not crash)
|
|
var result = Protocol.decode_snapshot(bytes)
|
|
assert_that(result).is_null().override_failure_message(
|
|
"malformed fixture should not decode as a valid ObserverSnapshot"
|
|
)
|
|
|
|
|
|
func test_fixture_malformed_input_fails() -> void:
|
|
var bytes = _load_fixture("malformed")
|
|
# Intentionally truncated — decode_player_input must return null (not crash)
|
|
var result = Protocol.decode_player_input(bytes)
|
|
assert_that(result).is_null().override_failure_message(
|
|
"malformed fixture should not decode as a valid PlayerInput"
|
|
)
|