Skip to content

Commit

Permalink
move test utils to reth_network::test_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Jan 17, 2023
1 parent 0f6bfc1 commit 5892531
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 78 deletions.
21 changes: 0 additions & 21 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ members = [
"crates/net/nat",
"crates/net/network-api",
"crates/net/network",
"crates/net/test-utils",
"crates/net/ipc",
"crates/net/rpc",
"crates/net/rpc-api",
Expand Down
7 changes: 5 additions & 2 deletions crates/net/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@ secp256k1 = { version = "0.24", features = [
"recovery",
] }

enr = { version = "0.7.0", features = ["serde", "rust-secp256k1"], optional = true }
ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false, optional = true }
tempfile = { version = "3.3", optional = true }

[dev-dependencies]
# reth
reth-discv4 = { path = "../discv4", features = ["test-utils"] }
reth-interfaces = { path = "../../interfaces", features = ["test-utils"] }
reth-provider = { path = "../../storage/provider", features = ["test-utils"] }
reth-tracing = { path = "../../tracing" }
reth-transaction-pool = { path = "../../transaction-pool", features = ["test-utils"] }
reth-net-test-utils = { path = "../test-utils" }

ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
ethers-providers = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
Expand All @@ -85,4 +88,4 @@ serial_test = "0.10"

[features]
serde = ["dep:serde", "dep:humantime-serde"]
test-utils = []
test-utils = ["reth-provider/test-utils", "dep:enr", "dep:ethers-core", "dep:tempfile"]
4 changes: 4 additions & 0 deletions crates/net/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
//!
//! - `serde`: Enable serde support for configuration types.

#[cfg(any(test, feature = "test-utils"))]
/// Common helpers for network testing.
pub mod test_utils;

mod builder;
mod cache;
pub mod config;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#![warn(missing_docs, unreachable_pub)]
#![deny(unused_must_use, rust_2018_idioms)]
#![doc(test(
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
))]

//! Internal helpers for network testing.
//! Common helpers for network testing.

mod init;
mod testnet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use futures::{FutureExt, StreamExt};
use pin_project::pin_project;
use reth_eth_wire::DisconnectReason;
use reth_network::{
use crate::{
error::NetworkError, eth_requests::EthRequestHandler, NetworkConfig, NetworkEvent,
NetworkHandle, NetworkManager,
};
Expand Down Expand Up @@ -355,3 +355,4 @@ impl NetworkEventStream {
}
}
}

2 changes: 1 addition & 1 deletion crates/net/network/tests/it/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use reth_interfaces::{
sync::{SyncState, SyncStateUpdater},
};
use reth_net_common::ban_list::BanList;
use reth_net_test_utils::{
use reth_network::test_utils::{
enr_to_peer_id, unused_tcp_udp, NetworkEventStream, PeerConfig, Testnet, GETH_TIMEOUT,
};
use reth_network::{NetworkConfig, NetworkEvent, NetworkManager, PeersConfig};
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/tests/it/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use reth_interfaces::p2p::{
bodies::client::BodiesClient,
headers::client::{HeadersClient, HeadersRequest},
};
use reth_net_test_utils::{NetworkEventStream, Testnet};
use reth_network::test_utils::{NetworkEventStream, Testnet};
use reth_network_api::NetworkInfo;
use reth_primitives::{
Block, Bytes, Header, HeadersDirection, Signature, Transaction, TransactionKind,
Expand Down
40 changes: 0 additions & 40 deletions crates/net/test-utils/Cargo.toml

This file was deleted.

3 changes: 1 addition & 2 deletions crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ reth-consensus = { path = "../consensus" }
reth-cli-utils = { path = "../cli/utils" }
reth-interfaces = { path = "../interfaces" }
reth-downloaders = { path = "../net/downloaders" }
reth-network = { path = "../net/network" }
reth-net-test-utils = { path = "../net/test-utils" }
reth-network = { path = "../net/network", features = ["test-utils"] }
reth-eth-wire = { path = "../net/eth-wire" }
reth-executor = { path = "../executor" }
reth-provider = { path = "../storage/provider"}
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/src/clique.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use ethers_signers::{LocalWallet, Signer, Wallet};
use reth_cli_utils::chainspec::{ChainSpecification, Genesis as RethGenesis};
use reth_consensus::Config as ConsensusConfig;
use reth_eth_wire::{EthVersion, Status};
use reth_net_test_utils::{enr_to_peer_id, unused_port};
use reth_network::test_utils::{enr_to_peer_id, unused_port};
use reth_primitives::{
proofs::genesis_state_root, Chain, ForkHash, ForkId, Header, PeerId, H160, INITIAL_BASE_FEE,
};
Expand Down
3 changes: 1 addition & 2 deletions crates/tests/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use ethers_providers::Middleware;
use reth_cli_utils::init::init_db;
use reth_consensus::BeaconConsensus;
use reth_db::mdbx::{Env, WriteMap};
use reth_net_test_utils::{unused_tcp_udp, NetworkEventStream, GETH_TIMEOUT};
use reth_network::{NetworkConfig, NetworkManager};
use reth_network::{NetworkConfig, NetworkManager, test_utils::{unused_tcp_udp, NetworkEventStream, GETH_TIMEOUT}};
use reth_primitives::{PeerId, H256};
use reth_provider::test_utils::NoopProvider;
use secp256k1::SecretKey;
Expand Down

0 comments on commit 5892531

Please sign in to comment.