#![cfg(all(unix, feature = "bus-impl"))]
use std::os::unix::net::UnixStream;
use futures_util::StreamExt;
use ntest::timeout;
use test_log::test;
use zbus::{Connection, Guid, block_on, connection::Builder};
#[test]
#[timeout(15000)]
fn build_message_stream_does_not_drop_pipelined_hello() {
block_on(async {
let (s0, s1) = UnixStream::pair().unwrap();
let guid = Guid::generate();
let server = async {
let mut stream = Builder::unix_stream(s0)
.server(guid)
.unwrap()
.p2p()
.build_message_stream()
.await
.unwrap();
let hello = stream
.next()
.await
.expect("stream terminated unexpectedly")
.unwrap();
assert_eq!(hello.header().member().unwrap().as_str(), "Hello");
let conn = Connection::from(stream);
conn.reply(&hello.header(), &(":1.1",)).await.unwrap();
};
let ((), client) = futures_util::join!(server, Builder::unix_stream(s1).build());
let _client_conn = client.unwrap();
});
}