1 use tokio::net::TcpStream;
2 use tokio::sync::oneshot;
3 use tokio::time::{timeout, Duration};
4 
5 use futures::executor::block_on;
6 
7 use std::net::TcpListener;
8 
9 #[test]
10 #[should_panic(expected = "no timer running")]
panics_when_no_timer()11 fn panics_when_no_timer() {
12     block_on(timeout_value());
13 }
14 
15 #[test]
16 #[should_panic(expected = "no reactor running")]
panics_when_no_reactor()17 fn panics_when_no_reactor() {
18     let srv = TcpListener::bind("127.0.0.1:0").unwrap();
19     let addr = srv.local_addr().unwrap();
20     block_on(TcpStream::connect(&addr)).unwrap();
21 }
22 
timeout_value()23 async fn timeout_value() {
24     let (_tx, rx) = oneshot::channel::<()>();
25     let dur = Duration::from_millis(20);
26     let _ = timeout(dur, rx).await;
27 }
28