test(client): use fallible packet length helpers in integration tests
This commit is contained in:
6 files changed
+20
-20
No files matched your search
@@ -468,7 +468,7 @@ mod tests {
|
||||
timestamps: &TimestampFields,
|
||||
) -> Vec<u8> {
|
||||
let layout = PacketLayout::echo(false, params);
|
||||
let packet_len = echo_packet_len(false, params);
|
||||
let packet_len = test_echo_packet_len(false, params);
|
||||
let mut packet = Vec::with_capacity(packet_len);
|
||||
|
||||
packet.extend_from_slice(&MAGIC);
|
||||
|
||||
@@ -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, ¶ms));
|
||||
assert_eq!(*len, test_echo_packet_len(true, ¶ms));
|
||||
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, ¶ms));
|
||||
assert_eq!(*bytes, test_echo_packet_len(true, ¶ms));
|
||||
assert!(server_timing.is_some());
|
||||
}
|
||||
other => panic!("expected EchoReply, got {other:?}"),
|
||||
|
||||
@@ -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, ¶ms);
|
||||
let expected = test_echo_packet_len(false, ¶ms);
|
||||
let header = echo_header_len(false, ¶ms);
|
||||
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, ¶ms);
|
||||
let expected = test_echo_packet_len(false, ¶ms);
|
||||
assert!(expected >= 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn length_1472_accepted() {
|
||||
let params = params_with_length(1472);
|
||||
let expected = echo_packet_len(false, ¶ms);
|
||||
let expected = test_echo_packet_len(false, ¶ms);
|
||||
assert_eq!(expected, 1472);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn length_4096_accepted() {
|
||||
let params = params_with_length(4096);
|
||||
let expected = echo_packet_len(false, ¶ms);
|
||||
let expected = test_echo_packet_len(false, ¶ms);
|
||||
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, ¶ms);
|
||||
let expected = test_echo_packet_len(false, ¶ms);
|
||||
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, ¶ms);
|
||||
let expected = test_echo_packet_len(false, ¶ms);
|
||||
assert_eq!(
|
||||
expected,
|
||||
echo_header_len(false, ¶ms).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, ¶ms);
|
||||
let expected = test_echo_packet_len(false, ¶ms);
|
||||
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, ¶ms);
|
||||
let expected = test_echo_packet_len(false, ¶ms);
|
||||
assert_reply_bytes(&run.reply, expected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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, ¶ms));
|
||||
assert_eq!(reply.bytes, test_echo_packet_len(false, ¶ms));
|
||||
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, ¶ms, true);
|
||||
|
||||
let reply = expect_echo_reply(&run.reply);
|
||||
assert_eq!(reply.bytes, echo_packet_len(true, ¶ms));
|
||||
assert_eq!(reply.bytes, test_echo_packet_len(true, ¶ms));
|
||||
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:?}"),
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user