Skip to content

Commit

Permalink
Changed eof test.
Browse files Browse the repository at this point in the history
  • Loading branch information
manforowicz committed Dec 10, 2024
1 parent 31010f3 commit 18cbb6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
10 changes: 5 additions & 5 deletions gday_encryption/src/helper_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub struct HelperBufPart<'a> {
start_i: usize,
}

impl<'a> aead::Buffer for HelperBufPart<'a> {
impl aead::Buffer for HelperBufPart<'_> {
/// Extends the [`HelperBufPart`] with `other`.
/// - Returns an [`aead::Error`] if there's not enough capacity.
fn extend_from_slice(&mut self, other: &[u8]) -> aead::Result<()> {
Expand All @@ -153,27 +153,27 @@ impl<'a> aead::Buffer for HelperBufPart<'a> {

// The 4 following impls let the user treat this
// struct as a slice with the data-containing portion
impl<'a> Deref for HelperBufPart<'a> {
impl Deref for HelperBufPart<'_> {
type Target = [u8];

fn deref(&self) -> &Self::Target {
&self.parent.inner[self.start_i..self.parent.r_cursor]
}
}

impl<'a> DerefMut for HelperBufPart<'a> {
impl DerefMut for HelperBufPart<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.parent.inner[self.start_i..self.parent.r_cursor]
}
}

impl<'a> AsRef<[u8]> for HelperBufPart<'a> {
impl AsRef<[u8]> for HelperBufPart<'_> {
fn as_ref(&self) -> &[u8] {
&self.parent.inner[self.start_i..self.parent.r_cursor]
}
}

impl<'a> AsMut<[u8]> for HelperBufPart<'a> {
impl AsMut<[u8]> for HelperBufPart<'_> {
fn as_mut(&mut self) -> &mut [u8] {
&mut self.parent.inner[self.start_i..self.parent.r_cursor]
}
Expand Down
13 changes: 3 additions & 10 deletions gday_server/tests/test_integration.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![forbid(unsafe_code)]
#![warn(clippy::all)]

use std::io::Read;

use gday_contact_exchange_protocol::{read_from, write_to, ClientMsg, Contact, ServerMsg};

#[tokio::test]
Expand Down Expand Up @@ -222,16 +224,7 @@ async fn test_request_limit() {
assert_eq!(response, ServerMsg::ErrorTooManyRequests);

// ensure the server closed the connection
let result = write_to(
ClientMsg::CreateRoom {
room_code: [100; 32],
},
&mut stream_v4,
);
assert!(
matches!(result, Err(gday_contact_exchange_protocol::Error::IO(_))),
"Expected Error::IO, got {result:?}."
);
assert_eq!(stream_v4.read(&mut [0, 0]).unwrap(), 0);

// ensure other connections are unaffected
write_to(
Expand Down

0 comments on commit 18cbb6e

Please sign in to comment.