Skip to content

Commit fd5d2d3

Browse files
authored
test(s2n-quic-dc): shared caches tests (#2876)
1 parent e726f08 commit fd5d2d3

File tree

9 files changed

+343
-81
lines changed

9 files changed

+343
-81
lines changed

dc/s2n-quic-dc/src/path/secret/map.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ impl Map {
298298
self.store.test_stop_cleaner();
299299
}
300300

301+
#[doc(hidden)]
302+
#[cfg(test)]
303+
pub fn reset_all_senders(&self) {
304+
self.store.reset_all_senders();
305+
}
306+
301307
#[doc(hidden)]
302308
#[cfg(any(test, feature = "testing"))]
303309
pub fn test_insert(&self, peer: SocketAddr) {

dc/s2n-quic-dc/src/path/secret/map/entry.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ impl Entry {
300300
pub fn application_data(&self) -> &Option<ApplicationData> {
301301
&self.application_data
302302
}
303+
304+
#[cfg(test)]
305+
pub fn reset_sender_counter(&self) {
306+
self.sender.reset_counter();
307+
}
303308
}
304309

305310
impl receiver::Error {

dc/s2n-quic-dc/src/path/secret/map/state.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,14 @@ where
10291029
Ok(None)
10301030
}
10311031
}
1032+
1033+
#[cfg(test)]
1034+
fn reset_all_senders(&self) {
1035+
let peer_map = self.peers.0.read();
1036+
for entry in peer_map.iter() {
1037+
entry.reset_sender_counter();
1038+
}
1039+
}
10321040
}
10331041

10341042
impl<C, S> Drop for State<C, S>

dc/s2n-quic-dc/src/path/secret/map/store.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,7 @@ pub trait Store: 'static + Send + Sync {
145145
&self,
146146
session: &dyn s2n_quic_core::crypto::tls::TlsSession,
147147
) -> Result<Option<ApplicationData>, ApplicationDataError>;
148+
149+
#[cfg(test)]
150+
fn reset_all_senders(&self);
148151
}

dc/s2n-quic-dc/src/path/secret/sender.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ impl State {
7373
// Update the key to the new minimum to start at.
7474
self.current_id.fetch_max(*min_key_id, Ordering::Relaxed);
7575
}
76+
77+
#[cfg(test)]
78+
pub fn reset_counter(&self) {
79+
self.current_id.store(0, Ordering::Relaxed);
80+
}
7681
}
7782

7883
#[test]

dc/s2n-quic-dc/src/stream/server/tokio/tcp/worker.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ where
781781
.on_decrypt_success(recv_buffer.into())
782782
.is_err()
783783
{
784+
// we just close the stream
784785
return Ok(ControlFlow::Continue(())).into();
785786
};
786787

@@ -813,16 +814,12 @@ where
813814
recv_buffer,
814815
);
815816

816-
let sender = uds::sender::Sender::new()?;
817-
let dest_path = self.dest_path.clone();
817+
let sender = uds::sender::Sender::new(&self.dest_path)?;
818818
let tcp_stream = socket.into_std()?;
819819

820820
// FIXME make this a manual Future impl instead of Box
821-
let send_future = Box::pin(async move {
822-
sender
823-
.send_msg(&buffer, &dest_path, tcp_stream.as_fd())
824-
.await
825-
});
821+
let send_future =
822+
Box::pin(async move { sender.send_msg(&buffer, tcp_stream.as_fd()).await });
826823

827824
let event_data = SocketEventData {
828825
credential_id: credentials.id.to_vec(),

0 commit comments

Comments
 (0)