@@ -122,86 +122,4 @@ where
122122}
123123
124124#[ cfg( test) ]
125- pub mod tests {
126- use std:: {
127- pin:: Pin ,
128- task:: { Context , Poll } ,
129- } ;
130-
131- use futures:: { channel:: mpsc, Sink , Stream } ;
132-
133- use crate :: endpoints:: defns:: api:: websocket_updates:: { ClientMsg , ServerMsg } ;
134-
135- use super :: TransportTrait ;
136-
137- pub struct MockTransportHandler {
138- send : mpsc:: Sender < ServerMsg > ,
139- recv : mpsc:: Receiver < ClientMsg > ,
140- }
141-
142- pub struct MockTransport {
143- recv : mpsc:: Receiver < ServerMsg > ,
144- send : mpsc:: Sender < ClientMsg > ,
145- }
146-
147- impl TransportTrait for MockTransport {
148- type TransportError = mpsc:: SendError ;
149- }
150-
151- impl MockTransport {
152- pub fn new ( ) -> ( Self , MockTransportHandler ) {
153- let ( server_msg_sender, server_msg_receiver) = mpsc:: channel ( 100 ) ;
154- let ( client_msg_sender, client_msg_receiver) = mpsc:: channel ( 100 ) ;
155-
156- (
157- Self {
158- recv : server_msg_receiver,
159- send : client_msg_sender,
160- } ,
161- MockTransportHandler {
162- send : server_msg_sender,
163- recv : client_msg_receiver,
164- } ,
165- )
166- }
167- }
168-
169- impl Stream for MockTransport {
170- type Item = Result < ServerMsg , mpsc:: SendError > ;
171-
172- fn poll_next ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Option < Self :: Item > > {
173- Pin :: new ( & mut self . recv )
174- . poll_next ( cx)
175- . map ( |opt| opt. map ( Ok ) )
176- }
177- }
178-
179- impl Sink < ClientMsg > for MockTransport {
180- type Error = mpsc:: SendError ;
181-
182- fn poll_ready (
183- mut self : Pin < & mut Self > ,
184- cx : & mut Context < ' _ > ,
185- ) -> Poll < Result < ( ) , Self :: Error > > {
186- Pin :: new ( & mut self . send ) . poll_ready ( cx)
187- }
188-
189- fn start_send ( mut self : Pin < & mut Self > , item : ClientMsg ) -> Result < ( ) , Self :: Error > {
190- Pin :: new ( & mut self . send ) . start_send ( item)
191- }
192-
193- fn poll_flush (
194- mut self : Pin < & mut Self > ,
195- cx : & mut Context < ' _ > ,
196- ) -> Poll < Result < ( ) , Self :: Error > > {
197- Pin :: new ( & mut self . send ) . poll_flush ( cx)
198- }
199-
200- fn poll_close (
201- mut self : Pin < & mut Self > ,
202- cx : & mut Context < ' _ > ,
203- ) -> Poll < Result < ( ) , Self :: Error > > {
204- Pin :: new ( & mut self . send ) . poll_close ( cx)
205- }
206- }
207- }
125+ pub mod tests;
0 commit comments