From e73869ed18159dc1f82e222005c90b27f1936f99 Mon Sep 17 00:00:00 2001 From: Sooly Kobayashi Date: Tue, 21 Jul 2026 21:46:39 +0200 Subject: [PATCH] test(db): make replica_fence boundary assertions clock-resolution portable ReplicaFence::advance() normalizes to Postgres timestamptz resolution (timestamp_micros), but fence_starts_closed_and_opens_on_advance compared against Utc::now() (nanoseconds on Linux): verified_through() == Some(ts) mixed resolutions, and covers(ts) compared nanos ts against the micros fence so the inclusive-boundary assertion failed. Compare at the fence's resolution. Production behavior unchanged. Signed-off-by: Sooly Kobayashi --- crates/buzz-db/src/replica_fence.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/buzz-db/src/replica_fence.rs b/crates/buzz-db/src/replica_fence.rs index 03bc1c77f08..fbbdbaafd22 100644 --- a/crates/buzz-db/src/replica_fence.rs +++ b/crates/buzz-db/src/replica_fence.rs @@ -523,9 +523,20 @@ mod tests { let ts = Utc::now(); fence.advance(ts); - assert_eq!(fence.verified_through(), Some(ts)); + // advance() normalizes to Postgres timestamptz resolution (micros); + // compare at that resolution so the assertion is clock-precision + // portable (Utc::now() yields nanos on Linux, micros elsewhere). + assert_eq!( + fence.verified_through(), + DateTime::from_timestamp_micros(ts.timestamp_micros()) + ); assert!(fence.covers(ts - chrono::Duration::seconds(1))); - assert!(fence.covers(ts), "boundary is inclusive"); + // Inclusive boundary at the fence's resolution: the exact micros + // watermark is covered (raw nanos `ts` is strictly past it). + assert!( + fence.covers(DateTime::from_timestamp_micros(ts.timestamp_micros()).unwrap()), + "boundary is inclusive" + ); assert!(!fence.covers(ts + chrono::Duration::seconds(1))); fence.close();