From 329634256a9d2ddadc07b0a73e29bb9a3a7867cf Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 28 May 2024 18:04:46 +0200 Subject: [PATCH] chore: move generators module (#8429) --- Cargo.lock | 2 ++ crates/interfaces/Cargo.toml | 4 +++- crates/interfaces/src/lib.rs | 5 ++++- crates/net/p2p/Cargo.toml | 8 +------- crates/net/p2p/src/test_utils/mod.rs | 3 --- testing/testing-utils/Cargo.toml | 7 +++++-- .../testing-utils/src}/generators.rs | 2 ++ testing/testing-utils/src/lib.rs | 2 ++ 8 files changed, 19 insertions(+), 14 deletions(-) rename {crates/net/p2p/src/test_utils => testing/testing-utils/src}/generators.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index ac41650c8..b19b4d6e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7110,6 +7110,7 @@ dependencies = [ "reth-fs-util", "reth-network-p2p", "reth-storage-errors", + "reth-testing-utils", "thiserror", ] @@ -8072,6 +8073,7 @@ name = "reth-testing-utils" version = "0.2.0-beta.7" dependencies = [ "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=64feb9b)", + "rand 0.8.5", "reth-primitives", "secp256k1 0.28.2", ] diff --git a/crates/interfaces/Cargo.toml b/crates/interfaces/Cargo.toml index 836ddebb5..1c07af335 100644 --- a/crates/interfaces/Cargo.toml +++ b/crates/interfaces/Cargo.toml @@ -18,9 +18,11 @@ reth-fs-util.workspace = true reth-network-p2p.workspace = true reth-storage-errors.workspace = true +reth-testing-utils = { workspace = true, optional = true } + # misc thiserror.workspace = true [features] -test-utils = ["reth-consensus/test-utils", "reth-network-p2p/test-utils"] +test-utils = ["reth-consensus/test-utils", "reth-network-p2p/test-utils", "reth-testing-utils"] clap = ["reth-storage-errors/clap"] \ No newline at end of file diff --git a/crates/interfaces/src/lib.rs b/crates/interfaces/src/lib.rs index 651283bb8..0a649e557 100644 --- a/crates/interfaces/src/lib.rs +++ b/crates/interfaces/src/lib.rs @@ -36,4 +36,7 @@ pub use reth_blockchain_tree_api as blockchain_tree; /// Common test helpers for mocking out Consensus, Downloaders and Header Clients. #[cfg(feature = "test-utils")] -pub use reth_network_p2p::test_utils; +pub mod test_utils { + pub use reth_network_p2p::test_utils::*; + pub use reth_testing_utils::generators; +} diff --git a/crates/net/p2p/Cargo.toml b/crates/net/p2p/Cargo.toml index 34705d78e..0e3146ab6 100644 --- a/crates/net/p2p/Cargo.toml +++ b/crates/net/p2p/Cargo.toml @@ -28,13 +28,7 @@ auto_impl.workspace = true thiserror.workspace = true tracing.workspace = true -secp256k1 = { workspace = true, default-features = false, features = [ - "alloc", - "recovery", - "rand", -], optional = true } parking_lot = { workspace = true, optional = true } -rand = { workspace = true, optional = true } [dev-dependencies] reth-consensus = { workspace = true, features = ["test-utils"] } @@ -45,4 +39,4 @@ tokio = { workspace = true, features = ["full"] } secp256k1 = { workspace = true, features = ["alloc", "recovery", "rand"] } [features] -test-utils = ["reth-consensus/test-utils", "secp256k1", "rand", "parking_lot"] +test-utils = ["reth-consensus/test-utils", "parking_lot"] diff --git a/crates/net/p2p/src/test_utils/mod.rs b/crates/net/p2p/src/test_utils/mod.rs index e56cd8f00..1abd215d0 100644 --- a/crates/net/p2p/src/test_utils/mod.rs +++ b/crates/net/p2p/src/test_utils/mod.rs @@ -2,9 +2,6 @@ mod bodies; mod full_block; mod headers; -/// Generators for different data structures like block headers, block bodies and ranges of those. -pub mod generators; - pub use bodies::*; pub use full_block::*; pub use headers::*; diff --git a/testing/testing-utils/Cargo.toml b/testing/testing-utils/Cargo.toml index 97a4c78df..815976dea 100644 --- a/testing/testing-utils/Cargo.toml +++ b/testing/testing-utils/Cargo.toml @@ -12,6 +12,9 @@ repository.workspace = true workspace = true [dependencies] -secp256k1.workspace = true -alloy-genesis.workspace = true reth-primitives.workspace = true + +alloy-genesis.workspace = true + +secp256k1.workspace = true +rand.workspace = true \ No newline at end of file diff --git a/crates/net/p2p/src/test_utils/generators.rs b/testing/testing-utils/src/generators.rs similarity index 99% rename from crates/net/p2p/src/test_utils/generators.rs rename to testing/testing-utils/src/generators.rs index 8056e90ff..551aa80e4 100644 --- a/crates/net/p2p/src/test_utils/generators.rs +++ b/testing/testing-utils/src/generators.rs @@ -1,3 +1,5 @@ +//! Generators for different data structures like block headers, block bodies and ranges of those. + pub use rand::Rng; use rand::{ distributions::uniform::SampleRange, rngs::StdRng, seq::SliceRandom, thread_rng, SeedableRng, diff --git a/testing/testing-utils/src/lib.rs b/testing/testing-utils/src/lib.rs index 27b54b19e..c593d3064 100644 --- a/testing/testing-utils/src/lib.rs +++ b/testing/testing-utils/src/lib.rs @@ -11,3 +11,5 @@ pub mod genesis_allocator; pub use genesis_allocator::GenesisAllocator; + +pub mod generators;