Skip to content

Commit

Permalink
Changes Committed
Browse files Browse the repository at this point in the history
  • Loading branch information
postmeback committed Aug 1, 2023
1 parent 13ef8e8 commit 28f6155
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 42 deletions.
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/eth1_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ fn is_candidate_block(block: &Eth1Block, period_start: u64, spec: &ChainSpec) ->
#[cfg(test)]
mod test {
use super::*;
use environment::null_logger;
use logging::test_logger;
use types::{DepositData, MinimalEthSpec, Signature};

type E = MinimalEthSpec;
Expand Down Expand Up @@ -743,7 +743,7 @@ mod test {
..Eth1Config::default()
};

let log = null_logger().unwrap();
let log = test_logger();
Eth1Chain::new(
CachingEth1Backend::new(eth1_config, log, MainnetEthSpec::default_spec()).unwrap(),
)
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/shuffling_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl BlockShufflingIds {
#[cfg(not(debug_assertions))]
#[cfg(test)]
mod test {
use task_executor::test_utils::null_logger;
use logging::test_logger;
use types::*;

use crate::test_utils::EphemeralHarnessType;
Expand All @@ -315,7 +315,7 @@ mod test {
previous: Some(shuffling_id(current_epoch - 1)),
block_root: Hash256::from_low_u64_le(0),
};
let logger = null_logger().unwrap();
let logger = test_logger().unwrap();
ShufflingCache::new(TEST_CACHE_SIZE, head_shuffling_ids, logger)
}

Expand Down
29 changes: 12 additions & 17 deletions beacon_node/eth1/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
#![cfg(test)]
use environment::{Environment, EnvironmentBuilder};
use environment::{Environment,
EnvironmentBuilder,
test_logger};
use eth1::{Config, Eth1Endpoint, Service};
use eth1::{DepositCache, DEFAULT_CHAIN_ID};
use eth1_test_rig::{AnvilEth1Instance, Http, Middleware, Provider};
use execution_layer::http::{deposit_methods::*, HttpJsonRpc, Log};
use merkle_proof::verify_merkle_proof;
use sensitive_url::SensitiveUrl;
use slog::Logger;
use sloggers::{null::NullLoggerBuilder, Build};
use std::ops::Range;
use std::time::Duration;
use tree_hash::TreeHash;
use types::{DepositData, EthSpec, Hash256, Keypair, MainnetEthSpec, MinimalEthSpec, Signature};

const DEPOSIT_CONTRACT_TREE_DEPTH: usize = 32;

pub fn null_logger() -> Logger {
let log_builder = NullLoggerBuilder;
log_builder.build().expect("should build logger")
}

pub fn new_env() -> Environment<MinimalEthSpec> {
EnvironmentBuilder::minimal()
.multi_threaded_tokio_runtime()
.expect("should start tokio runtime")
.null_logger()
.test_logger()
.expect("should start null logger")
.build()
.expect("should build env")
Expand Down Expand Up @@ -104,7 +99,7 @@ mod eth1_cache {
#[tokio::test]
async fn simple_scenario() {
async {
let log = null_logger();
let log = test_logger();

for follow_distance in 0..3 {
let eth1 = new_anvil_instance()
Expand Down Expand Up @@ -186,7 +181,7 @@ mod eth1_cache {
#[tokio::test]
async fn big_skip() {
async {
let log = null_logger();
let log = test_logger();

let eth1 = new_anvil_instance()
.await
Expand Down Expand Up @@ -241,7 +236,7 @@ mod eth1_cache {
#[tokio::test]
async fn pruning() {
async {
let log = null_logger();
let log = test_logger();

let eth1 = new_anvil_instance()
.await
Expand Down Expand Up @@ -293,7 +288,7 @@ mod eth1_cache {
#[tokio::test]
async fn double_update() {
async {
let log = null_logger();
let log = test_logger();

let n = 16;

Expand Down Expand Up @@ -346,7 +341,7 @@ mod deposit_tree {
#[tokio::test]
async fn updating() {
async {
let log = null_logger();
let log = test_logger();

let n = 4;

Expand Down Expand Up @@ -427,7 +422,7 @@ mod deposit_tree {
#[tokio::test]
async fn double_update() {
async {
let log = null_logger();
let log = test_logger();

let n = 8;

Expand Down Expand Up @@ -689,7 +684,7 @@ mod fast {
#[tokio::test]
async fn deposit_cache_query() {
async {
let log = null_logger();
let log = test_logger();

let eth1 = new_anvil_instance()
.await
Expand Down Expand Up @@ -772,7 +767,7 @@ mod persist {
#[tokio::test]
async fn test_persist_caches() {
async {
let log = null_logger();
let log = test_logger();

let eth1 = new_anvil_instance()
.await
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/execution_layer/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::engine_api::{
auth::Auth, http::JSONRPC_VERSION, ExecutionBlock, PayloadStatusV1, PayloadStatusV1Status,
};
use bytes::Bytes;
use environment::null_logger;
use environment::test_logger;
use execution_block_generator::PoWBlock;
use handle_rpc::handle_rpc;
use parking_lot::{Mutex, RwLock, RwLockWriteGuard};
Expand Down Expand Up @@ -115,7 +115,7 @@ impl<T: EthSpec> MockServer<T> {
let ctx: Arc<Context<T>> = Arc::new(Context {
config: server_config,
jwt_key,
log: null_logger().unwrap(),
log: test_logger(),
last_echo_request: last_echo_request.clone(),
execution_block_generator: RwLock::new(execution_block_generator),
previous_request: <_>::default(),
Expand Down
6 changes: 3 additions & 3 deletions beacon_node/genesis/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
//! You can start a suitable instance using the `anvil_test_node.sh` script in the `scripts`
//! dir in the root of the `lighthouse` repo.
#![cfg(test)]
use environment::{Environment, EnvironmentBuilder};
use environment::{Environment, EnvironmentBuilder, test_logger};
use eth1::{Eth1Endpoint, DEFAULT_CHAIN_ID};
use eth1_test_rig::{AnvilEth1Instance, DelayThenDeposit, Middleware};
use genesis::{Eth1Config, Eth1GenesisService};
use sensitive_url::SensitiveUrl;
use state_processing::is_valid_genesis_state;
use std::time::Duration;
use genesis::{Eth1Config, Eth1GenesisService};
use types::{test_utils::generate_deterministic_keypair, Hash256, MinimalEthSpec};

pub fn new_env() -> Environment<MinimalEthSpec> {
EnvironmentBuilder::minimal()
.multi_threaded_tokio_runtime()
.expect("should start tokio runtime")
.null_logger()
.test_logger()
.expect("should start null logger")
.build()
.expect("should build env")
Expand Down
6 changes: 3 additions & 3 deletions beacon_node/http_api/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use beacon_chain::{
test_utils::{AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType},
BeaconChain, StateSkipConfig, WhenSlotSkipped, MAXIMUM_GOSSIP_CLOCK_DISPARITY,
};
use environment::null_logger;
use logging::test_logger;
use eth2::{
mixin::{RequestAccept, ResponseForkName, ResponseOptional},
reqwest::RequestBuilder,
Expand Down Expand Up @@ -229,7 +229,7 @@ impl ApiTester {
"precondition: justification"
);

let log = null_logger().unwrap();
let log = test_logger();

let ApiServer {
server,
Expand Down Expand Up @@ -315,7 +315,7 @@ impl ApiTester {

let chain = harness.chain.clone();

let log = null_logger().unwrap();
let log = test_logger();

let ApiServer {
server,
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/http_metrics/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use beacon_chain::test_utils::EphemeralHarnessType;
use environment::null_logger;
use environment::test_logger;
use http_metrics::Config;
use reqwest::header::HeaderValue;
use reqwest::StatusCode;
Expand All @@ -13,7 +13,7 @@ type Context = http_metrics::Context<EphemeralHarnessType<MainnetEthSpec>>;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn returns_200_ok() {
async {
let log = null_logger().unwrap();
let log = test_logger();

let context = Arc::new(Context {
config: Config {
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![cfg(test)]

use beacon_chain::StateSkipConfig;
use logging::test_logger;
use node_test_rig::{
environment::{Environment, EnvironmentBuilder},
eth2::types::StateId,
Expand All @@ -25,8 +26,7 @@ fn build_node<E: EthSpec>(env: &mut Environment<E>) -> LocalBeaconNode<E> {
#[test]
fn http_server_genesis_state() {
let mut env = env_builder()
.null_logger()
//.async_logger("debug", None)
.test_logger()
.expect("should build env logger")
.multi_threaded_tokio_runtime()
.expect("should start tokio runtime")
Expand Down
6 changes: 4 additions & 2 deletions lcli/src/transition_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ use beacon_chain::{
};
use clap::ArgMatches;
use clap_utils::{parse_optional, parse_required};
use environment::{null_logger, Environment};
use environment::{Environment, test_logger};
use logging::test_logger;
use eth2::{
types::{BlockId, StateId},
BeaconNodeHttpClient, SensitiveUrl, Timeouts,
Expand Down Expand Up @@ -189,9 +190,10 @@ pub fn run<T: EthSpec>(env: Environment<T>, matches: &ArgMatches) -> Result<(),
let store = HotColdDB::open_ephemeral(
<_>::default(),
spec.clone(),
null_logger().map_err(|e| format!("Failed to create null_logger: {:?}", e))?,
test_logger(),
)
.map_err(|e| format!("Failed to create ephemeral store: {:?}", e))?;

let store = Arc::new(store);

debug!("Building pubkey cache (might take some time)");
Expand Down
6 changes: 3 additions & 3 deletions lighthouse/environment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use {
#[cfg(not(target_family = "unix"))]
use {futures::channel::oneshot, std::cell::RefCell};

pub use task_executor::test_utils::null_logger;
pub use logging::test_logger;

const LOG_CHANNEL_SIZE: usize = 2048;
const SSE_LOG_CHANNEL_SIZE: usize = 2048;
Expand Down Expand Up @@ -185,8 +185,8 @@ impl<E: EthSpec> EnvironmentBuilder<E> {
}

/// Specifies that all logs should be sent to `null` (i.e., ignored).
pub fn null_logger(mut self) -> Result<Self, String> {
self.log = Some(null_logger()?);
pub fn test_logger(mut self) -> Result<Self, String> {
self.log = Some(test_logger()?);
Ok(self)
}

Expand Down
3 changes: 2 additions & 1 deletion lighthouse/environment/tests/environment_builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg(test)]

use logging::test_logger;
use environment::EnvironmentBuilder;
use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK};
use std::path::PathBuf;
Expand All @@ -9,7 +10,7 @@ fn builder() -> EnvironmentBuilder<MainnetEthSpec> {
EnvironmentBuilder::mainnet()
.multi_threaded_tokio_runtime()
.expect("should set runtime")
.null_logger()
.test_logger()
.expect("should set logger")
}

Expand Down
2 changes: 1 addition & 1 deletion testing/web3signer_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ mod tests {

impl ValidatorStoreRig {
pub async fn new(validator_definitions: Vec<ValidatorDefinition>, spec: ChainSpec) -> Self {
let log = environment::null_logger().unwrap();
let log = logging::test_logger();
let validator_dir = TempDir::new().unwrap();

let validator_definitions = ValidatorDefinitions::from(validator_definitions);
Expand Down
3 changes: 1 addition & 2 deletions validator_client/src/doppelganger_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ impl DoppelgangerService {
#[cfg(test)]
mod test {
use super::*;
// use environment::null_logger;
use futures::executor::block_on;
use logging::test_logger;
use slot_clock::TestingSlotClock;
Expand Down Expand Up @@ -718,7 +717,7 @@ mod test {
fn build(self) -> TestScenario {
let mut rng = XorShiftRng::from_seed([42; 16]);
let slot_clock = TestingSlotClock::new(Slot::new(0), GENESIS_TIME, SLOT_DURATION);
let log = test_logger().unwrap();
let log = test_logger();

TestScenario {
validators: (0..self.validator_count)
Expand Down

0 comments on commit 28f6155

Please sign in to comment.