Review fixes: deduplicate dump_schedule_graph doc comment, add rng_seed round-trip test and v9→v10 backward compat test. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -184,9 +184,6 @@ fn main() {
|
|||||||
tracing::info!("Simulation server shutting down");
|
tracing::info!("Simulation server shutting down");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Print bevy_ecs schedule graph and exit.
|
|
||||||
/// Invoked by --dump-schedule CLI flag (#346).
|
|
||||||
///
|
|
||||||
/// Print bevy_ecs schedule graph and exit.
|
/// Print bevy_ecs schedule graph and exit.
|
||||||
/// Invoked by --dump-schedule CLI flag (#346).
|
/// Invoked by --dump-schedule CLI flag (#346).
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1187,6 +1187,80 @@ fn v8_payload_deserializes_into_v9_struct() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// rng_seed round-trips through MessagePack (#527).
|
||||||
|
/// Verifies Some(seed) survives the wire and None is omitted.
|
||||||
|
#[test]
|
||||||
|
fn rng_seed_roundtrip() {
|
||||||
|
let mut snapshot = test_snapshot(0, vec![]);
|
||||||
|
snapshot.rng_seed = Some(123456789);
|
||||||
|
let bytes = rmp_serde::to_vec_named(&snapshot).expect("serialize");
|
||||||
|
let decoded: ObserverSnapshot = rmp_serde::from_slice(&bytes).expect("deserialize");
|
||||||
|
assert_eq!(decoded.rng_seed, Some(123456789));
|
||||||
|
|
||||||
|
// None case: skip_serializing_if omits the field, default restores it
|
||||||
|
let mut snapshot_none = test_snapshot(0, vec![]);
|
||||||
|
snapshot_none.rng_seed = None;
|
||||||
|
let bytes_none = rmp_serde::to_vec_named(&snapshot_none).expect("serialize");
|
||||||
|
let decoded_none: ObserverSnapshot = rmp_serde::from_slice(&bytes_none).expect("deserialize");
|
||||||
|
assert_eq!(decoded_none.rng_seed, None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// v9 payloads (without rng_seed) must deserialize into the v10 struct
|
||||||
|
/// via #[serde(default)]. Guards backwards compat during migration (#527).
|
||||||
|
#[test]
|
||||||
|
fn v9_payload_deserializes_into_v10_struct() {
|
||||||
|
#[derive(serde::Serialize)]
|
||||||
|
struct ObserverSnapshotV9 {
|
||||||
|
version: u8,
|
||||||
|
tick: u64,
|
||||||
|
game_time: GameTime,
|
||||||
|
player_facing: FacingDirection,
|
||||||
|
player_stance: MovementStance,
|
||||||
|
player_inventory: Vec<InventoryItem>,
|
||||||
|
entities: Vec<VisibleEntity>,
|
||||||
|
visible_tiles: Vec<VisibleTile>,
|
||||||
|
nearby_interactions: Vec<NearbyInteraction>,
|
||||||
|
current_monologue: Option<MonologueEvent>,
|
||||||
|
pending_recognitions: Vec<PendingRecognitionWire>,
|
||||||
|
dialogue_response: Option<DialogueResponseEvent>,
|
||||||
|
blocked_entities: Vec<u64>,
|
||||||
|
scan_events: Vec<settled_reach_server::simulation::contraband::ScanEvent>,
|
||||||
|
}
|
||||||
|
|
||||||
|
let v9 = ObserverSnapshotV9 {
|
||||||
|
version: 9,
|
||||||
|
tick: 200,
|
||||||
|
game_time: GameTime {
|
||||||
|
day: 0,
|
||||||
|
time_of_day: 0,
|
||||||
|
day_phase: DayPhase::Morning,
|
||||||
|
tick_rate: TickRate::Full,
|
||||||
|
},
|
||||||
|
player_facing: FacingDirection::North,
|
||||||
|
player_stance: MovementStance::Walk,
|
||||||
|
player_inventory: vec![],
|
||||||
|
entities: vec![],
|
||||||
|
visible_tiles: vec![],
|
||||||
|
nearby_interactions: vec![],
|
||||||
|
current_monologue: None,
|
||||||
|
pending_recognitions: vec![],
|
||||||
|
dialogue_response: None,
|
||||||
|
blocked_entities: vec![],
|
||||||
|
scan_events: vec![],
|
||||||
|
};
|
||||||
|
|
||||||
|
let bytes = rmp_serde::to_vec_named(&v9).expect("serialize v9");
|
||||||
|
let decoded: ObserverSnapshot = rmp_serde::from_slice(&bytes)
|
||||||
|
.expect("v9 payload should deserialize into v10 struct via serde(default)");
|
||||||
|
|
||||||
|
assert_eq!(decoded.version, 9, "version field preserved from v9");
|
||||||
|
assert_eq!(decoded.tick, 200);
|
||||||
|
assert_eq!(
|
||||||
|
decoded.rng_seed, None,
|
||||||
|
"missing rng_seed should default to None"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// NearbyInteraction.object_type round-trips through MessagePack (#422).
|
/// NearbyInteraction.object_type round-trips through MessagePack (#422).
|
||||||
/// Verifies object_type=Some(Container) survives the wire.
|
/// Verifies object_type=Some(Container) survives the wire.
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user