update to tokio 0.3 (#491)

This commit is contained in:
João Oliveira
2020-10-23 18:45:09 +01:00
committed by GitHub
parent 676a068fd4
commit cbbdd305b1
11 changed files with 68 additions and 61 deletions

View File

@@ -11,4 +11,4 @@ edition = "2018"
h2-support = { path = "../h2-support" }
tracing = "0.1.13"
futures = { version = "0.3", default-features = false, features = ["alloc"] }
tokio = { version = "0.2", features = ["macros", "tcp"] }
tokio = { version = "0.3", features = ["macros", "net", "rt", "io-util"] }

View File

@@ -190,6 +190,7 @@ async fn read_continuation_frames() {
#[tokio::test]
async fn update_max_frame_len_at_rest() {
use futures::StreamExt;
use tokio::io::AsyncReadExt;
h2_support::trace_init!();
// TODO: add test for updating max frame length in flight as well?
@@ -211,6 +212,10 @@ async fn update_max_frame_len_at_rest() {
codec.next().await.unwrap().unwrap_err().to_string(),
"frame with invalid size"
);
// drain codec buffer
let mut buf = Vec::new();
codec.get_mut().read_to_end(&mut buf).await.unwrap();
}
#[tokio::test]

View File

@@ -972,7 +972,7 @@ async fn settings_lowered_capacity_returns_capacity_to_connection() {
//
// A timeout is used here to avoid blocking forever if there is a
// failure
let result = select(rx2, tokio::time::delay_for(Duration::from_secs(5))).await;
let result = select(rx2, tokio::time::sleep(Duration::from_secs(5))).await;
if let Either::Right((_, _)) = result {
panic!("Timed out");
}
@@ -1004,7 +1004,7 @@ async fn settings_lowered_capacity_returns_capacity_to_connection() {
});
// Wait for server handshake to complete.
let result = select(rx1, tokio::time::delay_for(Duration::from_secs(5))).await;
let result = select(rx1, tokio::time::sleep(Duration::from_secs(5))).await;
if let Either::Right((_, _)) = result {
panic!("Timed out");
}

View File

@@ -26,8 +26,8 @@ impl Server {
{
let mk_data = Arc::new(mk_data);
let mut rt = tokio::runtime::Runtime::new().unwrap();
let mut listener = rt
let rt = tokio::runtime::Runtime::new().unwrap();
let listener = rt
.block_on(TcpListener::bind(SocketAddr::from(([127, 0, 0, 1], 0))))
.unwrap();
let addr = listener.local_addr().unwrap();
@@ -140,7 +140,7 @@ fn hammer_client_concurrency() {
})
});
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(tcp);
println!("...done");
}