Skip to content

Commit

Permalink
Add test for issue #11
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Oct 19, 2017
1 parent 16f4004 commit 77025d0
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/stream_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,60 @@ fn recv_goaway_finishes_processed_streams() {
h2.join(srv).wait().expect("wait");
}

#[test]
fn skipped_stream_ids_are_implicitly_closed() {
let _ = ::env_logger::init();
let (io, srv) = mock::new();

let srv = srv
.assert_client_handshake()
.expect("handshake")
.recv_settings()
.recv_frame(frames::headers(5)
.request("GET", "https://example.com/")
.eos(),
)
// send the response on a lower-numbered stream, which should be
// implicitly closed.
.send_frame(frames::headers(3).response(200));

let h2 = Client::builder()
.initial_stream_id(5)
.handshake::<_, Bytes>(io)
.expect("handshake")
.and_then(|(mut client, h2)| {
let request = Request::builder()
.method(Method::GET)
.uri("https://example.com/")
.body(())
.unwrap();

let req = client.send_request(request, true)
.unwrap()
.0.then(|res| {
let err = res.unwrap_err();
assert_eq!(
err.to_string(),
"protocol error: unspecific protocol error detected");
Ok::<(), ()>(())
});
// client should see a conn error
let conn = h2.then(|res| {
let err = res.unwrap_err();
assert_eq!(
err.to_string(),
"protocol error: unspecific protocol error detected"
);
Ok::<(), ()>(())
});
conn.unwrap().join(req)
});


h2.join(srv).wait().expect("wait");

}

/*
#[test]
fn send_data_after_headers_eos() {
Expand Down

0 comments on commit 77025d0

Please sign in to comment.