From 4d946d970814e8cd13477d025aa46e1e58a893a1 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Mon, 6 Nov 2023 16:05:06 +0100 Subject: [PATCH] applied comments --- node/actors/consensus/src/replica/tests.rs | 3 +-- node/actors/consensus/src/tests.rs | 3 +-- node/actors/executor/src/lib.rs | 8 +++----- node/actors/executor/src/tests.rs | 3 +-- node/actors/network/src/consensus/handshake/tests.rs | 7 +++---- node/actors/network/src/consensus/tests.rs | 3 +-- node/actors/network/src/gossip/handshake/tests.rs | 7 +++---- node/actors/network/src/gossip/tests.rs | 2 +- node/actors/network/src/mux/tests.rs | 3 +-- node/actors/network/src/noise/tests.rs | 3 +-- node/actors/network/src/rpc/tests.rs | 8 ++++---- node/actors/network/src/tests.rs | 3 +-- node/actors/sync_blocks/src/peers/tests.rs | 3 +-- node/actors/sync_blocks/src/tests/end_to_end.rs | 3 +-- node/actors/sync_blocks/src/tests/mod.rs | 3 +-- 15 files changed, 24 insertions(+), 38 deletions(-) diff --git a/node/actors/consensus/src/replica/tests.rs b/node/actors/consensus/src/replica/tests.rs index 6c9e6e12..8fb3aedc 100644 --- a/node/actors/consensus/src/replica/tests.rs +++ b/node/actors/consensus/src/replica/tests.rs @@ -1,7 +1,6 @@ use crate::testonly; use rand::Rng; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, scope, time}; +use zksync_concurrency::{ctx, scope, testonly::abort_on_panic, time}; use zksync_consensus_network::io::{ConsensusInputMessage, Target}; use zksync_consensus_roles::validator::{self, ViewNumber}; diff --git a/node/actors/consensus/src/tests.rs b/node/actors/consensus/src/tests.rs index 54fa7f9a..a7f65479 100644 --- a/node/actors/consensus/src/tests.rs +++ b/node/actors/consensus/src/tests.rs @@ -2,8 +2,7 @@ use crate::{ misc::consensus_threshold, testonly::{Behavior, Network, Test}, }; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::ctx; +use zksync_concurrency::{ctx, testonly::abort_on_panic}; async fn run_test(behavior: Behavior, network: Network) { abort_on_panic(); diff --git a/node/actors/executor/src/lib.rs b/node/actors/executor/src/lib.rs index 70a60e59..c303056d 100644 --- a/node/actors/executor/src/lib.rs +++ b/node/actors/executor/src/lib.rs @@ -4,12 +4,10 @@ use crate::io::Dispatcher; use anyhow::Context as _; use std::{mem, sync::Arc}; use zksync_concurrency::{ctx, ctx::channel, net, scope}; -use zksync_consensus_consensus as consensus; -use zksync_consensus_consensus::Consensus; +use zksync_consensus_consensus::{misc::consensus_threshold, Consensus}; use zksync_consensus_network as network; use zksync_consensus_roles::{node, validator, validator::FinalBlock}; use zksync_consensus_storage::{FallbackReplicaStateStore, ReplicaStateStore, WriteBlockStore}; -use zksync_consensus_sync_blocks as sync_blocks; use zksync_consensus_sync_blocks::SyncBlocks; use zksync_consensus_utils::pipe; @@ -182,9 +180,9 @@ impl Executor { None }; - let sync_blocks_config = sync_blocks::Config::new( + let sync_blocks_config = zksync_consensus_sync_blocks::Config::new( validator_set.clone(), - consensus::misc::consensus_threshold(validator_set.len()), + consensus_threshold(validator_set.len()), )?; let sync_blocks = SyncBlocks::new( ctx, diff --git a/node/actors/executor/src/tests.rs b/node/actors/executor/src/tests.rs index dc69b267..87c4a9d1 100644 --- a/node/actors/executor/src/tests.rs +++ b/node/actors/executor/src/tests.rs @@ -3,8 +3,7 @@ use super::*; use rand::Rng; use std::collections::HashMap; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::sync; +use zksync_concurrency::{sync, testonly::abort_on_panic}; use zksync_consensus_consensus::testonly::make_genesis; use zksync_consensus_network::testonly::Instance; use zksync_consensus_roles::validator::{BlockNumber, Payload}; diff --git a/node/actors/network/src/consensus/handshake/tests.rs b/node/actors/network/src/consensus/handshake/tests.rs index c32228bc..ed49c14d 100644 --- a/node/actors/network/src/consensus/handshake/tests.rs +++ b/node/actors/network/src/consensus/handshake/tests.rs @@ -1,15 +1,14 @@ use super::*; use crate::{frame, noise, testonly}; use rand::Rng; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, io, scope}; +use zksync_concurrency::{ctx, io, scope, testonly::abort_on_panic}; use zksync_consensus_roles::validator; -use zksync_consensus_schema as schema; +use zksync_consensus_schema::testonly::test_encode_random; #[test] fn test_schema_encode_decode() { let rng = &mut ctx::test_root(&ctx::RealClock).rng(); - schema::testonly::test_encode_random::<_, Handshake>(rng); + test_encode_random::<_, Handshake>(rng); } #[tokio::test] diff --git a/node/actors/network/src/consensus/tests.rs b/node/actors/network/src/consensus/tests.rs index fe628bb3..4ec52fcc 100644 --- a/node/actors/network/src/consensus/tests.rs +++ b/node/actors/network/src/consensus/tests.rs @@ -3,8 +3,7 @@ use crate::{io, preface, rpc, run_network, testonly}; use anyhow::Context as _; use rand::Rng; use tracing::Instrument as _; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, net, scope}; +use zksync_concurrency::{ctx, net, scope, testonly::abort_on_panic}; use zksync_consensus_roles::validator; use zksync_consensus_utils::pipe; diff --git a/node/actors/network/src/gossip/handshake/tests.rs b/node/actors/network/src/gossip/handshake/tests.rs index 8894fc1f..39c26457 100644 --- a/node/actors/network/src/gossip/handshake/tests.rs +++ b/node/actors/network/src/gossip/handshake/tests.rs @@ -2,15 +2,14 @@ use super::*; use crate::{frame, noise, testonly}; use rand::Rng; use std::collections::{HashMap, HashSet}; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, io, scope}; +use zksync_concurrency::{ctx, io, scope, testonly::abort_on_panic}; use zksync_consensus_roles::node; -use zksync_consensus_schema as schema; +use zksync_consensus_schema::testonly::test_encode_random; #[test] fn test_schema_encode_decode() { let rng = &mut ctx::test_root(&ctx::RealClock).rng(); - schema::testonly::test_encode_random::<_, Handshake>(rng); + test_encode_random::<_, Handshake>(rng); } fn make_cfg(rng: &mut R) -> Config { diff --git a/node/actors/network/src/gossip/tests.rs b/node/actors/network/src/gossip/tests.rs index 8a09524e..14f73183 100644 --- a/node/actors/network/src/gossip/tests.rs +++ b/node/actors/network/src/gossip/tests.rs @@ -9,11 +9,11 @@ use std::{ }; use test_casing::{test_casing, Product}; use tracing::Instrument as _; -use zksync_concurrency::testonly::abort_on_panic; use zksync_concurrency::{ ctx::{self, channel}, oneshot, scope, sync::{watch, Mutex}, + testonly::abort_on_panic, time, }; use zksync_consensus_roles as roles; diff --git a/node/actors/network/src/mux/tests.rs b/node/actors/network/src/mux/tests.rs index 3bea05f6..19a82458 100644 --- a/node/actors/network/src/mux/tests.rs +++ b/node/actors/network/src/mux/tests.rs @@ -8,8 +8,7 @@ use std::{ Arc, }, }; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, scope}; +use zksync_concurrency::{ctx, scope, testonly::abort_on_panic}; use zksync_consensus_schema as schema; use zksync_consensus_schema::proto::network::mux_test as proto; use zksync_consensus_utils::no_copy::NoCopy; diff --git a/node/actors/network/src/noise/tests.rs b/node/actors/network/src/noise/tests.rs index cacfbbca..7ad33fcd 100644 --- a/node/actors/network/src/noise/tests.rs +++ b/node/actors/network/src/noise/tests.rs @@ -1,8 +1,7 @@ use crate::noise; use rand::Rng; use tracing::instrument::Instrument as _; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, io, scope}; +use zksync_concurrency::{ctx, io, scope, testonly::abort_on_panic}; #[tokio::test] async fn transmit_ok() { diff --git a/node/actors/network/src/rpc/tests.rs b/node/actors/network/src/rpc/tests.rs index e79aea03..d2e98851 100644 --- a/node/actors/network/src/rpc/tests.rs +++ b/node/actors/network/src/rpc/tests.rs @@ -5,8 +5,8 @@ use std::{ collections::HashSet, sync::atomic::{AtomicU64, Ordering}, }; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, time}; +use zksync_concurrency::{ctx, testonly::abort_on_panic, time}; +use zksync_consensus_schema::testonly::test_encode_random; /// CAPABILITY_ID should uniquely identify the RPC. #[test] @@ -22,8 +22,8 @@ fn test_capability_rpc_correspondence() { #[test] fn test_schema_encode_decode() { let rng = &mut ctx::test_root(&ctx::RealClock).rng(); - schema::testonly::test_encode_random::<_, consensus::Req>(rng); - schema::testonly::test_encode_random::<_, sync_validator_addrs::Resp>(rng); + test_encode_random::<_, consensus::Req>(rng); + test_encode_random::<_, sync_validator_addrs::Resp>(rng); } fn expected(res: Result<(), mux::RunError>) -> Result<(), mux::RunError> { diff --git a/node/actors/network/src/tests.rs b/node/actors/network/src/tests.rs index 2226219f..f283c393 100644 --- a/node/actors/network/src/tests.rs +++ b/node/actors/network/src/tests.rs @@ -1,7 +1,6 @@ use crate::{run_network, testonly}; use tracing::Instrument as _; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{ctx, scope}; +use zksync_concurrency::{ctx, scope, testonly::abort_on_panic}; use zksync_consensus_utils::pipe; /// Test that metrics are correctly defined diff --git a/node/actors/sync_blocks/src/peers/tests.rs b/node/actors/sync_blocks/src/peers/tests.rs index 57e9cd4d..6248bfb4 100644 --- a/node/actors/sync_blocks/src/peers/tests.rs +++ b/node/actors/sync_blocks/src/peers/tests.rs @@ -5,8 +5,7 @@ use async_trait::async_trait; use rand::{rngs::StdRng, seq::IteratorRandom, Rng}; use std::{collections::HashSet, fmt}; use test_casing::{test_casing, Product}; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::time; +use zksync_concurrency::{testonly::abort_on_panic, time}; use zksync_consensus_roles::validator; use zksync_consensus_storage::{BlockStore, InMemoryStorage}; diff --git a/node/actors/sync_blocks/src/tests/end_to_end.rs b/node/actors/sync_blocks/src/tests/end_to_end.rs index c54bfdd6..5bfc9bf3 100644 --- a/node/actors/sync_blocks/src/tests/end_to_end.rs +++ b/node/actors/sync_blocks/src/tests/end_to_end.rs @@ -6,8 +6,7 @@ use rand::seq::SliceRandom; use std::fmt; use test_casing::test_casing; use tracing::Instrument; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::ctx::channel; +use zksync_concurrency::{ctx::channel, testonly::abort_on_panic}; use zksync_consensus_network as network; use zksync_consensus_network::testonly::Instance as NetworkInstance; use zksync_consensus_roles::node; diff --git a/node/actors/sync_blocks/src/tests/mod.rs b/node/actors/sync_blocks/src/tests/mod.rs index 6fc7b445..fe0fe2b2 100644 --- a/node/actors/sync_blocks/src/tests/mod.rs +++ b/node/actors/sync_blocks/src/tests/mod.rs @@ -5,8 +5,7 @@ use rand::{ Rng, }; use std::iter; -use zksync_concurrency::testonly::abort_on_panic; -use zksync_concurrency::{oneshot, time}; +use zksync_concurrency::{oneshot, testonly::abort_on_panic, time}; use zksync_consensus_network::io::{GetBlockError, GetBlockResponse, SyncBlocksRequest}; use zksync_consensus_roles::validator::{ self,