extern crate alloc;
use crate::kairos::{Clock, Kairos, VirtualTimeSource};
#[test]
fn test_first_after_rolls_logical_ceiling() {
let clock = Clock::with_default_config(VirtualTimeSource::new(5), 1).unwrap();
let remote = Kairos::new(9, u16::MAX, 2, u16::MAX);
let minted = clock.after(remote, 0u16);
assert!(
minted > remote,
"after must dominate its input even at the remote's logical ceiling"
);
assert_eq!(minted.physical(), 10, "the ceiling rolls into physical");
assert_eq!(minted.logical(), 0, "logical restarts after the roll");
}
#[test]
fn test_physical_ceiling_reading_is_not_uninitialized() {
let clock = Clock::with_default_config(VirtualTimeSource::new(u64::MAX), 1).unwrap();
let t1 = clock.now(0u16);
let t2 = clock.now(0u16);
assert_eq!(t1.physical(), u64::MAX);
assert_eq!(t2.physical(), u64::MAX);
assert_eq!(t1.logical(), 0);
assert_eq!(
t2.logical(),
1,
"second stamp must advance logically, not reset to a fresh clock"
);
assert!(
t2 > t1,
"stamps must stay strictly monotonic at the u64 ceiling"
);
}