More tests

This commit is contained in:
Carl Lerche
2017-07-11 20:50:41 -07:00
parent fab9fa8ed2
commit 36a1c6f045
5 changed files with 55 additions and 4 deletions

View File

@@ -23,6 +23,17 @@ macro_rules! assert_user_err {
}};
}
macro_rules! assert_proto_err {
($actual:expr, $err:ident) => {{
use h2::error::{ConnectionError, Reason};
match $actual {
ConnectionError::Proto(e) => assert_eq!(e, Reason::$err),
_ => panic!("unexpected connection error type"),
}
}};
}
#[test]
fn handshake() {
let _ = ::env_logger::init();
@@ -341,8 +352,32 @@ fn invalid_client_stream_id() {
}
#[test]
#[ignore]
fn invalid_server_stream_id() {
let _ = ::env_logger::init();
let mock = mock_io::Builder::new()
.handshake()
// Write GET /
.write(&[
0, 0, 0x10, 1, 5, 0, 0, 0, 1, 0x82, 0x87, 0x41, 0x8B, 0x9D, 0x29,
0xAC, 0x4B, 0x8F, 0xA8, 0xE9, 0x19, 0x97, 0x21, 0xE9, 0x84,
])
.write(SETTINGS_ACK)
// Read response
.read(&[0, 0, 1, 1, 5, 0, 0, 0, 2, 137])
.build();
let h2 = client::handshake(mock)
.wait().unwrap();
// Send the request
let mut request = request::Head::default();
request.uri = "https://http2.akamai.com/".parse().unwrap();
let h2 = h2.send_request(1.into(), request, true).wait().unwrap();
// Get the response
let (err, _) = h2.into_future().wait().unwrap_err();
assert_proto_err!(err, ProtocolError);
}
#[test]