diff --git a/server/tests/serialization.rs b/server/tests/serialization.rs index 6551b76ac..568aa6618 100644 --- a/server/tests/serialization.rs +++ b/server/tests/serialization.rs @@ -49,3 +49,58 @@ fn empty_snapshot_roundtrip() { assert_eq!(decoded.tick, 0); assert!(decoded.entities.is_empty()); } + +/// All PlayerAction variants must survive MessagePack round-trip (D-030 Layer 1) +#[test] +fn all_player_action_variants_roundtrip() { + let actions = vec![ + PlayerAction::MoveNorth, + PlayerAction::MoveSouth, + PlayerAction::MoveEast, + PlayerAction::MoveWest, + PlayerAction::Interact, + PlayerAction::UsePerceptionMode("thermal".to_string()), + PlayerAction::Pause, + PlayerAction::Unpause, + ]; + + for action in actions { + let input = PlayerInput { + tick: 1, + action: action.clone(), + }; + let bytes = rmp_serde::to_vec(&input).expect("serialize"); + let decoded: PlayerInput = rmp_serde::from_slice(&bytes).expect("deserialize"); + assert_eq!(decoded.tick, 1); + // Verify the variant survived by re-serializing and comparing bytes + let re_bytes = rmp_serde::to_vec(&decoded).expect("re-serialize"); + assert_eq!(bytes, re_bytes, "round-trip mismatch for action variant"); + } +} + +/// All EntityKind variants must survive MessagePack round-trip (D-030 Layer 1) +#[test] +fn all_entity_kind_variants_roundtrip() { + let kinds = vec![EntityKind::Npc, EntityKind::Object, EntityKind::Terrain]; + + for (i, kind) in kinds.into_iter().enumerate() { + let entity = VisibleEntity { + entity_id: i as u64, + x: 0.0, + y: 0.0, + z: 0, + kind, + }; + let snapshot = ObserverSnapshot { + tick: 0, + entities: vec![entity], + }; + let bytes = rmp_serde::to_vec(&snapshot).expect("serialize"); + let decoded: ObserverSnapshot = rmp_serde::from_slice(&bytes).expect("deserialize"); + let re_bytes = rmp_serde::to_vec(&decoded).expect("re-serialize"); + assert_eq!( + bytes, re_bytes, + "round-trip mismatch for EntityKind variant" + ); + } +} diff --git a/server/tests/smoke.rs b/server/tests/smoke.rs index d3504457e..9420d4216 100644 --- a/server/tests/smoke.rs +++ b/server/tests/smoke.rs @@ -1,8 +1,8 @@ //! Smoke test: the simulation world boots and can run a single tick. use bevy_app::prelude::*; -use settled_reach_server::simulation::SimulationPlugin; use settled_reach_server::simulation::time::SimulationTime; +use settled_reach_server::simulation::SimulationPlugin; #[test] fn world_boots_and_ticks() {