refactor(simulation): apply rustfmt formatting

Formatting-only changes across server source and test files.
No logic changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-18 01:39:44 +01:00
co-authored by Claude Opus 4.6
parent 1da81a21ea
commit d5a1f6dadb
16 changed files with 169 additions and 105 deletions
+8 -2
View File
@@ -86,7 +86,10 @@ fn input_roundtrip_over_tcp() {
match bridge.receive_inputs() {
Ok(inputs) if !inputs.is_empty() => break inputs,
Ok(_) => {
assert!(std::time::Instant::now() < deadline, "timed out waiting for inputs");
assert!(
std::time::Instant::now() < deadline,
"timed out waiting for inputs"
);
thread::sleep(std::time::Duration::from_millis(1));
}
Err(e) => panic!("failed to receive inputs: {}", e),
@@ -150,7 +153,10 @@ fn tcp_bridge_eof_returns_error() {
match bridge.receive_inputs() {
Ok(inputs) if inputs.is_empty() => {
// WouldBlock — client hasn't disconnected yet, retry
assert!(std::time::Instant::now() < deadline, "timed out waiting for EOF");
assert!(
std::time::Instant::now() < deadline,
"timed out waiting for EOF"
);
thread::sleep(std::time::Duration::from_millis(1));
}
Ok(inputs) => panic!("expected Disconnected error, got {} inputs", inputs.len()),
+5 -7
View File
@@ -16,8 +16,8 @@ use settled_reach_server::knowledge::registry::EntityRegistry;
use settled_reach_server::knowledge::{KnowledgeGraph, KnowledgePlugin};
use settled_reach_server::npc::relationships::{RelationshipEdge, RelationshipGraph};
use settled_reach_server::npc::{
Contentment, DailyRoutine, Npc, NpcPlugin, RelationshipKind, RoutineEntry,
ToleranceThreshold, Want, WantKind,
Contentment, DailyRoutine, Npc, NpcPlugin, RelationshipKind, RoutineEntry, ToleranceThreshold,
Want, WantKind,
};
use settled_reach_server::perception::cognitive_delay::CognitiveDelay;
use settled_reach_server::perception::vision_cone::Facing;
@@ -213,10 +213,7 @@ fn build_deterministic_app(seed: u64) -> App {
/// Run the simulation for a fixed number of ticks with predetermined inputs.
/// Returns serialized snapshots for each tick.
fn run_simulation(
seed: u64,
inputs: &[Vec<PlayerInput>],
) -> Vec<Vec<u8>> {
fn run_simulation(seed: u64, inputs: &[Vec<PlayerInput>]) -> Vec<Vec<u8>> {
let mut app = build_deterministic_app(seed);
let mut snapshots = Vec::with_capacity(inputs.len());
@@ -334,7 +331,8 @@ fn gauntlet_deterministic_replay() {
for (tick, (s1, s2)) in run1.iter().zip(run2.iter()).enumerate() {
assert_eq!(
s1, s2,
s1,
s2,
"snapshot at tick {} differs between runs ({} vs {} bytes)",
tick,
s1.len(),
+4 -4
View File
@@ -279,11 +279,11 @@ fn generate_msgpack_fixtures() {
// Tests that GDScript can decode full ObserverSnapshot structs when the tick
// field crosses encoding format boundaries.
let boundary_snapshots: [(u64, &str); 5] = [
(0, "snapshot_boundary_tick_0"), // pos fixint
(127, "snapshot_boundary_tick_127"), // pos fixint max
(32767, "snapshot_boundary_tick_32767"), // int16/uint16 asymmetry
(0, "snapshot_boundary_tick_0"), // pos fixint
(127, "snapshot_boundary_tick_127"), // pos fixint max
(32767, "snapshot_boundary_tick_32767"), // int16/uint16 asymmetry
(2147483647, "snapshot_boundary_tick_2b31m1"), // int32/uint32 asymmetry
(4294967296, "snapshot_boundary_tick_2b32"), // int64 minimum
(4294967296, "snapshot_boundary_tick_2b32"), // int64 minimum
];
for (tick, name) in &boundary_snapshots {
+44 -14
View File
@@ -139,8 +139,9 @@ fn all_fixtures_deserialize() {
if name.starts_with("snapshot_boundary") {
// Boundary snapshot fixtures (#472): tick may exceed PROTOCOL_VERSION check
rmp_serde::from_slice::<ObserverSnapshot>(&bytes)
.unwrap_or_else(|e| panic!("deserialize boundary snapshot fixture {}: {}", name, e));
rmp_serde::from_slice::<ObserverSnapshot>(&bytes).unwrap_or_else(|e| {
panic!("deserialize boundary snapshot fixture {}: {}", name, e)
});
} else if name.starts_with("snapshot") {
let snap = rmp_serde::from_slice::<ObserverSnapshot>(&bytes)
.unwrap_or_else(|e| panic!("deserialize snapshot fixture {}: {}", name, e));
@@ -694,19 +695,48 @@ fn nearby_interaction_contradicted_roundtrip() {
/// int 32 (-32769 to -2^31), int 64 (-2^31-1 to -2^63).
const BOUNDARY_VALUES: [i64; 41] = [
// Positive boundaries (25 values)
0, 1, 126, 127, // pos fixint
128, 129, 254, 255, // uint 8
256, 257, 32766, 32767, // int 16 / uint 16 asymmetry
32768, 32769, 65534, 65535, // uint 16
65536, 65537, 2147483646, 2147483647, // int 32 / uint 32 asymmetry
2147483648, 4294967294, 4294967295, // uint 32
4294967296, i64::MAX, // int 64
0,
1,
126,
127, // pos fixint
128,
129,
254,
255, // uint 8
256,
257,
32766,
32767, // int 16 / uint 16 asymmetry
32768,
32769,
65534,
65535, // uint 16
65536,
65537,
2147483646,
2147483647, // int 32 / uint 32 asymmetry
2147483648,
4294967294,
4294967295, // uint 32
4294967296,
i64::MAX, // int 64
// Negative boundaries (16 values)
-1, -31, -32, // neg fixint
-33, -34, -127, -128, // int 8
-129, -130, -32767, -32768, // int 16
-32769, -2147483647, -2147483648, // int 32
-2147483649, i64::MIN, // int 64
-1,
-31,
-32, // neg fixint
-33,
-34,
-127,
-128, // int 8
-129,
-130,
-32767,
-32768, // int 16
-32769,
-2147483647,
-2147483648, // int 32
-2147483649,
i64::MIN, // int 64
];
#[test]