diff --git a/Cargo.toml b/Cargo.toml index 7fac83b9a2..36d9766e88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,11 +25,11 @@ smallvec = { version = "1.5.1", default-features = false } thiserror = "1.0.22" # used for tests and HTTP/hyper -# the features are used only for tests but enabled because `dev-depedencies` are leaked into dependencies. -tokio = { version = "0.2.24", features = ["stream", "rt-threaded", "macros"], optional = true } +# the features are used only for tests but enabled because `dev-dependencies` are leaked into dependencies. +tokio = { version = "1.0", features = ["net", "rt-multi-thread", "macros"], optional = true } # HTTP-related dependencies -hyper = { version = "0.13.9", features = ["stream"], optional = true } +hyper = { version = "0.14", features = ["stream", "client", "server", "http1", "http2", "tcp"], optional = true } unicase = { version = "2.6.0", optional = true } # WS-related dependencies diff --git a/src/http/transport/background.rs b/src/http/transport/background.rs index 3e4221bab8..ab909b5f99 100644 --- a/src/http/transport/background.rs +++ b/src/http/transport/background.rs @@ -83,7 +83,7 @@ impl BackgroundHttp { // Because hyper can only be polled through tokio, we spawn it in a background thread. thread::Builder::new().name("jsonrpsee-hyper-server".to_string()).spawn(move || { - let mut runtime = match tokio::runtime::Builder::new().basic_scheduler().enable_all().build() { + let runtime = match tokio::runtime::Builder::new_current_thread().enable_all().build() { Ok(r) => r, Err(err) => { log::error!("Failed to initialize tokio runtime in HTTP JSON-RPC server: {}", err); diff --git a/test-utils/Cargo.toml b/test-utils/Cargo.toml index 9e2ffde061..4b509909f6 100644 --- a/test-utils/Cargo.toml +++ b/test-utils/Cargo.toml @@ -10,10 +10,10 @@ edition = "2018" [dependencies] async-std = "1.8.0" futures = "0.3.8" -hyper = "0.13.9" +hyper = "0.14" log = "0.4.11" serde = { version = "1.0.118", default-features = false, features = ["derive"] } serde_json = "1.0.60" soketto = "0.4.2" -tokio = { version = "0.2.24", features = ["dns", "stream", "tcp", "rt-threaded", "macros"] } -tokio-util = { version = "0.3.1", features = ["compat"] } +tokio = { version = "1.0", features = ["net", "rt-multi-thread", "macros", "time"] } +tokio-util = { version = "0.6", features = ["compat"] } diff --git a/test-utils/src/types.rs b/test-utils/src/types.rs index 036ccb98fc..aa8d1dc75f 100644 --- a/test-utils/src/types.rs +++ b/test-utils/src/types.rs @@ -9,7 +9,7 @@ use soketto::handshake::{server::Response, Server}; use std::net::SocketAddr; use std::time::Duration; use tokio::net::TcpStream; -use tokio_util::compat::{Compat, Tokio02AsyncReadCompatExt}; +use tokio_util::compat::{Compat, TokioAsyncReadCompatExt}; pub use hyper::{Body, HeaderMap, StatusCode, Uri}; @@ -183,7 +183,7 @@ async fn connection_task(socket: async_std::net::TcpStream, mode: ServerMode, mu loop { let next_ws = ws_stream.next().fuse(); let next_exit = exit.next().fuse(); - let time_out = tokio::time::delay_for(Duration::from_secs(1)).fuse(); + let time_out = tokio::time::sleep(Duration::from_secs(1)).fuse(); futures::pin_mut!(time_out, next_exit, next_ws); futures::select! { diff --git a/tests/helpers.rs b/tests/helpers.rs index d06dedf2b6..dade37a968 100644 --- a/tests/helpers.rs +++ b/tests/helpers.rs @@ -36,7 +36,7 @@ use futures::future::FutureExt; pub fn websocket_server(server_started: Sender) { std::thread::spawn(move || { - let mut rt = tokio::runtime::Runtime::new().unwrap(); + let rt = tokio::runtime::Runtime::new().unwrap(); let server = rt.block_on(WsServer::new("127.0.0.1:0")).unwrap(); let mut sub_hello = @@ -54,7 +54,7 @@ pub fn websocket_server(server_started: Sender) { } .fuse(); - let timeout = tokio::time::delay_for(Duration::from_millis(100)).fuse(); + let timeout = tokio::time::sleep(Duration::from_millis(100)).fuse(); futures::pin_mut!(hello_fut, timeout); futures::select! { _ = hello_fut => (), @@ -70,7 +70,7 @@ pub fn websocket_server(server_started: Sender) { pub fn websocket_server_with_wait_period(server_started: Sender, wait: Receiver<()>) { std::thread::spawn(move || { - let mut rt = tokio::runtime::Runtime::new().unwrap(); + let rt = tokio::runtime::Runtime::new().unwrap(); let server = rt.block_on(WsServer::new("127.0.0.1:0")).unwrap(); let mut respond = server.register_method("say_hello".to_owned()).unwrap(); @@ -88,7 +88,7 @@ pub fn websocket_server_with_wait_period(server_started: Sender, wai pub fn http_server(server_started: Sender) { std::thread::spawn(move || { - let mut rt = tokio::runtime::Runtime::new().unwrap(); + let rt = tokio::runtime::Runtime::new().unwrap(); let server = rt.block_on(HttpServer::new("127.0.0.1:0", HttpConfig::default())).unwrap(); server_started.send(*server.local_addr()).unwrap();