diff --git a/crates/idunn-daemon/src/main.rs b/crates/idunn-daemon/src/main.rs index d461018..58e6f29 100644 --- a/crates/idunn-daemon/src/main.rs +++ b/crates/idunn-daemon/src/main.rs @@ -3694,7 +3694,7 @@ fn run_rudp_health_ingress_loop( loop { match socket.recv_from(&mut buffer) { Ok((size, source)) => { - let observed_at = timestamp()?; + let observed_at = timestamp_with_millis(); if trace_ingress { println!("Idunn RUDP health ingress received {size} bytes from {source}."); } @@ -7034,6 +7034,10 @@ fn timestamp() -> Result { Ok(format!("unix:{seconds}")) } +fn timestamp_with_millis() -> String { + chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true) +} + fn unix_epoch_millis() -> Result { let millis = SystemTime::now() .duration_since(UNIX_EPOCH) @@ -7050,6 +7054,16 @@ fn help_text() -> &'static str { mod tests { use super::*; + #[test] + fn rudp_admission_timestamp_preserves_millisecond_precision() { + let before = unix_epoch_millis().unwrap(); + let timestamp = timestamp_with_millis(); + let parsed = parse_timestamp_millis(×tamp).unwrap(); + let after = unix_epoch_millis().unwrap(); + assert!(timestamp.contains('.')); + assert!(parsed >= before && parsed <= after); + } + #[test] fn target_actuation_gate_serializes_request_owners() { let gate = Arc::new(TargetActuationGate::new());