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 crate::config::{NegotiationPolicy, DEFAULT_OPEN_TIMEOUTS};
|
||||
use irtt_proto::{
|
||||
echo_packet_len, flags::FLAG_HMAC, flags::FLAG_OPEN, flags::FLAG_REPLY, verify_hmac, Clock,
|
||||
ReceivedStats, StampAt, HMAC_SIZE, MAGIC,
|
||||
flags::FLAG_HMAC, flags::FLAG_OPEN, flags::FLAG_REPLY, verify_hmac, Clock, ReceivedStats,
|
||||
StampAt, HMAC_SIZE, MAGIC,
|
||||
};
|
||||
use std::{thread, time::SystemTime};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use support::echo_packet_len;
|
||||
|
||||
#[cfg(not(all(target_os = "linux", feature = "ancillary")))]
|
||||
fn assert_packet_meta_unavailable(packet_meta: &crate::event::PacketMeta) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use super::*;
|
||||
use irtt_proto::{
|
||||
compute_hmac_in_place, echo_packet_len, flags::FLAG_HMAC, flags::FLAG_OPEN, flags::FLAG_REPLY,
|
||||
layout::PacketLayout, Clock, ReceivedStats, StampAt, HMAC_SIZE, MAGIC,
|
||||
compute_hmac_in_place, echo_packet_len as checked_echo_packet_len, flags::FLAG_HMAC,
|
||||
flags::FLAG_OPEN, flags::FLAG_REPLY, layout::PacketLayout, Clock, ReceivedStats, StampAt,
|
||||
HMAC_SIZE, MAGIC,
|
||||
};
|
||||
use std::{
|
||||
net::UdpSocket,
|
||||
@@ -74,6 +75,11 @@ pub(super) fn open_reply(
|
||||
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(
|
||||
token: u64,
|
||||
seq: u32,
|
||||
|
||||
@@ -311,8 +311,10 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::{config::NegotiationPolicy, SubscriberOverflow};
|
||||
use irtt_proto::{
|
||||
echo_packet_len, flags, flags::FLAG_OPEN, flags::FLAG_REPLY, layout::PacketLayout, Clock,
|
||||
Params, ReceivedStats, StampAt, TimestampFields, MAGIC, PROTOCOL_VERSION,
|
||||
echo_packet_len,
|
||||
flags::{self, FLAG_OPEN, FLAG_REPLY},
|
||||
layout::PacketLayout,
|
||||
Clock, Params, ReceivedStats, StampAt, TimestampFields, MAGIC, PROTOCOL_VERSION,
|
||||
};
|
||||
use std::{
|
||||
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 {
|
||||
Params {
|
||||
protocol_version: PROTOCOL_VERSION,
|
||||
|
||||
Reference in new issue
Block a user