extern crate alloc;
use crate::kairos::{Clock, Kairos, TickCounter, VirtualTimeSource};
#[test]
fn test_observe_advances_clock_without_minting() {
let clock = Clock::with_default_config(TickCounter::new(), 1).unwrap();
let first = clock.now(0u16); let remote = Kairos::new(100, 7, 2, 10u16);
clock.observe(remote);
assert_eq!(
clock.stats().max_forward_skew_ns,
99,
"observe pulls the clock forward to the remote's physical time"
);
let next = clock.now(0u16);
assert!(
next > remote,
"a mint after observe exceeds the observed remote"
);
assert!(next > first);
assert_eq!(
next.physical(),
100,
"physical jumped to the observed remote"
);
assert_eq!(
next.station_id(),
1,
"observe carries no identity; the mint is local"
);
}
#[test]
fn test_observe_of_dominated_remote_still_advances() {
let clock = Clock::with_default_config(VirtualTimeSource::new(0), 1).unwrap();
let a = clock.now(0u16); clock.observe(Kairos::new(0, 0, 2, 0u16)); let b = clock.now(0u16); assert!(b > a);
assert_eq!(
b.logical(),
2,
"observe consumed a logical tick, so the next mint is two on, not one"
);
}