mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 14:31:13 +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:
@@ -16,7 +16,6 @@
|
||||
// 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 futures::{executor::LocalPool, task::LocalSpawn, FutureExt};
|
||||
use std::{
|
||||
future::Future,
|
||||
sync::{Arc, Mutex},
|
||||
@@ -316,28 +315,17 @@ where
|
||||
F: FnOnce(Arc<MockClient>) -> Fut + 'static,
|
||||
Fut: Future<Output = ()>,
|
||||
{
|
||||
let mut pool = LocalPool::new();
|
||||
let runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
let client = Arc::new(MockClient::new());
|
||||
|
||||
let client_clone = client.clone();
|
||||
pool.spawner()
|
||||
.spawn_local_obj(
|
||||
async move {
|
||||
let backend = client_clone.backend.clone();
|
||||
MmrGadget::start(
|
||||
client_clone.clone(),
|
||||
backend,
|
||||
MockRuntimeApi::INDEXING_PREFIX.to_vec(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
.boxed_local()
|
||||
.into(),
|
||||
)
|
||||
.unwrap();
|
||||
runtime.spawn(async move {
|
||||
let backend = client_clone.backend.clone();
|
||||
MmrGadget::start(client_clone, backend, MockRuntimeApi::INDEXING_PREFIX.to_vec()).await
|
||||
});
|
||||
|
||||
pool.run_until(async move {
|
||||
async_std::task::sleep(Duration::from_millis(200)).await;
|
||||
runtime.block_on(async move {
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
|
||||
f(client).await
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user