@@ -101,7 +101,7 @@ async fn split_communication() {
101101 . await
102102 . expect ( "Client failed to connect" ) ;
103103
104- let ( tx, rx) = stream. split ( ) ;
104+ let ( mut tx, rx) = stream. split ( ) ;
105105
106106 for i in 1 ..10 {
107107 info ! ( "Sending message" ) ;
@@ -120,53 +120,3 @@ async fn split_communication() {
120120 assert ! ( rx. is_pair_of( & tx) ) ;
121121 WebSocketStream :: reunite ( tx, rx) . expect ( "Failed to reunite the stream" ) ;
122122}
123-
124- #[ async_std:: test]
125- async fn concurrent_send ( ) {
126- let _ = env_logger:: try_init ( ) ;
127-
128- let ( con_tx, con_rx) = futures:: channel:: oneshot:: channel ( ) ;
129- let ( msg_tx, msg_rx) = futures:: channel:: oneshot:: channel ( ) ;
130-
131- let f = async move {
132- let listener = TcpListener :: bind ( "127.0.0.1:12347" ) . await . unwrap ( ) ;
133- info ! ( "Server ready" ) ;
134- con_tx. send ( ( ) ) . unwrap ( ) ;
135- info ! ( "Waiting on next connection" ) ;
136- let ( connection, _) = listener. accept ( ) . await . expect ( "No connections to accept" ) ;
137- let stream = accept_async ( connection) . await ;
138- let stream = stream. expect ( "Failed to handshake with connection" ) ;
139- run_connection ( stream, msg_tx) . await ;
140- } ;
141-
142- task:: spawn ( f) ;
143-
144- info ! ( "Waiting for server to be ready" ) ;
145-
146- con_rx. await . expect ( "Server not ready" ) ;
147- let tcp = TcpStream :: connect ( "127.0.0.1:12347" )
148- . await
149- . expect ( "Failed to connect" ) ;
150- let url = url:: Url :: parse ( "ws://localhost:12347/" ) . unwrap ( ) ;
151- let ( stream, _) = client_async ( url, tcp)
152- . await
153- . expect ( "Client failed to connect" ) ;
154-
155- let ( tx, _rx) = stream. split ( ) ;
156-
157- // the `WebSocketSender::send` takes a shared `&self`, so you can call it concurrently.
158- // this test case checks that it works
159- let results = futures:: future:: join_all ( ( 1 ..10 ) . map ( |i| {
160- info ! ( "Sending message" ) ;
161- tx. send ( Message :: text ( format ! ( "{}" , i) ) )
162- } ) )
163- . await ;
164-
165- assert ! ( results. iter( ) . all( Result :: is_ok) ) ;
166-
167- tx. close ( None ) . await . expect ( "Failed to close" ) ;
168-
169- info ! ( "Waiting for response messages" ) ;
170- let messages = msg_rx. await . expect ( "Failed to receive messages" ) ;
171- assert_eq ! ( messages. len( ) , 10 ) ;
172- }
0 commit comments