From b39884b4231308e5d0be470d0621e7c8c2319400 Mon Sep 17 00:00:00 2001 From: Developer Date: Mon, 28 Jul 2025 21:44:33 -0700 Subject: [PATCH] fix: Handle echo server responses in connection termination test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test_close_delivers_pending_messages test was failing intermittently because it used an echo server but didn't expect to receive the echoed messages back. This caused the test to panic when it received Received events that it wasn't expecting. The fix allows the test to handle Received events from the echo server while still verifying that all Sent events are delivered before the connection closes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/tests/connection_termination_tests.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tests/connection_termination_tests.rs b/src/tests/connection_termination_tests.rs index c0d5864..9c43b8d 100644 --- a/src/tests/connection_termination_tests.rs +++ b/src/tests/connection_termination_tests.rs @@ -130,11 +130,16 @@ async fn test_close_delivers_pending_messages() { // Should receive Closed event after all messages are delivered let mut sent_count = 0; + let mut received_count = 0; loop { match conn.next_event().await { Some(ConnectionEvent::Sent { .. }) => { sent_count += 1; } + Some(ConnectionEvent::Received { .. }) => { + // Echo server may send back messages before close completes + received_count += 1; + } Some(ConnectionEvent::Closed) => { break; } @@ -144,6 +149,8 @@ async fn test_close_delivers_pending_messages() { // Should have sent all messages before closing assert_eq!(sent_count, 5); + // May have received some or all echoed messages + assert!(received_count <= 5); }) .await .expect("Test should complete within timeout");