Add connection window overflow test (#72)

This commit is contained in:
Sean McArthur
2017-09-11 10:17:43 -07:00
committed by Carl Lerche
parent 5c0efcf8c4
commit 460afa41c8
3 changed files with 110 additions and 1 deletions

View File

@@ -34,6 +34,12 @@ pub fn window_update<T>(id: T, sz: u32) -> frame::WindowUpdate
frame::WindowUpdate::new(id.into(), sz)
}
pub fn go_away<T>(id: T) -> MockGoAway
where T: Into<StreamId>,
{
MockGoAway(frame::GoAway::new(id.into(), frame::Reason::NoError))
}
// Headers helpers
pub struct MockHeaders(frame::Headers);
@@ -139,6 +145,35 @@ impl From<MockData> for SendFrame {
}
}
// GoAway helpers
pub struct MockGoAway(frame::GoAway);
impl MockGoAway {
pub fn flow_control(self) -> Self {
MockGoAway(frame::GoAway::new(self.0.last_stream_id(), frame::Reason::FlowControlError))
}
}
impl fmt::Debug for MockGoAway {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
}
impl From<MockGoAway> for Frame {
fn from(src: MockGoAway) -> Self {
Frame::GoAway(src.0)
}
}
impl From<MockGoAway> for SendFrame {
fn from(src: MockGoAway) -> Self {
Frame::GoAway(src.0)
}
}
// ==== "trait alias" for types that are HttpTryFrom and have Debug Errors ====
pub trait HttpTryInto<T> {