Skip to content

Commit

Permalink
chore: remove explicit initialization of env_logger in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vbar committed Dec 4, 2024
1 parent 69d6bb7 commit fa93524
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
22 changes: 15 additions & 7 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const-decoder = "0.3.0"
const_format = "0.2.31"
criterion = "0.5.1"
dashmap = "6.1"
env_logger = "0.10.0"
fake = "2.8.0"
ff = "0.13"
flate2 = "1.0.27"
Expand Down Expand Up @@ -131,7 +130,7 @@ starknet_api = { git = "https://github.com/eqlabs/sequencer", branch = "eqlabs/m
starknet-types-core = "=0.1.5"
syn = "1.0"
tempfile = "3.8"
test-log = { version = "0.2.12", default-features = false }
test-log = { version = "0.2.12", features = ["trace"] }
thiserror = "1.0.48"
time = "0.3.36"
tokio = "1.37.0"
Expand Down
3 changes: 1 addition & 2 deletions crates/p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ zeroize = { workspace = true }

[dev-dependencies]
clap = { workspace = true, features = ["derive", "env", "wrap_help"] }
env_logger = { workspace = true }
hex = { workspace = true }
rand = { workspace = true }
rstest = { workspace = true }
tagged = { path = "../tagged" }
tagged-debug-derive = { path = "../tagged-debug-derive" }
test-log = { workspace = true, features = ["trace"] }
test-log = { workspace = true }
tokio = { workspace = true, features = ["test-util"] }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
6 changes: 0 additions & 6 deletions crates/p2p/src/client/peer_agnostic/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ async fn make_header_stream(
#[case] responses: Vec<Result<(TestPeer, Vec<BlockHeadersResponse>), TestPeer>>,
#[case] expected_stream: Vec<(TestPeer, SignedBlockHeader)>,
) {
let _ = env_logger::builder().is_test(true).try_init();

for (reverse, direction) in [(false, "forward"), (true, "backward")] {
let (peers, responses) = unzip_fixtures(responses.clone());
let get_peers = move || {
Expand Down Expand Up @@ -295,7 +293,6 @@ async fn make_transaction_stream(
#[case] num_txns_per_block: Vec<usize>,
#[case] expected_stream: Vec<Result<(TestPeer, Vec<TestTxn>), ()>>,
) {
let _ = env_logger::builder().is_test(true).try_init();
let (peers, responses) = unzip_fixtures(responses);
let get_peers = move || {
let peers = peers.clone();
Expand Down Expand Up @@ -518,7 +515,6 @@ async fn make_state_diff_stream(
#[case] state_diff_len_per_block: Vec<usize>,
#[case] expected_stream: Vec<Result<(TestPeer, StateUpdateData), ()>>,
) {
let _ = env_logger::builder().is_test(true).try_init();
let (peers, responses) = unzip_fixtures(responses);
let get_peers = move || {
let peers = peers.clone();
Expand Down Expand Up @@ -713,7 +709,6 @@ async fn make_class_definition_stream(
#[case] declared_classes_per_block: Vec<usize>,
#[case] expected_stream: Vec<Result<(TestPeer, ClassDefinition), ()>>,
) {
let _ = env_logger::builder().is_test(true).try_init();
let (peers, responses) = unzip_fixtures(responses);
let get_peers = move || {
let peers = peers.clone();
Expand Down Expand Up @@ -904,7 +899,6 @@ async fn make_event_stream(
#[case] events_per_block: Vec<usize>,
#[case] expected_stream: Vec<Result<(TestPeer, TaggedEventsForBlockByTransaction), ()>>,
) {
let _ = env_logger::builder().is_test(true).try_init();
let (peers, responses) = unzip_fixtures(responses);
let get_peers = move || {
let peers = peers.clone();
Expand Down
8 changes: 0 additions & 8 deletions crates/p2p/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ async fn client_to_server() -> (TestPeer, TestPeer) {

#[test_log::test(tokio::test)]
async fn dial() {
let _ = env_logger::builder().is_test(true).try_init();
// tokio::time::pause() does not make a difference
let mut peer1 = TestPeer::default();
let mut peer2 = TestPeer::default();
Expand All @@ -119,8 +118,6 @@ async fn dial() {

#[test_log::test(tokio::test)]
async fn disconnect() {
let _ = env_logger::builder().is_test(true).try_init();

let mut peer1 = TestPeer::default();
let mut peer2 = TestPeer::default();

Expand Down Expand Up @@ -157,8 +154,6 @@ async fn disconnect() {

#[test_log::test(tokio::test)]
async fn periodic_bootstrap() {
let _ = env_logger::builder().is_test(true).try_init();

const BOOTSTRAP_PERIOD: Duration = Duration::from_millis(500);
let cfg = Config {
bootstrap_period: Some(BOOTSTRAP_PERIOD),
Expand Down Expand Up @@ -785,7 +780,6 @@ async fn rate_limit() {
#[case::client_to_server(client_to_server().await)]
#[test_log::test(tokio::test)]
async fn provide_capability(#[case] peers: (TestPeer, TestPeer)) {
let _ = env_logger::builder().is_test(true).try_init();
let (peer1, peer2) = peers;

let mut peer1_started_providing = filter_events(peer1.event_receiver, |event| match event {
Expand All @@ -811,7 +805,6 @@ async fn provide_capability(#[case] peers: (TestPeer, TestPeer)) {
#[case::client_to_server(client_to_server().await)]
#[test_log::test(tokio::test)]
async fn subscription_and_propagation(#[case] peers: (TestPeer, TestPeer)) {
let _ = env_logger::builder().is_test(true).try_init();
let (peer1, peer2) = peers;

let mut peer2_subscribed_to_peer1 = filter_events(peer1.event_receiver, |event| match event {
Expand Down Expand Up @@ -855,7 +848,6 @@ mod successful_sync {
#[case::client_to_server(client_to_server().await)]
#[test_log::test(tokio::test)]
async fn $test_name(#[case] peers: (TestPeer, TestPeer)) {
let _ = env_logger::builder().is_test(true).try_init();
let (peer1, peer2) = peers;
// Fake some request for peer2 to send to peer1
let expected_request = Faker.fake::<$req_type>();
Expand Down

0 comments on commit fa93524

Please sign in to comment.