// Make sure that the ReplyContext aborts on Drop of no reply was sent. use std::thread; use ump_ng::{channel, Error, MsgType}; #[test] fn sync_expect_noreply() { let (server, client) = channel::<(), String, String, ()>(); let server_thread = thread::spawn(move || { // Wait for data to arrive from a client let MsgType::Request(_, rctx) = server.wait().unwrap() else { panic!("Unexpected message operation type"); }; // Don't do this. drop(rctx); }); let msg = String::from("Client"); let reply = client.req(msg); match reply { Err(Error::NoReply) => { // This is the expected error } _ => { panic!("Unexpected return value"); } } server_thread.join().unwrap(); } #[test] fn async_expect_noreply() { let tokrt = tokio::runtime::Runtime::new().unwrap(); let (server, client) = channel::<(), String, String, ()>(); let server_thread = thread::spawn(move || { // Wait for data to arrive from a client let MsgType::Request(_, rctx) = server.wait().unwrap() else { panic!("Unexpected message operation type"); }; // Don't do this. drop(rctx); }); tokrt.block_on(async { let msg = String::from("Client"); let reply = client.areq(msg).await; match reply { Err(Error::NoReply) => { // This is the expected error } _ => { panic!("Unexpected return value"); } } }); server_thread.join().unwrap(); } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :