irtt-client and irtt-server mutually dev-depended on each other for cross-crate integration tests. That cycle blocks `cargo publish` for either crate whenever the other doesn't already exist on the registry at the required version, which is exactly the situation for a crate's first-ever release (irtt-server has never been published before). Introduce a new `irtt-integration-tests` crate (publish = false, no library target) to own tests whose actual subject is the interaction between two or more irtt-* production crates: crate-local behavior -> crate's own tests/ cross-crate/system behavior -> irtt-integration-tests Move every test that imports both irtt_client and irtt_server there: the client-side support harness (hmac, large_packets, protocol_options, fill_negotiation) and the server-side real-socket tests that drive a real AsyncClient against a real Server (async_client, negotiation_policy, fill_wire_bytes, traffic_class, wildcard_source). server_set.rs stays in irtt-server/tests since it only uses irtt_proto as test machinery to drive irtt-server directly, which is a normal one-directional test dependency, not a peer relationship. irtt-server's dev-dependency on irtt-client is dropped entirely now that nothing under crates/irtt-server/tests needs it, which fully breaks the cycle from that side. irtt-client keeps a one-directional dev-dependency on irtt-server: a handful of white-box unit tests in src/async_client/tests.rs assert on private AsyncClient internals (socket, remote, test_hooks) while also needing a real in-tree server for blocking/async equivalence checks, so they can't move to an external crate without losing that access. Their InTreeServer helper is duplicated locally rather than shared, matching the existing precedent of irtt-cli's own tests/support/in_tree_server.rs.
104 lines
3.2 KiB
Rust
104 lines
3.2 KiB
Rust
mod support;
|
|
|
|
use irtt_client::{Client, ClientConfig, ClientEvent, NegotiationPolicy};
|
|
use irtt_proto::{echo_header_len, Params, TimestampFields};
|
|
|
|
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 {
|
|
Params {
|
|
length,
|
|
..default_params()
|
|
}
|
|
}
|
|
|
|
fn assert_echo_size(run: &support::OneProbeRun, expected: usize) {
|
|
match run.observations[1] {
|
|
ServerObservation::Echo { len, .. } => assert_eq!(len, expected),
|
|
ref other => panic!("expected Echo observation, got {other:?}"),
|
|
}
|
|
}
|
|
|
|
fn assert_reply(event: &ClientEvent) {
|
|
assert!(matches!(event, ClientEvent::EchoReply { .. }));
|
|
}
|
|
|
|
fn assert_sent_bytes(event: &ClientEvent, expected: usize) {
|
|
match event {
|
|
ClientEvent::EchoSent { bytes, .. } => assert_eq!(*bytes, expected),
|
|
other => panic!("expected EchoSent, got {other:?}"),
|
|
}
|
|
}
|
|
|
|
fn assert_reply_bytes(event: &ClientEvent, expected: usize) {
|
|
match event {
|
|
ClientEvent::EchoReply { bytes, .. } => assert_eq!(*bytes, expected),
|
|
other => panic!("expected EchoReply, got {other:?}"),
|
|
}
|
|
}
|
|
|
|
// ─── Echo request size: FakeServer observes exact packet size ───
|
|
|
|
#[test]
|
|
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 = test_echo_packet_len(false, ¶ms);
|
|
assert_echo_size(&run, expected);
|
|
assert_sent_bytes(&run.sent, expected);
|
|
}
|
|
|
|
#[test]
|
|
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 = test_echo_packet_len(false, ¶ms);
|
|
assert_eq!(
|
|
expected,
|
|
echo_header_len(false, ¶ms).max(length as usize)
|
|
);
|
|
assert_echo_size(&run, expected);
|
|
assert_sent_bytes(&run.sent, expected);
|
|
}
|
|
}
|
|
|
|
// ─── Echo reply handling ───
|
|
|
|
#[test]
|
|
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 = test_echo_packet_len(false, ¶ms);
|
|
assert_reply(&run.reply);
|
|
assert_reply_bytes(&run.reply, expected);
|
|
}
|
|
}
|
|
|
|
// ─── Backend-neutral smoke ───
|
|
|
|
#[test]
|
|
fn backend_large_packet_smoke() {
|
|
let params = params_with_length(1472);
|
|
let peer = BackendPeer::start_open_echo(None);
|
|
let mut client = Client::connect(ClientConfig {
|
|
negotiation_policy: NegotiationPolicy::Loose,
|
|
length: 1472,
|
|
..config_for_params(peer.addr(), ¶ms)
|
|
})
|
|
.unwrap();
|
|
|
|
let outcome = client.open().unwrap();
|
|
assert!(matches!(outcome, irtt_client::OpenOutcome::Started { .. }));
|
|
|
|
client.send_probe().unwrap();
|
|
let events = client.recv_once().unwrap();
|
|
assert_eq!(events.len(), 1);
|
|
assert!(matches!(events[0], ClientEvent::EchoReply { .. }));
|
|
|
|
client.close().unwrap();
|
|
}
|