| 1 |
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 2 |
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 3 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 4 |
// option. This file may not be copied, modified, or distributed |
| 5 |
// except according to those terms. |
| 6 |
|
| 7 |
use neqo_transport::ConnectionParameters; |
| 8 |
use test_fixture::{default_client, default_server, new_client, now}; |
| 9 |
|
| 10 |
#[test] |
| 11 |
fn sni_no_slicing_at_nonzero_offset() { |
| 12 |
let mut client = default_client(); |
| 13 |
let mut server = default_server(); |
| 14 |
let mut now = now(); |
| 15 |
|
| 16 |
// This packet will have two CRPYTO frames [y..end] and [0..x], where x < y. |
| 17 |
let ch1 = client.process_output(now).dgram(); |
| 18 |
assert_eq!(client.stats().frame_tx.crypto, 2); |
| 19 |
// This packet will have one CRYPTO frame [x..y]. |
| 20 |
let _ch2 = client.process_output(now).dgram(); |
| 21 |
assert_eq!(client.stats().frame_tx.crypto, 3); |
| 22 |
// We are dropping the second packet and only deliver the first. |
| 23 |
let ack = server.process(ch1, now).dgram(); |
| 24 |
// Client will now RTX the second packet. |
| 25 |
now += client.process(ack, now).callback(); |
| 26 |
// Make sure it only has one CRYPTO frame. |
| 27 |
_ = client.process_output(now).dgram(); |
| 28 |
assert_eq!(client.stats().frame_tx.crypto, 4); |
| 29 |
} |
| 30 |
|
| 31 |
#[test] |
| 32 |
fn sni_no_slicing_at_nonzero_offset_no_mlkem() { |
| 33 |
let mut client = new_client(ConnectionParameters::default().mlkem(false)); |
| 34 |
let mut now = now(); |
| 35 |
|
| 36 |
// This packet will have two CRPYTO frames [x..end] and [0..x]. |
| 37 |
_ = client.process_output(now).dgram(); |
| 38 |
assert_eq!(client.stats().frame_tx.crypto, 2); |
| 39 |
// Client will now RTX the packet. |
| 40 |
now += client.process_output(now).callback(); |
| 41 |
// Make sure it has two CRYPTO frames. |
| 42 |
_ = client.process_output(now).dgram(); |
| 43 |
assert_eq!(client.stats().frame_tx.crypto, 4); |
| 44 |
} |