test(client): use fallible packet length helpers in integration tests

This commit is contained in:
Nils Andreas Svee committed 2026-05-12 13:05:45 +07:00
1 parent 4549d95d0a
commit a7e10358fd
6 files changed
+20 -20

No files matched your search

+3 -3
View File
@@ -5,7 +5,7 @@ use std::time::Duration;
use irtt_client::{
Client, ClientConfig, ClientError, ClientEvent, OpenOutcome, SocketConfig, WarningKind,
};
use irtt_proto::{echo_packet_len, ProtoError, TimestampFields};
use irtt_proto::{ProtoError, TimestampFields};
use support::{
config_for_params, default_params, params_for_modes, run_one_probe_with_config,
@@ -64,7 +64,7 @@ fn hmac_echo_success_verifies_request_and_accepts_reply() {
token,
sequence,
} => {
assert_eq!(*len, echo_packet_len(true, &params));
assert_eq!(*len, test_echo_packet_len(true, &params));
assert!(*hmac);
assert_eq!(*token, TOKEN);
assert_eq!(*sequence, 0);
@@ -80,7 +80,7 @@ fn hmac_echo_success_verifies_request_and_accepts_reply() {
..
} => {
assert_eq!(*seq, 0);
assert_eq!(*bytes, echo_packet_len(true, &params));
assert_eq!(*bytes, test_echo_packet_len(true, &params));
assert!(server_timing.is_some());
}
other => panic!("expected EchoReply, got {other:?}"),
+8 -8
View File
@@ -44,7 +44,7 @@ fn assert_reply_bytes(event: &ClientEvent, expected: usize) {
#[test]
fn length_zero_baseline() {
let params = params_with_length(0);
let expected = echo_packet_len(false, &params);
let expected = test_echo_packet_len(false, &params);
let header = echo_header_len(false, &params);
assert_eq!(expected, header);
}
@@ -52,21 +52,21 @@ fn length_zero_baseline() {
#[test]
fn length_one_accepted() {
let params = params_with_length(1);
let expected = echo_packet_len(false, &params);
let expected = test_echo_packet_len(false, &params);
assert!(expected >= 1);
}
#[test]
fn length_1472_accepted() {
let params = params_with_length(1472);
let expected = echo_packet_len(false, &params);
let expected = test_echo_packet_len(false, &params);
assert_eq!(expected, 1472);
}
#[test]
fn length_4096_accepted() {
let params = params_with_length(4096);
let expected = echo_packet_len(false, &params);
let expected = test_echo_packet_len(false, &params);
assert_eq!(expected, 4096);
}
@@ -76,7 +76,7 @@ fn length_4096_accepted() {
fn echo_request_size_matches_echo_packet_len_for_zero_length() {
let params = params_with_length(0);
let run = run_one_probe(params.clone(), TimestampFields::default());
let expected = echo_packet_len(false, &params);
let expected = test_echo_packet_len(false, &params);
assert_echo_size(&run, expected);
assert_sent_bytes(&run.sent, expected);
}
@@ -86,7 +86,7 @@ fn echo_request_size_matches_echo_packet_len_above_header() {
for length in [16, 60, 128, 1472, 4096] {
let params = params_with_length(length);
let run = run_one_probe(params.clone(), TimestampFields::default());
let expected = echo_packet_len(false, &params);
let expected = test_echo_packet_len(false, &params);
assert_eq!(
expected,
echo_header_len(false, &params).max(length as usize)
@@ -102,7 +102,7 @@ fn echo_request_size_matches_echo_packet_len_above_header() {
fn echo_reply_decoded_for_large_length() {
let params = params_with_length(4096);
let run = run_one_probe(params.clone(), TimestampFields::default());
let expected = echo_packet_len(false, &params);
let expected = test_echo_packet_len(false, &params);
assert_reply(&run.reply);
assert_reply_bytes(&run.reply, expected);
}
@@ -112,7 +112,7 @@ fn echo_reply_bytes_consistent_with_echo_packet_len_for_various_lengths() {
for length in [0, 1472, 4096] {
let params = params_with_length(length);
let run = run_one_probe(params.clone(), TimestampFields::default());
let expected = echo_packet_len(false, &params);
let expected = test_echo_packet_len(false, &params);
assert_reply_bytes(&run.reply, expected);
}
}
+5 -5
View File
@@ -6,7 +6,7 @@ use irtt_client::{
Client, ClientConfig, ClientError, ClientEvent, OneWayDelaySample, ReceivedStatsSample,
RttSample, ServerTiming,
};
use irtt_proto::{echo_packet_len, Clock, Params, ReceivedStats, StampAt, TimestampFields};
use irtt_proto::{Clock, Params, ReceivedStats, StampAt, TimestampFields};
use support::{
config_for_params, default_params, params_for_modes, run_one_probe, run_one_probe_with_config,
@@ -39,7 +39,7 @@ fn received_stats_modes_drive_negotiated_echo_and_reply_events() {
let reply = expect_echo_reply(&run.reply);
assert_eq!(reply.seq, 0);
assert_eq!(reply.bytes, echo_packet_len(false, &params));
assert_eq!(reply.bytes, test_echo_packet_len(false, &params));
assert!(reply.server_timing.is_none());
assert!(reply.one_way.is_none());
assert_received_stats(reply.received_stats, expected_count, expected_window);
@@ -148,7 +148,7 @@ fn hmac_rich_mode_uses_negotiated_echo_layout_and_decodes_reply() {
assert_negotiated_echo_use(&run, &params, true);
let reply = expect_echo_reply(&run.reply);
assert_eq!(reply.bytes, echo_packet_len(true, &params));
assert_eq!(reply.bytes, test_echo_packet_len(true, &params));
assert_received_stats(reply.received_stats, Some(RECV_COUNT), Some(RECV_WINDOW));
assert_timing_fields(reply.server_timing, true, true, false, false, true, true);
}
@@ -245,7 +245,7 @@ fn assert_negotiated_echo_use(run: &OneProbeRun, params: &Params, hmac: bool) {
fn assert_echo_uses_params(run: &OneProbeRun, params: &Params, hmac: bool) {
let (echo_len, echo_hmac, token, sequence) = echo_observation(run);
assert_eq!(echo_len, echo_packet_len(hmac, params));
assert_eq!(echo_len, test_echo_packet_len(hmac, params));
assert_eq!(echo_hmac, hmac);
assert_eq!(token, TOKEN);
assert_eq!(sequence, 0);
@@ -253,7 +253,7 @@ fn assert_echo_uses_params(run: &OneProbeRun, params: &Params, hmac: bool) {
match &run.sent {
ClientEvent::EchoSent { seq, bytes, .. } => {
assert_eq!(*seq, 0);
assert_eq!(*bytes, echo_packet_len(hmac, params));
assert_eq!(*bytes, test_echo_packet_len(hmac, params));
}
other => panic!("expected EchoSent, got {other:?}"),
}
+2 -2
View File
@@ -204,11 +204,11 @@ fn server_fill_does_not_affect_client_side_packet_layout() {
let (echo_len_without, _, _, _) = echo_observation(&run_without);
assert_eq!(echo_len_with, echo_len_without);
assert_eq!(
echo_packet_len(false, &run_with.negotiated.params),
test_echo_packet_len(false, &run_with.negotiated.params),
echo_len_with
);
assert_eq!(
echo_packet_len(false, &run_without.negotiated.params),
test_echo_packet_len(false, &run_without.negotiated.params),
echo_len_without
);
}
+1 -1
View File
@@ -534,7 +534,7 @@ fn echo_reply_packet(
) -> Vec<u8> {
let has_hmac = hmac_key.is_some();
let layout = irtt_proto::PacketLayout::echo(has_hmac, params);
let packet_len = echo_packet_len(has_hmac, params);
let packet_len = test_echo_packet_len(has_hmac, params);
let mut packet = Vec::with_capacity(packet_len);
packet.extend_from_slice(&MAGIC);