don't use delays in tests (#5404)

This commit is contained in:
Nikolay Volf
2020-03-29 01:40:00 -07:00
committed by GitHub
parent 1242a7df3c
commit d7ffef43ce
5 changed files with 106 additions and 52 deletions
+22 -1
View File
@@ -31,7 +31,7 @@ pub use sc_transaction_graph as txpool;
pub use crate::api::{FullChainApi, LightChainApi};
use std::{collections::HashMap, sync::Arc, pin::Pin};
use futures::{Future, FutureExt, future::ready, channel::oneshot};
use futures::{prelude::*, future::ready, channel::oneshot};
use parking_lot::Mutex;
use sp_runtime::{
@@ -151,6 +151,27 @@ impl<PoolApi, Block> BasicPool<PoolApi, Block>
Self::with_revalidation_type(options, pool_api, RevalidationType::Full)
}
/// Create new basic transaction pool with provided api, for tests.
#[cfg(test)]
pub fn new_test(
pool_api: Arc<PoolApi>,
) -> (Self, Pin<Box<dyn Future<Output=()> + Send>>, intervalier::BackSignalControl) {
let pool = Arc::new(sc_transaction_graph::Pool::new(Default::default(), pool_api.clone()));
let (revalidation_queue, background_task, notifier) =
revalidation::RevalidationQueue::new_test(pool_api.clone(), pool.clone());
(
BasicPool {
api: pool_api,
pool,
revalidation_queue: Arc::new(revalidation_queue),
revalidation_strategy: Arc::new(Mutex::new(RevalidationStrategy::Always)),
ready_poll: Default::default(),
},
background_task,
notifier,
)
}
/// Create new basic transaction pool with provided api and custom
/// revalidation type.
pub fn with_revalidation_type(