Rust CI / cargo fmt (push) Successful in 17s
Rust CI / cargo check (x86_64-unknown-linux-gnu) (push) Successful in 34s
Rust CI / cargo clippy (push) Successful in 35s
Rust CI / cargo check (x86_64-unknown-linux-musl) (push) Failing after 8s
Rust CI / cargo test (x86_64-unknown-linux-musl) (push) Failing after 10s
Rust CI / cargo test (x86_64-unknown-linux-gnu) (push) Successful in 1m14s
Rust CI / cargo doc (push) Successful in 23s
Fuzz Smoke / cargo fuzz smoke (push) Failing after 29s
Supply chain / cargo-deny advisories (push) Successful in 9s
Supply chain / cargo-deny bans licenses sources (push) Successful in 5s
Supply chain / actionlint (push) Successful in 3s
Netem Interop / netem interop (push) Successful in 1m11s
118 lines
3.3 KiB
Rust
118 lines
3.3 KiB
Rust
use super::*;
|
|
|
|
#[test]
|
|
fn connect_rejects_invalid_configuration() {
|
|
let i64_max_ns = u64::try_from(i64::MAX).unwrap();
|
|
let too_large = Duration::from_nanos(i64_max_ns) + Duration::from_nanos(1);
|
|
let cases = [
|
|
(
|
|
"oversized UDP payload",
|
|
ClientConfig {
|
|
length: MAX_UDP_PAYLOAD_LENGTH + 1,
|
|
..ClientConfig::default()
|
|
},
|
|
"packet length",
|
|
),
|
|
(
|
|
"zero finite duration",
|
|
ClientConfig {
|
|
duration: Some(Duration::ZERO),
|
|
..ClientConfig::default()
|
|
},
|
|
"duration must be greater than zero; use None for continuous mode",
|
|
),
|
|
(
|
|
"zero interval",
|
|
ClientConfig {
|
|
interval: Duration::ZERO,
|
|
..ClientConfig::default()
|
|
},
|
|
"interval must be greater than zero",
|
|
),
|
|
(
|
|
"duration nanosecond overflow",
|
|
ClientConfig {
|
|
duration: Some(too_large),
|
|
..ClientConfig::default()
|
|
},
|
|
"duration is too large to encode as nanoseconds",
|
|
),
|
|
(
|
|
"interval nanosecond overflow",
|
|
ClientConfig {
|
|
interval: too_large,
|
|
..ClientConfig::default()
|
|
},
|
|
"interval is too large to encode as nanoseconds",
|
|
),
|
|
(
|
|
"invalid DSCP codepoint",
|
|
ClientConfig {
|
|
dscp: 64,
|
|
..ClientConfig::default()
|
|
},
|
|
"dscp",
|
|
),
|
|
(
|
|
// The unspecified clock is the absent-tag wire default, not a
|
|
// client mode; a client that needs timestamps must name a clock.
|
|
"unspecified clock",
|
|
ClientConfig {
|
|
clock: Clock::Unspecified,
|
|
..ClientConfig::default()
|
|
},
|
|
"clock must be wall, monotonic, or both",
|
|
),
|
|
(
|
|
"empty server fill",
|
|
ClientConfig {
|
|
server_fill: Some("".to_owned()),
|
|
..ClientConfig::default()
|
|
},
|
|
"server_fill",
|
|
),
|
|
(
|
|
"oversized server fill",
|
|
ClientConfig {
|
|
server_fill: Some("0123456789abcdef0123456789abcdefx".to_owned()),
|
|
..ClientConfig::default()
|
|
},
|
|
"server_fill",
|
|
),
|
|
];
|
|
|
|
for (name, config, expected_reason) in cases {
|
|
assert!(
|
|
matches!(
|
|
Client::connect(config),
|
|
Err(ClientError::InvalidConfig { .. })
|
|
),
|
|
"{name} should fail with InvalidConfig ({expected_reason})"
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn minimum_open_timeout_under_200ms_is_rejected() {
|
|
let config = ClientConfig {
|
|
open_timeouts: vec![Duration::from_millis(199)],
|
|
..ClientConfig::default()
|
|
};
|
|
assert!(matches!(
|
|
Client::connect(config),
|
|
Err(ClientError::OpenTimeoutTooSmall { .. })
|
|
));
|
|
}
|
|
|
|
#[test]
|
|
fn empty_open_timeouts_is_rejected() {
|
|
let config = ClientConfig {
|
|
open_timeouts: vec![],
|
|
..ClientConfig::default()
|
|
};
|
|
assert!(matches!(
|
|
Client::connect(config),
|
|
Err(ClientError::NoOpenTimeouts)
|
|
));
|
|
}
|