From c6fdfed819b1de9bec91e4f0eac9fd22b78e837f Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 6 Jul 2025 14:13:14 +0100 Subject: [PATCH 1/2] Add test ensuring strict priority when fairness disabled --- tests/connection_actor.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/connection_actor.rs b/tests/connection_actor.rs index b746ded5..0bbca515 100644 --- a/tests/connection_actor.rs +++ b/tests/connection_actor.rs @@ -104,6 +104,32 @@ async fn fairness_disabled_processes_all_high_first( assert_eq!(out, vec![1, 2, 3, 4, 5]); } +#[rstest] +#[tokio::test] +async fn fairness_disabled_ignores_arrival_order( + queues: (PushQueues, wireframe::push::PushHandle), + shutdown_token: CancellationToken, +) { + let (queues, handle) = queues; + let fairness = FairnessConfig { + max_high_before_low: 0, + time_slice: None, + }; + + handle.push_low_priority(4).await.unwrap(); + handle.push_low_priority(5).await.unwrap(); + for n in 1..=3 { + handle.push_high_priority(n).await.unwrap(); + } + + let mut actor: ConnectionActor<_, ()> = + ConnectionActor::new(queues, handle, None, shutdown_token); + actor.set_fairness(fairness); + let mut out = Vec::new(); + actor.run(&mut out).await.unwrap(); + assert_eq!(out, vec![1, 2, 3, 4, 5]); +} + #[rstest] #[tokio::test] async fn fairness_yields_low_with_time_slice( From 0d08cfce2d60b1bbd6ed3329bab1441478c251fb Mon Sep 17 00:00:00 2001 From: Leynos Date: Sun, 6 Jul 2025 14:31:54 +0100 Subject: [PATCH 2/2] Replace unwraps with expects in test --- tests/connection_actor.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/connection_actor.rs b/tests/connection_actor.rs index 0bbca515..7b938d3a 100644 --- a/tests/connection_actor.rs +++ b/tests/connection_actor.rs @@ -116,17 +116,24 @@ async fn fairness_disabled_ignores_arrival_order( time_slice: None, }; - handle.push_low_priority(4).await.unwrap(); - handle.push_low_priority(5).await.unwrap(); + handle + .push_low_priority(4) + .await + .expect("failed to push low-priority frame 4"); + handle + .push_low_priority(5) + .await + .expect("failed to push low-priority frame 5"); for n in 1..=3 { - handle.push_high_priority(n).await.unwrap(); + let message = format!("failed to push high-priority frame {n}"); + handle.push_high_priority(n).await.expect(&message); } let mut actor: ConnectionActor<_, ()> = ConnectionActor::new(queues, handle, None, shutdown_token); actor.set_fairness(fairness); let mut out = Vec::new(); - actor.run(&mut out).await.unwrap(); + actor.run(&mut out).await.expect("actor run failed"); assert_eq!(out, vec![1, 2, 3, 4, 5]); }