use super::*;
#[tokio::test(flavor = "current_thread")]
async fn round_trip_frame() {
let stream = MemoryStream::default();
let producer = stream.clone();
let push = tokio::spawn(async move {
tokio::task::yield_now().await;
producer.push_inbound(b"hello".to_vec());
});
let body = stream.read_message().await.unwrap();
assert_eq!(body, b"hello");
push.await.unwrap();
stream.write_all(b"out").await.unwrap();
assert_eq!(stream.captured(), b"out");
stream.close();
let err = stream.read_message().await.unwrap_err();
assert!(
matches!(err, Error::Io(ref e) if e.kind() == std::io::ErrorKind::UnexpectedEof),
"unexpected error: {err:?}"
);
}