From 5ccd02b0fe5db168255a9ceb7ed613e75b3d88f3 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Fri, 1 Aug 2025 17:40:10 -0700 Subject: [PATCH] cut some lines --- .../mcp-server/tests/common/mcp_process.rs | 20 ++----------------- .../mcp-server/tests/stream_conversation.rs | 8 ++++---- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/codex-rs/mcp-server/tests/common/mcp_process.rs b/codex-rs/mcp-server/tests/common/mcp_process.rs index 25fe19d72e..270112600f 100644 --- a/codex-rs/mcp-server/tests/common/mcp_process.rs +++ b/codex-rs/mcp-server/tests/common/mcp_process.rs @@ -272,33 +272,17 @@ impl McpProcess { } /// Connect stream for a conversation and wait for the initial_state notification. - /// Returns the params of the initial_state notification for further inspection. + /// Returns (requestId, params) where params are the initial_state notification params. pub async fn connect_stream_and_expect_initial_state( &mut self, session_id: &str, - ) -> anyhow::Result { + ) -> anyhow::Result<(i64, serde_json::Value)> { let req_id = self.send_conversation_stream_tool_call(session_id).await?; // Wait for stream() tool-call response first let _ = self .read_stream_until_response_message(RequestId::Integer(req_id)) .await?; // Then the initial_state notification - let note = self - .read_stream_until_notification_method("notifications/initial_state") - .await?; - note.params - .ok_or_else(|| anyhow::format_err!("initial_state must have params")) - } - - /// Connect stream and also return the request id for later cancellation. - pub async fn connect_stream_get_req_and_initial_state( - &mut self, - session_id: &str, - ) -> anyhow::Result<(i64, serde_json::Value)> { - let req_id = self.send_conversation_stream_tool_call(session_id).await?; - let _ = self - .read_stream_until_response_message(RequestId::Integer(req_id)) - .await?; let note = self .read_stream_until_notification_method("notifications/initial_state") .await?; diff --git a/codex-rs/mcp-server/tests/stream_conversation.rs b/codex-rs/mcp-server/tests/stream_conversation.rs index 00f74fb7ef..95933e3c93 100644 --- a/codex-rs/mcp-server/tests/stream_conversation.rs +++ b/codex-rs/mcp-server/tests/stream_conversation.rs @@ -38,7 +38,7 @@ async fn test_connect_then_send_receives_initial_state_and_notifications() { .expect("create conversation"); // Connect the stream - let params = mcp + let (_stream_req, params) = mcp .connect_stream_and_expect_initial_state(&conv_id) .await .expect("initial_state params"); @@ -94,7 +94,7 @@ async fn test_send_then_connect_receives_initial_state_with_message() { .expect("send message ok"); // Now connect stream and expect InitialState with the prior message included - let params = mcp + let (_stream_req, params) = mcp .connect_stream_and_expect_initial_state(&conv_id) .await .expect("initial_state params"); @@ -151,7 +151,7 @@ async fn test_cancel_stream_then_reconnect_catches_up_initial_state() { .await .expect("create"); let (stream_a_id, _params) = mcp - .connect_stream_get_req_and_initial_state(&conv_id) + .connect_stream_and_expect_initial_state(&conv_id) .await .expect("stream A initial_state"); @@ -183,7 +183,7 @@ async fn test_cancel_stream_then_reconnect_catches_up_initial_state() { ); // Connect stream B and expect initial_state that includes the response - let params = mcp + let (_stream_req, params) = mcp .connect_stream_and_expect_initial_state(&conv_id) .await .expect("stream B initial_state");