Fix AsyncRead impl for TcpStream
mcches opened this issue · comments
Brett McChesney commented
Is your feature request related to a problem? Please describe.
Yes, turmoil::net::TcpStream
does not behave like tokio::net::TcpStream
.
AsyncRead
is broken if the supplied buf does not have capacity for the next message.
#[test]
fn read_buf_smaller_than_msg() -> Result {
let mut sim = Builder::new().build();
sim.client("server", async {
let listener = bind().await?;
let (mut s, _) = listener.accept().await?;
s.write_u64(1234).await?;
Ok(())
});
sim.client("client", async {
let mut s = TcpStream::connect(("server", PORT)).await?;
let mut buf = [0; 1];
// panic!: buf.len() must fit in remaining()
let _r = s.read(&mut buf).await?;
Ok(())
});
sim.run()
}
See:
Line 137 in 2d0fadd
Describe the solution you'd like
Align turmoil
with tokio::net
.