diff --git a/capnp-futures/src/serialize_packed.rs b/capnp-futures/src/serialize_packed.rs index 14ade2762..67ff85be4 100644 --- a/capnp-futures/src/serialize_packed.rs +++ b/capnp-futures/src/serialize_packed.rs @@ -524,7 +524,7 @@ where #[cfg(test)] pub mod test { use crate::serialize::test::{BlockingRead, BlockingWrite}; - use crate::serialize_packed::{PackedRead, PackedWrite}; + use crate::serialize_packed::{try_read_message, PackedRead, PackedWrite}; use capnp::message::ReaderSegments; use futures::{AsyncReadExt, AsyncWriteExt}; use quickcheck::{quickcheck, TestResult}; @@ -691,4 +691,15 @@ pub mod test { fn check_packed_round_trip_async() { quickcheck(round_trip as fn(usize, usize, Vec>) -> TestResult); } + + #[test] + fn read_empty() { + let words = vec![]; + // Before https://github.com/capnproto/capnproto-rust/pull/446 + // this would loop forever. + let message = + futures::executor::block_on(Box::pin(try_read_message(&words[..], Default::default()))) + .expect("reading"); + assert!(message.is_none()); + } }