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:
Dmitry Markin
2022-12-05 11:18:46 +03:00
committed by GitHub
parent 1943e25cb9
commit 5eb84f9cc6
60 changed files with 747 additions and 634 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ log = "0.4.17"
parity-scale-codec = "3.0.0"
parking_lot = "0.12.1"
tempfile = "3.1.0"
tokio = { version = "1.17.0", features = ["time"] }
tokio = { version = "1.22.0", features = ["time"] }
sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" }
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
sc-client-db = { version = "0.10.0-dev", default-features = false, path = "../../db" }
+45 -38
View File
@@ -302,48 +302,55 @@ where
full: impl Iterator<Item = impl FnOnce(Configuration) -> Result<(F, U), Error>>,
authorities: impl Iterator<Item = (String, impl FnOnce(Configuration) -> Result<(F, U), Error>)>,
) {
let handle = self.runtime.handle().clone();
self.runtime.block_on(async {
let handle = self.runtime.handle().clone();
for (key, authority) in authorities {
let node_config = node_config(
self.nodes,
&self.chain_spec,
Role::Authority,
handle.clone(),
Some(key),
self.base_port,
temp,
);
let addr = node_config.network.listen_addresses.first().unwrap().clone();
let (service, user_data) =
authority(node_config).expect("Error creating test node service");
for (key, authority) in authorities {
let node_config = node_config(
self.nodes,
&self.chain_spec,
Role::Authority,
handle.clone(),
Some(key),
self.base_port,
temp,
);
let addr = node_config.network.listen_addresses.first().unwrap().clone();
let (service, user_data) =
authority(node_config).expect("Error creating test node service");
handle.spawn(service.clone().map_err(|_| ()));
let addr =
MultiaddrWithPeerId { multiaddr: addr, peer_id: service.network().local_peer_id() };
self.authority_nodes.push((self.nodes, service, user_data, addr));
self.nodes += 1;
}
handle.spawn(service.clone().map_err(|_| ()));
let addr = MultiaddrWithPeerId {
multiaddr: addr,
peer_id: service.network().local_peer_id(),
};
self.authority_nodes.push((self.nodes, service, user_data, addr));
self.nodes += 1;
}
for full in full {
let node_config = node_config(
self.nodes,
&self.chain_spec,
Role::Full,
handle.clone(),
None,
self.base_port,
temp,
);
let addr = node_config.network.listen_addresses.first().unwrap().clone();
let (service, user_data) = full(node_config).expect("Error creating test node service");
for full in full {
let node_config = node_config(
self.nodes,
&self.chain_spec,
Role::Full,
handle.clone(),
None,
self.base_port,
temp,
);
let addr = node_config.network.listen_addresses.first().unwrap().clone();
let (service, user_data) =
full(node_config).expect("Error creating test node service");
handle.spawn(service.clone().map_err(|_| ()));
let addr =
MultiaddrWithPeerId { multiaddr: addr, peer_id: service.network().local_peer_id() };
self.full_nodes.push((self.nodes, service, user_data, addr));
self.nodes += 1;
}
handle.spawn(service.clone().map_err(|_| ()));
let addr = MultiaddrWithPeerId {
multiaddr: addr,
peer_id: service.network().local_peer_id(),
};
self.full_nodes.push((self.nodes, service, user_data, addr));
self.nodes += 1;
}
});
}
}