test: cover timing, overflow, and target authentication contracts
This commit is contained in:
4 files changed
+150
-3
No files matched your search
@@ -1,5 +1,45 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn probe_timeout_overflow_transmits_no_echo() {
|
||||
let params = default_params();
|
||||
let server = start_fake_server(move |socket, tx| {
|
||||
socket
|
||||
.set_read_timeout(Some(Duration::from_secs(2)))
|
||||
.unwrap();
|
||||
let (_, peer) = recv_request(&socket, &tx);
|
||||
socket
|
||||
.send_to(
|
||||
&open_reply(FLAG_OPEN | FLAG_REPLY, TOKEN, ¶ms, None),
|
||||
peer,
|
||||
)
|
||||
.unwrap();
|
||||
// CLOSE is a completion barrier: any incorrectly transmitted ECHO
|
||||
// precedes it on this connected loopback socket.
|
||||
let _ = recv_request(&socket, &tx);
|
||||
});
|
||||
let config = ClientConfig {
|
||||
probe_timeout: Duration::MAX,
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open().unwrap());
|
||||
assert!(matches!(
|
||||
client.send_probe(),
|
||||
Err(ClientError::DurationOverflow)
|
||||
));
|
||||
assert!(!client.has_pending_probes());
|
||||
client.close().unwrap();
|
||||
let packets: Vec<_> = server.rx.iter().collect();
|
||||
assert_eq!(packets.len(), 2);
|
||||
assert_eq!(
|
||||
packets[1][3],
|
||||
flags::FLAG_CLOSE,
|
||||
"overflow must not transmit an ECHO"
|
||||
);
|
||||
server.join();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn poll_timeouts_emits_echo_loss() {
|
||||
let params = default_params();
|
||||
|
||||
Reference in new issue
Block a user