Move src/logger.rs into logger/ crate to unify logging across the workspace
This commit is contained in:
@@ -116,8 +116,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_encrypt_file_many_keys_single() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
|
||||
let entries = make_tiny_test_entries(32);
|
||||
let ledger_dir = "test_encrypt_file_many_keys_single";
|
||||
@@ -156,8 +155,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_encrypt_file_many_keys_multiple_keys() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
|
||||
let entries = make_tiny_test_entries(32);
|
||||
let ledger_dir = "test_encrypt_file_many_keys_multiple";
|
||||
|
@@ -1109,7 +1109,7 @@ mod tests {
|
||||
use crate::crds_value::CrdsValueLabel;
|
||||
use crate::db_ledger::DbLedger;
|
||||
use crate::ledger::get_tmp_ledger_path;
|
||||
use crate::logger;
|
||||
|
||||
use crate::packet::BLOB_HEADER_SIZE;
|
||||
use crate::result::Error;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
@@ -1206,7 +1206,7 @@ mod tests {
|
||||
/// test window requests respond with the right blob, and do not overrun
|
||||
#[test]
|
||||
fn run_window_request() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let ledger_path = get_tmp_ledger_path("run_window_request");
|
||||
{
|
||||
let db_ledger = Arc::new(RwLock::new(DbLedger::open(&ledger_path).unwrap()));
|
||||
@@ -1254,7 +1254,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_default_leader() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let node_info = NodeInfo::new_localhost(Keypair::new().pubkey(), 0);
|
||||
let mut cluster_info = ClusterInfo::new(node_info);
|
||||
let network_entry_point = NodeInfo::new_entry_point(&socketaddr!("127.0.0.1:1239"));
|
||||
|
@@ -150,7 +150,7 @@ pub mod tests {
|
||||
use crate::bank::Bank;
|
||||
use crate::compute_leader_finality_service::ComputeLeaderFinalityService;
|
||||
use crate::create_vote_account::*;
|
||||
use crate::logger;
|
||||
|
||||
use crate::mint::Mint;
|
||||
use bincode::serialize;
|
||||
use solana_sdk::hash::hash;
|
||||
@@ -164,7 +164,7 @@ pub mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_compute_finality() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
|
||||
let mint = Mint::new(1234);
|
||||
let dummy_leader_id = Keypair::new().pubkey();
|
||||
|
@@ -491,32 +491,28 @@ mod test {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_star_network_large_pull() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let mut network = star_network_create(2000);
|
||||
network_simulator_pull_only(&mut network);
|
||||
}
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_rstar_network_large_push() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let mut network = rstar_network_create(4000);
|
||||
network_simulator(&mut network);
|
||||
}
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_ring_network_large_push() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let mut network = ring_network_create(4001);
|
||||
network_simulator(&mut network);
|
||||
}
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_star_network_large_push() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let mut network = star_network_create(4002);
|
||||
network_simulator(&mut network);
|
||||
}
|
||||
|
@@ -342,8 +342,7 @@ mod test {
|
||||
}
|
||||
#[test]
|
||||
fn test_refresh_active_set() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let mut crds = Crds::default();
|
||||
let mut push = CrdsGossipPush::default();
|
||||
let value1 = CrdsValue::ContactInfo(ContactInfo::new_localhost(Keypair::new().pubkey(), 0));
|
||||
|
@@ -570,7 +570,7 @@ pub mod test {
|
||||
use super::*;
|
||||
use crate::db_ledger::{DbLedger, DEFAULT_SLOT_HEIGHT};
|
||||
use crate::ledger::{get_tmp_ledger_path, make_tiny_test_entries, Block};
|
||||
use crate::logger;
|
||||
|
||||
use crate::packet::{index_blobs, SharedBlob, BLOB_DATA_SIZE, BLOB_SIZE};
|
||||
use crate::window::WindowSlot;
|
||||
use rand::{thread_rng, Rng};
|
||||
@@ -824,7 +824,7 @@ pub mod test {
|
||||
// Remove a data block, test for successful recovery
|
||||
#[test]
|
||||
pub fn test_window_recover_basic() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
|
||||
// Setup the window
|
||||
let offset = 0;
|
||||
@@ -878,7 +878,7 @@ pub mod test {
|
||||
// Remove a data and coding block, test for successful recovery
|
||||
#[test]
|
||||
pub fn test_window_recover_basic2() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
|
||||
// Setup the window
|
||||
let offset = 0;
|
||||
@@ -951,7 +951,7 @@ pub mod test {
|
||||
// #[test]
|
||||
// #[ignore]
|
||||
// pub fn test_window_recover() {
|
||||
// logger::setup();
|
||||
// solana_logger::setup();
|
||||
// let offset = 4;
|
||||
// let data_len = 16;
|
||||
// let num_blobs = NUM_DATA + 2;
|
||||
|
@@ -731,8 +731,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_slice() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let zero = Hash::default();
|
||||
let one = hash(&zero.as_ref());
|
||||
assert!(vec![][..].verify(&zero)); // base case
|
||||
@@ -775,8 +774,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_entries_to_blobs() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let entries = make_test_entries();
|
||||
|
||||
let blob_q = entries.to_blobs();
|
||||
@@ -786,8 +784,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_bad_blobs_attack() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 8000);
|
||||
let blobs_q = to_blobs(vec![(0, addr)]).unwrap(); // <-- attack!
|
||||
assert!(reconstruct_entries_from_blobs(blobs_q).is_err());
|
||||
@@ -795,8 +792,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_next_entries() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let id = Hash::default();
|
||||
let next_id = hash(&id.as_ref());
|
||||
let keypair = Keypair::new();
|
||||
@@ -844,8 +840,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_ledger_reader_writer() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let ledger_path = get_tmp_ledger_path("test_ledger_reader_writer");
|
||||
let entries = make_tiny_test_entries(10);
|
||||
|
||||
@@ -922,8 +917,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_recover_ledger() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
|
||||
let entries = make_tiny_test_entries(10);
|
||||
let ledger_path = get_tmp_ledger_path("test_recover_ledger");
|
||||
@@ -973,8 +967,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_ledger() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
|
||||
let entries = make_tiny_test_entries(10);
|
||||
let ledger_path = get_tmp_ledger_path("test_verify_ledger");
|
||||
@@ -991,8 +984,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_get_entries_bytes() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let entries = make_tiny_test_entries(10);
|
||||
let ledger_path = get_tmp_ledger_path("test_raw_entries");
|
||||
{
|
||||
|
@@ -42,7 +42,6 @@ pub mod gossip_service;
|
||||
pub mod leader_scheduler;
|
||||
pub mod ledger;
|
||||
pub mod ledger_write_stage;
|
||||
pub mod logger;
|
||||
pub mod mint;
|
||||
pub mod netutil;
|
||||
pub mod packet;
|
||||
|
@@ -1,16 +0,0 @@
|
||||
//! The `logger` module provides a setup function for `env_logger`. Its only function,
|
||||
//! `setup()` may be called multiple times.
|
||||
|
||||
use env_logger;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
|
||||
static INIT: Once = ONCE_INIT;
|
||||
|
||||
/// Setup function that is only run once, even if called multiple times.
|
||||
pub fn setup() {
|
||||
INIT.call_once(|| {
|
||||
env_logger::Builder::from_default_env()
|
||||
.default_format_timestamp_nanos(true)
|
||||
.init();
|
||||
});
|
||||
}
|
@@ -203,14 +203,14 @@ pub fn find_available_port_in_range(range: (u16, u16)) -> io::Result<u16> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::logger;
|
||||
|
||||
use crate::netutil::*;
|
||||
use ipnetwork::IpNetwork;
|
||||
use pnet_datalink as datalink;
|
||||
|
||||
#[test]
|
||||
fn test_find_eth0ish_ip_addr() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
|
||||
macro_rules! mock_interface {
|
||||
($name:ident, $ip_mask:expr) => {
|
||||
|
@@ -256,7 +256,7 @@ mod test {
|
||||
make_active_set_entries, LeaderScheduler, LeaderSchedulerConfig,
|
||||
};
|
||||
use crate::ledger::{create_ticks, create_tmp_sample_ledger, LedgerWriter};
|
||||
use crate::logger;
|
||||
|
||||
use crate::packet::BlobError;
|
||||
use crate::replay_stage::{ReplayStage, ReplayStageReturnType};
|
||||
use crate::result::Error;
|
||||
@@ -271,7 +271,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
pub fn test_replay_stage_leader_rotation_exit() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
|
||||
// Set up dummy node to host a ReplayStage
|
||||
let my_keypair = Keypair::new();
|
||||
|
@@ -301,7 +301,7 @@ impl Replicator {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::logger;
|
||||
|
||||
use crate::replicator::sample_file;
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
@@ -327,7 +327,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_sample_file() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let in_path = tmp_file_path("test_sample_file_input.txt");
|
||||
let num_strings = 4096;
|
||||
let string = "12foobar";
|
||||
|
@@ -481,8 +481,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_verify_multi_sig() {
|
||||
use crate::logger;
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let keypair0 = Keypair::new();
|
||||
let keypair1 = Keypair::new();
|
||||
let keypairs = vec![&keypair0, &keypair1];
|
||||
|
@@ -339,7 +339,7 @@ mod tests {
|
||||
use crate::entry::Entry;
|
||||
use crate::ledger::make_tiny_test_entries;
|
||||
use crate::ledger::{create_tmp_sample_ledger, LedgerWriter};
|
||||
use crate::logger;
|
||||
|
||||
use crate::service::Service;
|
||||
use crate::storage_stage::StorageState;
|
||||
use crate::storage_stage::NUM_IDENTITIES;
|
||||
@@ -380,7 +380,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_storage_stage_process_entries() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let keypair = Arc::new(Keypair::new());
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
|
||||
@@ -445,7 +445,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_storage_stage_process_vote_entries() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let keypair = Arc::new(Keypair::new());
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
|
||||
|
@@ -430,7 +430,7 @@ mod tests {
|
||||
use crate::fullnode::Fullnode;
|
||||
use crate::leader_scheduler::LeaderScheduler;
|
||||
use crate::ledger::create_tmp_ledger_with_mint;
|
||||
use crate::logger;
|
||||
|
||||
use crate::mint::Mint;
|
||||
use bincode::deserialize;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
@@ -441,7 +441,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_thin_client() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let leader_keypair = Arc::new(Keypair::new());
|
||||
let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
let leader_data = leader.info.clone();
|
||||
@@ -495,7 +495,7 @@ mod tests {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_bad_sig() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let leader_keypair = Arc::new(Keypair::new());
|
||||
let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
let alice = Mint::new(10_000);
|
||||
@@ -552,7 +552,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_client_check_signature() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let leader_keypair = Arc::new(Keypair::new());
|
||||
let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
let alice = Mint::new(10_000);
|
||||
@@ -597,7 +597,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_register_vote_account() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let leader_keypair = Arc::new(Keypair::new());
|
||||
let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
let mint = Mint::new(10_000);
|
||||
@@ -680,7 +680,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_transaction_count() {
|
||||
// set a bogus address, see that we don't hang
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let addr = "0.0.0.0:1234".parse().unwrap();
|
||||
let transactions_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
let mut client =
|
||||
@@ -690,7 +690,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_zero_balance_after_nonzero() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let leader_keypair = Arc::new(Keypair::new());
|
||||
let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
let alice = Mint::new(10_000);
|
||||
|
@@ -185,7 +185,7 @@ pub mod tests {
|
||||
use crate::gossip_service::GossipService;
|
||||
use crate::leader_scheduler::LeaderScheduler;
|
||||
use crate::ledger::get_tmp_ledger_path;
|
||||
use crate::logger;
|
||||
|
||||
use crate::mint::Mint;
|
||||
use crate::packet::SharedBlob;
|
||||
use crate::service::Service;
|
||||
@@ -219,7 +219,7 @@ pub mod tests {
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_replay() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let leader = Node::new_localhost();
|
||||
let target1_keypair = Keypair::new();
|
||||
let target1 = Node::new_localhost_with_pubkey(target1_keypair.pubkey());
|
||||
|
@@ -237,7 +237,7 @@ mod test {
|
||||
use crate::entry::Entry;
|
||||
use crate::leader_scheduler::LeaderScheduler;
|
||||
use crate::ledger::{get_tmp_ledger_path, make_consecutive_blobs};
|
||||
use crate::logger;
|
||||
|
||||
use crate::packet::{SharedBlob, PACKET_DATA_SIZE};
|
||||
use crate::streamer::{blob_receiver, responder};
|
||||
use crate::window_service::{repair_backoff, window_service};
|
||||
@@ -267,7 +267,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
pub fn window_send_test() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let tn = Node::new_localhost();
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let mut cluster_info_me = ClusterInfo::new(tn.info.clone());
|
||||
@@ -338,7 +338,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
pub fn window_send_leader_test2() {
|
||||
logger::setup();
|
||||
solana_logger::setup();
|
||||
let tn = Node::new_localhost();
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let cluster_info_me = ClusterInfo::new(tn.info.clone());
|
||||
|
Reference in New Issue
Block a user