Rewrite a flow test
This commit is contained in:
		| @@ -424,9 +424,9 @@ impl Future for GetResponse { | |||||||
| #[test] | #[test] | ||||||
| fn recv_window_update_on_stream_closed_by_data_frame() { | fn recv_window_update_on_stream_closed_by_data_frame() { | ||||||
|     let _ = ::env_logger::init(); |     let _ = ::env_logger::init(); | ||||||
|     let (m, mock) = mock::new(); |     let (io, srv) = mock::new(); | ||||||
|  |  | ||||||
|     let h2 = Client::handshake(m).unwrap() |     let h2 = Client::handshake(io).unwrap() | ||||||
|         .and_then(|mut h2| { |         .and_then(|mut h2| { | ||||||
|             let request = Request::builder() |             let request = Request::builder() | ||||||
|                 .method(Method::POST) |                 .method(Method::POST) | ||||||
| @@ -451,40 +451,21 @@ fn recv_window_update_on_stream_closed_by_data_frame() { | |||||||
|         }) |         }) | ||||||
|         ; |         ; | ||||||
|  |  | ||||||
|     let mock = mock.assert_client_handshake().unwrap() |     let srv = srv.assert_client_handshake().unwrap() | ||||||
|         // Get the first frame |         .recv_settings() | ||||||
|         .and_then(|(_, mock)| mock.into_future().unwrap()) |         .recv_frame( | ||||||
|         .and_then(|(frame, mut mock)| { |             frames::headers(1) | ||||||
|             let request = assert_headers!(frame.unwrap()); |                 .request("POST", "https://http2.akamai.com/") | ||||||
|  |         ) | ||||||
|             assert_eq!(request.stream_id(), 1); |         .send_frame( | ||||||
|             assert!(!request.is_end_stream()); |             frames::headers(1) | ||||||
|  |                 .response(200) | ||||||
|             // Send the response which also closes the stream |         ) | ||||||
|             let mut f = frame::Headers::new( |         .recv_frame(frames::data(1, "hello").eos()) | ||||||
|                 request.stream_id(), |         .send_frame(frames::window_update(1, 5)) | ||||||
|                 frame::Pseudo::response(StatusCode::OK), |         .map(drop) | ||||||
|                 HeaderMap::new()); |  | ||||||
|             f.set_end_stream(); |  | ||||||
|  |  | ||||||
|             mock.send(f.into()).unwrap(); |  | ||||||
|  |  | ||||||
|             mock.into_future().unwrap() |  | ||||||
|         }) |  | ||||||
|         .and_then(|(frame, mut mock)| { |  | ||||||
|             let data = assert_data!(frame.unwrap()); |  | ||||||
|             assert_eq!(data.payload(), "hello"); |  | ||||||
|  |  | ||||||
|             // Send a window update just for fun |  | ||||||
|             let f = frame::WindowUpdate::new( |  | ||||||
|                 data.stream_id(), data.payload().len() as u32); |  | ||||||
|  |  | ||||||
|             mock.send(f.into()).unwrap(); |  | ||||||
|  |  | ||||||
|             Ok(()) |  | ||||||
|         }) |  | ||||||
|         ; |         ; | ||||||
|  |  | ||||||
|     let _ = h2.join(mock) |     let _ = h2.join(srv) | ||||||
|         .wait().unwrap(); |         .wait().unwrap(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -335,6 +335,12 @@ pub trait HandleFutureExt { | |||||||
|             frame: Some(frame.into()), |             frame: Some(frame.into()), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     fn close(self) -> Box<Future<Item=(), Error=()>> | ||||||
|  |         where Self: Future<Error = ()> + Sized + 'static, | ||||||
|  |     { | ||||||
|  |         Box::new(self.map(drop)) | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| pub struct RecvFrame<T> { | pub struct RecvFrame<T> { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user