Skip to content

Commit 6d0e1a7

Browse files
authored
test(s2n-quic-dc): add s2n-quic-dc tests for checking size (#2807)
1 parent 4d384f9 commit 6d0e1a7

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

dc/s2n-quic-dc/src/stream/testing.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,24 @@ thread_local! {
3030
static SERVERS: RefCell<HashMap<SocketAddr, server::Handle>> = Default::default();
3131
}
3232

33+
pub mod read {
34+
use crate::stream::recv::application as recv;
35+
36+
pub use recv::{AckMode, ReadMode};
37+
pub type Reader = recv::Reader<super::Subscriber>;
38+
}
39+
40+
pub mod write {
41+
use crate::stream::send::application as send;
42+
43+
pub type Writer = send::Writer<super::Subscriber>;
44+
}
45+
3346
pub type Subscriber = (Arc<event::testing::Subscriber>, event::tracing::Subscriber);
3447

3548
pub type Stream = application::Stream<Subscriber>;
49+
pub use read::Reader;
50+
pub use write::Writer;
3651

3752
const DEFAULT_POOLED: bool = true;
3853

dc/s2n-quic-dc/src/stream/tests.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
use super::{testing, Protocol};
5+
46
mod accept_queue;
57
mod behavior;
68
/// A set of tests ensuring we support a large number of peers.
@@ -12,3 +14,37 @@ mod key_update;
1214
mod request_response;
1315
mod restart;
1416
mod rpc;
17+
18+
/// Shows an endpoint doesn't need an application tokio runtime to be created
19+
#[test]
20+
fn runtime_free_context_test() {
21+
let _ = testing::dcquic::Context::new_sync(Protocol::Udp, "127.0.0.1:0".parse().unwrap());
22+
}
23+
24+
mod sizes {
25+
use core::mem::size_of;
26+
27+
#[test]
28+
fn stream_test() {
29+
assert_eq!(
30+
size_of::<crate::stream::testing::Stream>(),
31+
size_of::<Box<()>>() * 2
32+
);
33+
}
34+
35+
#[test]
36+
fn reader_test() {
37+
assert_eq!(
38+
size_of::<crate::stream::testing::Reader>(),
39+
size_of::<Box<()>>()
40+
);
41+
}
42+
43+
#[test]
44+
fn writer_test() {
45+
assert_eq!(
46+
size_of::<crate::stream::testing::Writer>(),
47+
size_of::<Box<()>>()
48+
);
49+
}
50+
}

0 commit comments

Comments
 (0)