Skip to content

Commit

Permalink
applied comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pompon0 committed Nov 6, 2023
1 parent 762aa97 commit 4d946d9
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 38 deletions.
3 changes: 1 addition & 2 deletions node/actors/consensus/src/replica/tests.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
3 changes: 1 addition & 2 deletions node/actors/consensus/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 3 additions & 5 deletions node/actors/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -182,9 +180,9 @@ impl<S: WriteBlockStore + 'static> Executor<S> {
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,
Expand Down
3 changes: 1 addition & 2 deletions node/actors/executor/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
7 changes: 3 additions & 4 deletions node/actors/network/src/consensus/handshake/tests.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
3 changes: 1 addition & 2 deletions node/actors/network/src/consensus/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 3 additions & 4 deletions node/actors/network/src/gossip/handshake/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<R: Rng>(rng: &mut R) -> Config {
Expand Down
2 changes: 1 addition & 1 deletion node/actors/network/src/gossip/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions node/actors/network/src/mux/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions node/actors/network/src/noise/tests.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
8 changes: 4 additions & 4 deletions node/actors/network/src/rpc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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> {
Expand Down
3 changes: 1 addition & 2 deletions node/actors/network/src/tests.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions node/actors/sync_blocks/src/peers/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
3 changes: 1 addition & 2 deletions node/actors/sync_blocks/src/tests/end_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions node/actors/sync_blocks/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4d946d9

Please sign in to comment.