mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +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:
@@ -201,7 +201,7 @@ mod tests {
|
||||
let a2 = client.import_block(&BlockId::Hash(a1.hash()), b"a2", Some(1)).await;
|
||||
|
||||
client.finalize_block(a1.hash(), Some(1));
|
||||
async_std::task::sleep(Duration::from_millis(200)).await;
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
// expected finalized heads: a1
|
||||
client.assert_canonicalized(&[&a1]);
|
||||
client.assert_not_pruned(&[&a2]);
|
||||
@@ -221,7 +221,7 @@ mod tests {
|
||||
let a6 = client.import_block(&BlockId::Hash(a5.hash()), b"a6", Some(2)).await;
|
||||
|
||||
client.finalize_block(a5.hash(), Some(2));
|
||||
async_std::task::sleep(Duration::from_millis(200)).await;
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
// expected finalized heads: a4, a5
|
||||
client.assert_canonicalized(&[&a4, &a5]);
|
||||
client.assert_not_pruned(&[&a6]);
|
||||
@@ -240,7 +240,7 @@ mod tests {
|
||||
// Simulate the case where the runtime says that there are 2 mmr_blocks when in fact
|
||||
// there is only 1.
|
||||
client.finalize_block(a1.hash(), Some(2));
|
||||
async_std::task::sleep(Duration::from_millis(200)).await;
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
// expected finalized heads: -
|
||||
client.assert_not_canonicalized(&[&a1]);
|
||||
});
|
||||
|
||||
@@ -228,7 +228,7 @@ mod tests {
|
||||
let d5 = client.import_block(&BlockId::Hash(d4.hash()), b"d5", Some(4)).await;
|
||||
|
||||
client.finalize_block(a3.hash(), Some(3));
|
||||
async_std::task::sleep(Duration::from_millis(200)).await;
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
// expected finalized heads: a1, a2, a3
|
||||
client.assert_canonicalized(&[&a1, &a2, &a3]);
|
||||
// expected stale heads: c1
|
||||
@@ -236,7 +236,7 @@ mod tests {
|
||||
client.assert_pruned(&[&c1, &b1]);
|
||||
|
||||
client.finalize_block(d5.hash(), None);
|
||||
async_std::task::sleep(Duration::from_millis(200)).await;
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
// expected finalized heads: d4, d5,
|
||||
client.assert_canonicalized(&[&d4, &d5]);
|
||||
// expected stale heads: b1, b2, b3, a4
|
||||
|
||||
@@ -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