mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-10-21 00:00:50 +00:00
test: make secure datagram grace expiry deterministic (#2723)
The expiry test sampled time before sync_root_key established its grace period. Scheduling delays over 3 ms could leave the asserted timestamp inside the grace window and fail the test. Use the actual grace deadline to check acceptance just before expiry and rejection at expiry. Use a fresh sequence number for the rejection check so replay detection cannot hide a broken expiry boundary.
This commit is contained in:
@@ -1011,14 +1011,12 @@ mod tests {
|
||||
assert!(s.check_replay_for_test(1, 0, SecureDatagramDirection::AToB, now + 1));
|
||||
|
||||
s.sync_root_key(root_key, 2, 2, true);
|
||||
assert!(s.check_replay_for_test(2, 0, SecureDatagramDirection::AToB, now + 2));
|
||||
// Use the actual deadline so scheduling delays before sync do not affect the test.
|
||||
let expires_at_ms = s.sync_rx_grace_expires_at_ms.load(Ordering::Relaxed);
|
||||
assert!(s.check_replay_for_test(2, 0, SecureDatagramDirection::AToB, expires_at_ms - 1));
|
||||
assert!(s.check_replay_for_test(0, 1, SecureDatagramDirection::AToB, expires_at_ms - 1));
|
||||
|
||||
assert!(!s.check_replay_for_test(
|
||||
0,
|
||||
1,
|
||||
SecureDatagramDirection::AToB,
|
||||
now + SecureDatagramSession::SYNC_RX_GRACE_AFTER_MS + 3
|
||||
));
|
||||
assert!(!s.check_replay_for_test(0, 2, SecureDatagramDirection::AToB, expires_at_ms));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user