Remove transaction-pool test-helpers feature (#10571)

* Remove transaction-pool `test-helpers` feature

`test-helpers` feature is a bad idea in general, because once the feature is enabled somewhere in
the workspace, it is enabled anywhere. While removing the feature, the tests were also rewritten to
get rid off other "only test" related code.

Contributes towards: https://github.com/paritytech/substrate/issues/9727

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Fix benches

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
Bastian Köcher
2022-01-03 16:08:42 +01:00
committed by GitHub
parent cc70518629
commit 424ddf33ee
12 changed files with 363 additions and 400 deletions
+6 -19
View File
@@ -23,20 +23,12 @@
#![warn(unused_extern_crates)]
mod api;
pub mod error;
mod graph;
mod metrics;
mod revalidation;
pub mod error;
/// Common types for testing the transaction pool
#[cfg(feature = "test-helpers")]
pub mod test_helpers {
pub use super::{
graph::{BlockHash, ChainApi, ExtrinsicFor, NumberFor, Pool},
revalidation::RevalidationQueue,
};
}
#[cfg(test)]
mod tests;
pub use crate::api::FullChainApi;
use futures::{
@@ -170,13 +162,10 @@ where
PoolApi: graph::ChainApi<Block = Block> + 'static,
{
/// Create new basic transaction pool with provided api, for tests.
#[cfg(feature = "test-helpers")]
pub fn new_test(
pool_api: Arc<PoolApi>,
) -> (Self, Pin<Box<dyn Future<Output = ()> + Send>>, intervalier::BackSignalControl) {
pub fn new_test(pool_api: Arc<PoolApi>) -> (Self, Pin<Box<dyn Future<Output = ()> + Send>>) {
let pool = Arc::new(graph::Pool::new(Default::default(), true.into(), pool_api.clone()));
let (revalidation_queue, background_task, notifier) =
revalidation::RevalidationQueue::new_test(pool_api.clone(), pool.clone());
let (revalidation_queue, background_task) =
revalidation::RevalidationQueue::new_background(pool_api.clone(), pool.clone());
(
Self {
api: pool_api,
@@ -187,7 +176,6 @@ where
metrics: Default::default(),
},
background_task,
notifier,
)
}
@@ -237,7 +225,6 @@ where
}
/// Get access to the underlying api
#[cfg(feature = "test-helpers")]
pub fn api(&self) -> &PoolApi {
&self.api
}