mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 08:47:57 +00:00
Upgrade tokio to 1.22.0 and replace async-std with tokio (#12646)
* Replace deprecated libp2p feature specs with correct ones * Bump tokio to 1.21.2 * Replace async-std libp2p primitives with tokio ones * minor: rustfmt * Fix TestNet to run initialization in the tokio context * Convert telemetry test from async-std to tokio * Convert notifications tests from async-std to tokio * Convert chain sync tests from async-std to tokio * Ditch async-std completely * Make executor mandatory * Bump tokio to 1.22.0 * minor: rustfmt * Explicitly use tokio runtime in tests * Move more tests to explicit tokio runtime * Explicitly set multithreaded runtime in tokio test * minor: rustfmt * minor: fix comment * Replace async-std with tokio in MMR tests
This commit is contained in:
@@ -26,7 +26,7 @@ use std::process;
|
||||
pub mod common;
|
||||
pub mod websocket_server;
|
||||
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn telemetry_works() {
|
||||
let config = websocket_server::Config {
|
||||
capacity: 1,
|
||||
@@ -38,7 +38,7 @@ async fn telemetry_works() {
|
||||
|
||||
let addr = server.local_addr().unwrap();
|
||||
|
||||
let server_task = async_std::task::spawn(async move {
|
||||
let server_task = tokio::spawn(async move {
|
||||
loop {
|
||||
use websocket_server::Event;
|
||||
match server.next_event().await {
|
||||
@@ -78,7 +78,7 @@ async fn telemetry_works() {
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
server_task.await;
|
||||
server_task.await.expect("server task panicked");
|
||||
|
||||
assert!(substrate.try_wait().unwrap().is_none(), "the process should still be running");
|
||||
|
||||
|
||||
@@ -16,11 +16,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use async_std::net::{TcpListener, TcpStream};
|
||||
use core::pin::Pin;
|
||||
use futures::prelude::*;
|
||||
use soketto::handshake::{server::Response, Server};
|
||||
use std::{io, net::SocketAddr};
|
||||
use tokio::net::{TcpListener, TcpStream};
|
||||
use tokio_util::compat::{Compat, TokioAsyncReadCompatExt};
|
||||
|
||||
/// Configuration for a [`WsServer`].
|
||||
pub struct Config {
|
||||
@@ -71,8 +72,12 @@ pub struct WsServer {
|
||||
negotiating: stream::FuturesUnordered<
|
||||
Pin<
|
||||
Box<
|
||||
dyn Future<Output = Result<Server<'static, TcpStream>, Box<dyn std::error::Error>>>
|
||||
+ Send,
|
||||
dyn Future<
|
||||
Output = Result<
|
||||
Server<'static, Compat<TcpStream>>,
|
||||
Box<dyn std::error::Error>,
|
||||
>,
|
||||
> + Send,
|
||||
>,
|
||||
>,
|
||||
>,
|
||||
@@ -120,7 +125,7 @@ impl WsServer {
|
||||
let pending_incoming = self.pending_incoming.take().expect("no pending socket");
|
||||
|
||||
self.negotiating.push(Box::pin(async move {
|
||||
let mut server = Server::new(pending_incoming);
|
||||
let mut server = Server::new(pending_incoming.compat());
|
||||
|
||||
let websocket_key = match server.receive_request().await {
|
||||
Ok(req) => req.key(),
|
||||
|
||||
Reference in New Issue
Block a user