Skip to content

Commit

Permalink
Remove transaction-pool test-helpers feature (paritytech#10571)
Browse files Browse the repository at this point in the history
* 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: paritytech#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>
  • Loading branch information
2 people authored and ark0f committed Feb 27, 2023
1 parent 08ff6e0 commit 217246b
Show file tree
Hide file tree
Showing 12 changed files with 364 additions and 401 deletions.
56 changes: 20 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions client/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "2.0.0" }
thiserror = "1.0.30"
futures = "0.3.16"
intervalier = "0.4.0"
futures-timer = "3.0.2"
log = "0.4.8"
parity-util-mem = { version = "0.10.2", default-features = false, features = ["primitive-types"] }
parking_lot = "0.11.2"
Expand Down Expand Up @@ -48,6 +48,3 @@ criterion = "0.3"
[[bench]]
name = "basics"
harness = false

[features]
test-helpers = []
12 changes: 6 additions & 6 deletions client/transaction-pool/benches/basics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use futures::{
executor::block_on,
future::{ready, Ready},
};
use sc_transaction_pool::{test_helpers::*, *};
use sc_transaction_pool::*;
use sp_core::blake2_256;
use sp_runtime::{
generic::BlockId,
traits::Block as BlockT,
traits::{Block as BlockT, NumberFor},
transaction_validity::{
InvalidTransaction, TransactionSource, TransactionTag as Tag, TransactionValidity,
ValidTransaction,
Expand Down Expand Up @@ -63,7 +63,7 @@ impl ChainApi for TestApi {
&self,
at: &BlockId<Self::Block>,
_source: TransactionSource,
uxt: test_helpers::ExtrinsicFor<Self>,
uxt: <Self::Block as BlockT>::Extrinsic,
) -> Self::ValidationFuture {
let nonce = uxt.transfer().nonce;
let from = uxt.transfer().from.clone();
Expand All @@ -89,7 +89,7 @@ impl ChainApi for TestApi {
fn block_id_to_number(
&self,
at: &BlockId<Self::Block>,
) -> Result<Option<test_helpers::NumberFor<Self>>, Self::Error> {
) -> Result<Option<NumberFor<Self::Block>>, Self::Error> {
Ok(match at {
BlockId::Number(num) => Some(*num),
BlockId::Hash(_) => None,
Expand All @@ -99,14 +99,14 @@ impl ChainApi for TestApi {
fn block_id_to_hash(
&self,
at: &BlockId<Self::Block>,
) -> Result<Option<test_helpers::BlockHash<Self>>, Self::Error> {
) -> Result<Option<<Self::Block as BlockT>::Hash>, Self::Error> {
Ok(match at {
BlockId::Number(num) => Some(H256::from_low_u64_be(*num)).into(),
BlockId::Hash(_) => None,
})
}

fn hash_and_length(&self, uxt: &test_helpers::ExtrinsicFor<Self>) -> (H256, usize) {
fn hash_and_length(&self, uxt: &<Self::Block as BlockT>::Extrinsic) -> (H256, usize) {
let encoded = uxt.encode();
(blake2_256(&encoded).into(), encoded.len())
}
Expand Down
Loading

0 comments on commit 217246b

Please sign in to comment.