test(client): update test helpers to handle fallible packet length calculations
This commit is contained in:
9 files changed
+35
-8
No files matched your search
@@ -1,8 +1,8 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::config::{NegotiationPolicy, DEFAULT_OPEN_TIMEOUTS};
|
use crate::config::{NegotiationPolicy, DEFAULT_OPEN_TIMEOUTS};
|
||||||
use irtt_proto::{
|
use irtt_proto::{
|
||||||
echo_packet_len, flags::FLAG_HMAC, flags::FLAG_OPEN, flags::FLAG_REPLY, verify_hmac, Clock,
|
flags::FLAG_HMAC, flags::FLAG_OPEN, flags::FLAG_REPLY, verify_hmac, Clock, ReceivedStats,
|
||||||
ReceivedStats, StampAt, HMAC_SIZE, MAGIC,
|
StampAt, HMAC_SIZE, MAGIC,
|
||||||
};
|
};
|
||||||
use std::{thread, time::SystemTime};
|
use std::{thread, time::SystemTime};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
use support::echo_packet_len;
|
||||||
|
|
||||||
#[cfg(not(all(target_os = "linux", feature = "ancillary")))]
|
#[cfg(not(all(target_os = "linux", feature = "ancillary")))]
|
||||||
fn assert_packet_meta_unavailable(packet_meta: &crate::event::PacketMeta) {
|
fn assert_packet_meta_unavailable(packet_meta: &crate::event::PacketMeta) {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use irtt_proto::{
|
use irtt_proto::{
|
||||||
compute_hmac_in_place, echo_packet_len, flags::FLAG_HMAC, flags::FLAG_OPEN, flags::FLAG_REPLY,
|
compute_hmac_in_place, echo_packet_len as checked_echo_packet_len, flags::FLAG_HMAC,
|
||||||
layout::PacketLayout, Clock, ReceivedStats, StampAt, HMAC_SIZE, MAGIC,
|
flags::FLAG_OPEN, flags::FLAG_REPLY, layout::PacketLayout, Clock, ReceivedStats, StampAt,
|
||||||
|
HMAC_SIZE, MAGIC,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
net::UdpSocket,
|
net::UdpSocket,
|
||||||
@@ -74,6 +75,11 @@ pub(super) fn open_reply(
|
|||||||
packet
|
packet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn echo_packet_len(hmac: bool, params: &Params) -> usize {
|
||||||
|
checked_echo_packet_len(hmac, params)
|
||||||
|
.expect("test params must have a non-negative packet length")
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn echo_reply_packet(
|
pub(super) fn echo_reply_packet(
|
||||||
token: u64,
|
token: u64,
|
||||||
seq: u32,
|
seq: u32,
|
||||||
|
|||||||
@@ -311,8 +311,10 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::{config::NegotiationPolicy, SubscriberOverflow};
|
use crate::{config::NegotiationPolicy, SubscriberOverflow};
|
||||||
use irtt_proto::{
|
use irtt_proto::{
|
||||||
echo_packet_len, flags, flags::FLAG_OPEN, flags::FLAG_REPLY, layout::PacketLayout, Clock,
|
echo_packet_len,
|
||||||
Params, ReceivedStats, StampAt, TimestampFields, MAGIC, PROTOCOL_VERSION,
|
flags::{self, FLAG_OPEN, FLAG_REPLY},
|
||||||
|
layout::PacketLayout,
|
||||||
|
Clock, Params, ReceivedStats, StampAt, TimestampFields, MAGIC, PROTOCOL_VERSION,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
net::{SocketAddr, UdpSocket},
|
net::{SocketAddr, UdpSocket},
|
||||||
@@ -331,6 +333,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_echo_packet_len(hmac: bool, params: &Params) -> usize {
|
||||||
|
echo_packet_len(hmac, params)
|
||||||
|
.expect("managed runner test params must have a non-negative packet length")
|
||||||
|
}
|
||||||
|
|
||||||
fn test_params(duration: Option<Duration>, interval: Duration) -> Params {
|
fn test_params(duration: Option<Duration>, interval: Duration) -> Params {
|
||||||
Params {
|
Params {
|
||||||
protocol_version: PROTOCOL_VERSION,
|
protocol_version: PROTOCOL_VERSION,
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ use support::{
|
|||||||
start_hmac_required_open_drop_server, BackendPeer, ServerObservation, TOKEN,
|
start_hmac_required_open_drop_server, BackendPeer, ServerObservation, TOKEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::support::test_echo_packet_len;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hmac_open_success_negotiates_without_warnings() {
|
fn hmac_open_success_negotiates_without_warnings() {
|
||||||
let key = b"compat-secret".to_vec();
|
let key = b"compat-secret".to_vec();
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
mod support;
|
mod support;
|
||||||
|
|
||||||
use irtt_client::{Client, ClientConfig, ClientEvent, NegotiationPolicy};
|
use irtt_client::{Client, ClientConfig, ClientEvent, NegotiationPolicy};
|
||||||
use irtt_proto::{echo_header_len, echo_packet_len, Params, TimestampFields};
|
use irtt_proto::{echo_header_len, Params, TimestampFields};
|
||||||
|
|
||||||
use support::{config_for_params, default_params, run_one_probe, BackendPeer, ServerObservation};
|
use support::{config_for_params, default_params, run_one_probe, BackendPeer, ServerObservation};
|
||||||
|
|
||||||
|
use crate::support::test_echo_packet_len;
|
||||||
|
|
||||||
fn params_with_length(length: i64) -> Params {
|
fn params_with_length(length: i64) -> Params {
|
||||||
Params {
|
Params {
|
||||||
length,
|
length,
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ use support::{
|
|||||||
ServerObservation, RECV_COUNT, RECV_WINDOW, TOKEN,
|
ServerObservation, RECV_COUNT, RECV_WINDOW, TOKEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::support::test_echo_packet_len;
|
||||||
|
|
||||||
struct ReplyView<'a> {
|
struct ReplyView<'a> {
|
||||||
seq: u32,
|
seq: u32,
|
||||||
rtt: &'a RttSample,
|
rtt: &'a RttSample,
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
mod support;
|
mod support;
|
||||||
|
|
||||||
use irtt_client::{Client, ClientConfig, ClientError, ClientEvent, NegotiationPolicy};
|
use irtt_client::{Client, ClientConfig, ClientError, ClientEvent, NegotiationPolicy};
|
||||||
use irtt_proto::{echo_packet_len, Params, TimestampFields};
|
use irtt_proto::{Params, TimestampFields};
|
||||||
|
|
||||||
use support::{
|
use support::{
|
||||||
config_for_params, default_params, run_one_probe, run_one_probe_with_config, server_fill,
|
config_for_params, default_params, run_one_probe, run_one_probe_with_config, server_fill,
|
||||||
start_open_server, OneProbeRun, ServerObservation,
|
start_open_server, OneProbeRun, ServerObservation,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::support::test_echo_packet_len;
|
||||||
|
|
||||||
fn open_observation_params(run: &OneProbeRun) -> &Params {
|
fn open_observation_params(run: &OneProbeRun) -> &Params {
|
||||||
match &run.observations[0] {
|
match &run.observations[0] {
|
||||||
ServerObservation::Open { params, .. } => params,
|
ServerObservation::Open { params, .. } => params,
|
||||||
|
|||||||
@@ -520,6 +520,11 @@ fn open_reply(flags: u8, token: u64, params: &Params, hmac_key: Option<&[u8]>) -
|
|||||||
packet
|
packet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn test_echo_packet_len(hmac: bool, params: &Params) -> usize {
|
||||||
|
echo_packet_len(hmac, params)
|
||||||
|
.expect("managed runner test params must have a non-negative packet length")
|
||||||
|
}
|
||||||
|
|
||||||
fn echo_reply_packet(
|
fn echo_reply_packet(
|
||||||
token: u64,
|
token: u64,
|
||||||
seq: u32,
|
seq: u32,
|
||||||
|
|||||||
Reference in new issue
Block a user