Files
h2/tests/ping_pong.rs
Sean McArthur f8efb053b9 split Client into (Client, Connection) (#107)
The Connection type is a `Future` that drives all of the IO of the
client connection.

The Client type is separate, and is used to send requests into the
connection.
2017-09-28 16:55:12 -07:00

37 lines
846 B
Rust

#[macro_use]
pub mod support;
use support::prelude::*;
#[test]
fn recv_single_ping() {
let _ = ::env_logger::init();
let (m, mock) = mock::new();
// Create the handshake
let h2 = Client::handshake(m)
.unwrap()
.and_then(|(_, conn)| conn.unwrap());
let mock = mock.assert_client_handshake()
.unwrap()
.and_then(|(_, mut mock)| {
let frame = frame::Ping::new();
mock.send(frame.into()).unwrap();
mock.into_future().unwrap()
})
.and_then(|(frame, _)| {
let pong = assert_ping!(frame.unwrap());
// Payload is correct
assert_eq!(*pong.payload(), <[u8; 8]>::default());
// Is ACK
assert!(pong.is_ack());
Ok(())
});
let _ = h2.join(mock).wait().unwrap();
}