test: address review gaps in timing and dynamic targets
This commit is contained in:
4 files changed
+211
-33
No files matched your search
@@ -1139,6 +1139,56 @@ mod tests {
|
||||
use super::*;
|
||||
use irtt_proto::{FLAG_OPEN, FLAG_REPLY};
|
||||
|
||||
#[test]
|
||||
fn timing_arithmetic_preserves_negative_samples() {
|
||||
let mono = Instant::now();
|
||||
let sent = ClientTimestamp {
|
||||
mono,
|
||||
wall: UNIX_EPOCH + Duration::from_nanos(100),
|
||||
};
|
||||
let received = ClientTimestamp {
|
||||
mono: mono + Duration::from_nanos(10),
|
||||
wall: UNIX_EPOCH + Duration::from_nanos(110),
|
||||
};
|
||||
// Processing longer than raw RTT must remain negative with either clock.
|
||||
for timestamps in [
|
||||
TimestampFields {
|
||||
recv_mono: Some(100),
|
||||
send_mono: Some(120),
|
||||
..TimestampFields::default()
|
||||
},
|
||||
TimestampFields {
|
||||
recv_wall: Some(100),
|
||||
send_wall: Some(120),
|
||||
..TimestampFields::default()
|
||||
},
|
||||
] {
|
||||
let rtt = compute_rtt(&sent, &received, ×tamps);
|
||||
assert_eq!(rtt.raw, Duration::from_nanos(10));
|
||||
assert_eq!(rtt.adjusted.unwrap().as_nanos(), -10);
|
||||
assert_eq!(rtt.effective.as_nanos(), -10);
|
||||
}
|
||||
// A server clock behind or ahead can make either direction negative.
|
||||
for (recv_wall, send_wall, upstream, downstream) in [(90, 95, -10, 15), (115, 120, 15, -10)]
|
||||
{
|
||||
let sample = compute_one_way(
|
||||
&sent,
|
||||
sent.wall,
|
||||
&received,
|
||||
None,
|
||||
&ReceiveMeta::default(),
|
||||
&TimestampFields {
|
||||
recv_wall: Some(recv_wall),
|
||||
send_wall: Some(send_wall),
|
||||
..TimestampFields::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(sample.client_to_server.unwrap().as_nanos(), upstream);
|
||||
assert_eq!(sample.server_to_client.unwrap().as_nanos(), downstream);
|
||||
}
|
||||
}
|
||||
|
||||
fn opened() -> SessionMachine {
|
||||
let mut machine = SessionMachine::new(
|
||||
ClientConfig {
|
||||
|
||||
Reference in new issue
Block a user