diff --git a/crates/optimism/flashblocks/src/ws/stream.rs b/crates/optimism/flashblocks/src/ws/stream.rs index c18857eee3c..a2aad69eef6 100644 --- a/crates/optimism/flashblocks/src/ws/stream.rs +++ b/crates/optimism/flashblocks/src/ws/stream.rs @@ -182,7 +182,7 @@ mod tests { use alloy_primitives::bytes::Bytes; use brotli::enc::BrotliEncoderParams; use std::future; - use tokio_tungstenite::tungstenite::Error; + use tokio_tungstenite::tungstenite::{Error, Utf8Bytes}; /// A `FakeConnector` creates [`FakeStream`]. /// @@ -284,4 +284,18 @@ mod tests { assert_eq!(actual_messages, expected_messages); } + + #[tokio::test] + async fn test_stream_fails_to_decode_non_binary_message() { + let messages = FakeConnector::from([Ok(Message::Text(Utf8Bytes::from("test")))]); + let ws_url = "http://localhost".parse().unwrap(); + let stream = WsFlashBlockStream::with_connector(ws_url, messages); + + let actual_messages: Vec<_> = + stream.map(Result::unwrap_err).map(|e| format!("{e}")).collect().await; + let expected_messages = + vec!["Unexpected websocket message: Text(Utf8Bytes(b\"test\"))".to_owned()]; + + assert_eq!(actual_messages, expected_messages); + } }