test: cover timing, overflow, and target authentication contracts

This commit is contained in:
Nils Andreas Svee committed 2026-10-03 13:47:09 +07:00
1 parent 56fe86f543
commit f2c2153cc0
4 files changed
+150 -3

No files matched your search

@@ -1,5 +1,45 @@
use super::*;
#[test]
fn probe_timeout_overflow_transmits_no_echo() {
let params = default_params();
let server = start_fake_server(move |socket, tx| {
socket
.set_read_timeout(Some(Duration::from_secs(2)))
.unwrap();
let (_, peer) = recv_request(&socket, &tx);
socket
.send_to(
&open_reply(FLAG_OPEN | FLAG_REPLY, TOKEN, &params, None),
peer,
)
.unwrap();
// CLOSE is a completion barrier: any incorrectly transmitted ECHO
// precedes it on this connected loopback socket.
let _ = recv_request(&socket, &tx);
});
let config = ClientConfig {
probe_timeout: Duration::MAX,
..default_test_config(server.addr)
};
let mut client = Client::connect(config).unwrap();
assert_open_started(client.open().unwrap());
assert!(matches!(
client.send_probe(),
Err(ClientError::DurationOverflow)
));
assert!(!client.has_pending_probes());
client.close().unwrap();
let packets: Vec<_> = server.rx.iter().collect();
assert_eq!(packets.len(), 2);
assert_eq!(
packets[1][3],
flags::FLAG_CLOSE,
"overflow must not transmit an ECHO"
);
server.join();
}
#[test]
fn poll_timeouts_emits_echo_loss() {
let params = default_params();
+8 -3
View File
@@ -132,9 +132,14 @@ fn assert_kernel_send_endpoint(event: &ClientEvent, before_send: SystemTime) {
"TX timestamp was not observed; userspace fallback is insufficient"
);
assert!(selected <= ns(received_at.wall));
assert!(
packet_meta.kernel_rx_timestamp.is_some(),
"Linux RX timestamp required"
let selected_receive =
i128::from(timing.send_wall_ns.unwrap()) + one_way.server_to_client.unwrap().as_nanos();
assert_eq!(
selected_receive,
ns(packet_meta
.kernel_rx_timestamp
.expect("Linux RX timestamp required")),
"downstream OWD must use the kernel receive endpoint"
);
assert_eq!(rtt.raw, received_at.mono.duration_since(sent_at.mono));
}