@@ -111,6 +111,9 @@ where
111111 Ok ( Message :: Binary ( bytes) ) => {
112112 return Poll :: Ready ( Some ( FlashBlock :: decode ( bytes) ) )
113113 }
114+ Ok ( Message :: Text ( bytes) ) => {
115+ return Poll :: Ready ( Some ( FlashBlock :: decode ( bytes. into ( ) ) ) )
116+ }
114117 Ok ( Message :: Ping ( bytes) ) => this. ping ( bytes) ,
115118 Ok ( msg) => debug ! ( "Received unexpected message: {:?}" , msg) ,
116119 Err ( err) => return Poll :: Ready ( Some ( Err ( err. into ( ) ) ) ) ,
@@ -222,7 +225,7 @@ mod tests {
222225 use alloy_primitives:: bytes:: Bytes ;
223226 use brotli:: enc:: BrotliEncoderParams ;
224227 use std:: { future, iter} ;
225- use tokio_tungstenite:: tungstenite:: { Error , Utf8Bytes } ;
228+ use tokio_tungstenite:: tungstenite:: { protocol :: frame :: Frame , Error } ;
226229
227230 /// A `FakeConnector` creates [`FakeStream`].
228231 ///
@@ -438,9 +441,11 @@ mod tests {
438441 assert_eq ! ( actual_messages, expected_messages) ;
439442 }
440443
444+ #[ test_case:: test_case( Message :: Pong ( Bytes :: from( b"test" . as_slice( ) ) ) ; "pong" ) ]
445+ #[ test_case:: test_case( Message :: Frame ( Frame :: pong( b"test" . as_slice( ) ) ) ; "frame" ) ]
441446 #[ tokio:: test]
442- async fn test_stream_ignores_non_binary_message ( ) {
443- let messages = FakeConnector :: from ( [ Ok ( Message :: Text ( Utf8Bytes :: from ( "test" ) ) ) ] ) ;
447+ async fn test_stream_ignores_unexpected_message ( message : Message ) {
448+ let messages = FakeConnector :: from ( [ Ok ( message ) ] ) ;
444449 let ws_url = "http://localhost" . parse ( ) . unwrap ( ) ;
445450 let mut stream = WsFlashBlockStream :: with_connector ( ws_url, messages) ;
446451 assert ! ( stream. next( ) . await . is_none( ) ) ;
0 commit comments