From 77304604febf4b4e08ed2423e00f8a6b664d210d Mon Sep 17 00:00:00 2001 From: faumaray Date: Sun, 25 Oct 2026 03:26:33 +0300 Subject: [PATCH] Let the stream task say when it is done in the layer-format test layer_formats_reach_the_live_stream sent the same layer format a second time and then slept 200 ms before asserting that no keyframe was asked for, which tests that the stream task had not got to the command within 200 ms. It is the task that asks for a keyframe (when the layer's bitrate changes) and it takes its commands in the order they are sent, from the sink and from the handle through the same channel. The test now sends a command whose answer is an error event (Kick of a viewer, 65535, that is none) and waits for that event: it comes after everything the format set going, and nothing is left to wait out. A keyframe request the viewer's side makes late is not covered, and none was seen. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/stream.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/voelin-core/src/stream.rs b/crates/voelin-core/src/stream.rs index f385e2c..893bed0 100644 --- a/crates/voelin-core/src/stream.rs +++ b/crates/voelin-core/src/stream.rs @@ -1342,7 +1342,11 @@ mod tests { .await .expect("the layer did not change"); sink.layer_format(0, format(9_000_000)); - tokio::time::sleep(Duration::from_millis(200)).await; + // The stream task takes its commands in order: its answer to this one + // (an error, nobody is viewer 65535) comes after all that the format + // above set going, and nothing is left to wait out. + handles[0].send(StreamCmd::Kick { viewer: u16::MAX }); + wait(&mut rx, |e| matches!(e, Event::Error { session: 1, .. }).then_some(())).await; assert!(!keyframes(), "nothing changed"); handles[0].send(StreamCmd::Stop); }