Integrate independent signed Windows clocks with native Linux lease guards
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -17,6 +17,48 @@ struct Clock {
|
||||
now: DateTime<Utc>,
|
||||
trusted: bool,
|
||||
}
|
||||
#[test]
|
||||
fn client_lease_requires_entire_fresh_upper_before_deadline() {
|
||||
struct IntervalClock {
|
||||
wall: DateTime<Utc>,
|
||||
upper: DateTime<Utc>,
|
||||
}
|
||||
impl SyncClock for IntervalClock {
|
||||
fn now(&self) -> anyhow::Result<DateTime<Utc>> {
|
||||
Ok(self.wall)
|
||||
}
|
||||
fn reading(&self) -> anyhow::Result<ClockReading> {
|
||||
Ok(ClockReading {
|
||||
own_wall: self.wall,
|
||||
upper: self.upper,
|
||||
})
|
||||
}
|
||||
}
|
||||
let mut f = Fixture::new();
|
||||
let mut client = f.client();
|
||||
let prepared = f.prepare(&mut client);
|
||||
let decision = f.decision(&prepared, true);
|
||||
f.apply(&mut client, &decision).unwrap();
|
||||
let wall = decision.valid_until - Duration::milliseconds(10);
|
||||
assert!(client.can_start(
|
||||
&f.channel,
|
||||
false,
|
||||
&Clock {
|
||||
now: wall,
|
||||
trusted: true
|
||||
}
|
||||
));
|
||||
for overshoot in [Duration::zero(), Duration::nanoseconds(1)] {
|
||||
assert!(!client.can_start(
|
||||
&f.channel,
|
||||
false,
|
||||
&IntervalClock {
|
||||
wall,
|
||||
upper: decision.valid_until + overshoot
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
impl SyncClock for Clock {
|
||||
fn now(&self) -> anyhow::Result<DateTime<Utc>> {
|
||||
anyhow::ensure!(self.trusted, "CLOCK_UNTRUSTED");
|
||||
|
||||
Reference in New Issue
Block a user