From 5d365521c03ccf4b1745868c1125967927714baf Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 13 Jul 2025 14:58:07 +0100 Subject: [PATCH 1/4] Document rate limiter nuances --- tests/push.rs | 5 +++++ tests/push_policies.rs | 13 ++++++++----- wireframe_testing/src/lib.rs | 4 +++- wireframe_testing/src/logging.rs | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/push.rs b/tests/push.rs index b1ad0d08..187e5cbd 100644 --- a/tests/push.rs +++ b/tests/push.rs @@ -57,6 +57,8 @@ async fn push_queues_error_on_closed() { } /// A push beyond the configured rate is blocked. +/// Time is paused using [`tokio::time::pause`], so the test runs in a +/// virtual-time context. #[rstest] #[case::high(PushPriority::High)] #[case::low(PushPriority::Low)] @@ -107,6 +109,8 @@ async fn rate_limiter_allows_after_wait() { } /// The limiter counts pushes from all priority queues. +/// The token bucket is shared, so pushes from one priority reduce +/// the allowance for the other. #[tokio::test] async fn rate_limiter_shared_across_priorities() { time::pause(); @@ -142,6 +146,7 @@ async fn unlimited_queues_do_not_block() { } /// A burst up to capacity succeeds and further pushes are blocked. +/// The maximum burst size equals the configured `capacity` parameter. #[tokio::test] async fn rate_limiter_allows_burst_within_capacity_and_blocks_excess() { time::pause(); diff --git a/tests/push_policies.rs b/tests/push_policies.rs index e0173bc6..4588f1d4 100644 --- a/tests/push_policies.rs +++ b/tests/push_policies.rs @@ -12,16 +12,19 @@ use wireframe::push::{PushPolicy, PushPriority, PushQueues}; use wireframe_testing::{LoggerHandle, logger}; /// Builds a single-thread [`Runtime`] for async tests. -#[allow( +#[allow(unfulfilled_lint_expectations)] +#[expect( unused_braces, reason = "rustc false positive for single line rstest fixtures" )] #[fixture] fn rt() -> Runtime { - tokio::runtime::Builder::new_current_thread() - .enable_all() - .build() - .expect("failed to build test runtime") + return { + tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .expect("failed to build test runtime") + }; } /// Verifies how queue policies log and drop when the queue is full. diff --git a/wireframe_testing/src/lib.rs b/wireframe_testing/src/lib.rs index 8657b8e2..34002b56 100644 --- a/wireframe_testing/src/lib.rs +++ b/wireframe_testing/src/lib.rs @@ -2,7 +2,9 @@ //! with in-memory streams during tests. //! //! These helpers spawn the application on a `tokio::io::duplex` stream and -//! return all bytes written by the app for easy assertions. +//! return all bytes written by the app for easy assertions. They work with any +//! message implementing [`bincode::Encode`] – the example uses a simple `u8` +//! value so no generics are required. //! //! ```rust //! use wireframe::app::WireframeApp; diff --git a/wireframe_testing/src/logging.rs b/wireframe_testing/src/logging.rs index 0f312e13..b7af3226 100644 --- a/wireframe_testing/src/logging.rs +++ b/wireframe_testing/src/logging.rs @@ -43,10 +43,10 @@ impl LoggerHandle { /// /// ```no_run /// use wireframe_testing::LoggerHandle; - /// # use log::info; + /// # use log::warn; /// /// let mut log = LoggerHandle::new(); - /// info!("init"); + /// warn!("warned"); /// assert!(log.pop().is_some()); /// assert!(log.pop().is_none()); /// ``` From fefd481ad419efd3e88fc66ba01d838d7e61f721 Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 13 Jul 2025 15:09:57 +0100 Subject: [PATCH 2/4] Remove unnecessary return statement and braces. Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- tests/push_policies.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/push_policies.rs b/tests/push_policies.rs index 4588f1d4..0e1bd344 100644 --- a/tests/push_policies.rs +++ b/tests/push_policies.rs @@ -19,12 +19,11 @@ use wireframe_testing::{LoggerHandle, logger}; )] #[fixture] fn rt() -> Runtime { - return { - tokio::runtime::Builder::new_current_thread() - .enable_all() - .build() - .expect("failed to build test runtime") - }; +fn rt() -> Runtime { + tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .expect("failed to build test runtime") } /// Verifies how queue policies log and drop when the queue is full. From 74dfb41feb65f60a2b23d7637787cae1d4df7173 Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 13 Jul 2025 15:11:08 +0100 Subject: [PATCH 3/4] Use `allow` for fixture --- tests/push_policies.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/push_policies.rs b/tests/push_policies.rs index 0e1bd344..a9ba752b 100644 --- a/tests/push_policies.rs +++ b/tests/push_policies.rs @@ -12,8 +12,7 @@ use wireframe::push::{PushPolicy, PushPriority, PushQueues}; use wireframe_testing::{LoggerHandle, logger}; /// Builds a single-thread [`Runtime`] for async tests. -#[allow(unfulfilled_lint_expectations)] -#[expect( +#[allow( unused_braces, reason = "rustc false positive for single line rstest fixtures" )] From 7908b34156b01da06cfc71cee08c44077009c9f9 Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 13 Jul 2025 15:12:58 +0100 Subject: [PATCH 4/4] Fix repeated line --- tests/push_policies.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/push_policies.rs b/tests/push_policies.rs index a9ba752b..e0173bc6 100644 --- a/tests/push_policies.rs +++ b/tests/push_policies.rs @@ -17,7 +17,6 @@ use wireframe_testing::{LoggerHandle, logger}; reason = "rustc false positive for single line rstest fixtures" )] #[fixture] -fn rt() -> Runtime { fn rt() -> Runtime { tokio::runtime::Builder::new_current_thread() .enable_all()