From 18cbb6ea6bdea2c05cd613032bd617e15c9353f5 Mon Sep 17 00:00:00 2001 From: Marcin Anforowicz Date: Tue, 10 Dec 2024 11:10:48 -0800 Subject: [PATCH] Changed eof test. --- gday_encryption/src/helper_buf.rs | 10 +++++----- gday_server/tests/test_integration.rs | 13 +++---------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/gday_encryption/src/helper_buf.rs b/gday_encryption/src/helper_buf.rs index a304058..236349c 100644 --- a/gday_encryption/src/helper_buf.rs +++ b/gday_encryption/src/helper_buf.rs @@ -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<()> { @@ -153,7 +153,7 @@ 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 { @@ -161,19 +161,19 @@ impl<'a> Deref for HelperBufPart<'a> { } } -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] } diff --git a/gday_server/tests/test_integration.rs b/gday_server/tests/test_integration.rs index 8aa6e00..60e9e70 100644 --- a/gday_server/tests/test_integration.rs +++ b/gday_server/tests/test_integration.rs @@ -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] @@ -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(