Integrate tracing (#6339)

Tracing Integration
- [reference](5bbf1859e9/projects/project-ideas.md (L297))


  - [x] replace slog & log with tracing throughout the codebase
- [x] implement custom crit log
- [x] make relevant changes in the formatter
- [x] replace sloggers
- [x] re-write SSE logging components

cc: @macladson @eserilev
This commit is contained in:
ThreeHrSleep
2025-03-13 04:01:05 +05:30
committed by GitHub
parent f23f984f85
commit d60c24ef1c
241 changed files with 9485 additions and 9328 deletions

View File

@@ -4,10 +4,11 @@ use lighthouse_network::Enr;
use lighthouse_network::EnrExt;
use lighthouse_network::Multiaddr;
use lighthouse_network::{NetworkConfig, NetworkEvent};
use slog::{debug, error, o, Drain};
use std::sync::Arc;
use std::sync::Weak;
use tokio::runtime::Runtime;
use tracing::{debug, error, info_span, Instrument};
use tracing_subscriber::EnvFilter;
use types::{
ChainSpec, EnrForkId, Epoch, EthSpec, FixedBytesExtended, ForkContext, ForkName, Hash256,
MinimalEthSpec, Slot,
@@ -67,15 +68,12 @@ impl std::ops::DerefMut for Libp2pInstance {
}
#[allow(unused)]
pub fn build_log(level: slog::Level, enabled: bool) -> slog::Logger {
let decorator = slog_term::TermDecorator::new().build();
let drain = slog_term::FullFormat::new(decorator).build().fuse();
let drain = slog_async::Async::new(drain).build().fuse();
pub fn build_tracing_subscriber(level: &str, enabled: bool) {
if enabled {
slog::Logger::root(drain.filter_level(level).fuse(), o!())
} else {
slog::Logger::root(drain.filter(|_| false).fuse(), o!())
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::try_new(level).unwrap())
.try_init()
.unwrap();
}
}
@@ -101,16 +99,16 @@ pub fn build_config(mut boot_nodes: Vec<Enr>) -> Arc<NetworkConfig> {
pub async fn build_libp2p_instance(
rt: Weak<Runtime>,
boot_nodes: Vec<Enr>,
log: slog::Logger,
fork_name: ForkName,
chain_spec: Arc<ChainSpec>,
service_name: String,
) -> Libp2pInstance {
let config = build_config(boot_nodes);
// launch libp2p service
let (signal, exit) = async_channel::bounded(1);
let (shutdown_tx, _) = futures::channel::mpsc::channel(1);
let executor = task_executor::TaskExecutor::new(rt, exit, log.clone(), shutdown_tx);
let executor = task_executor::TaskExecutor::new(rt, exit, shutdown_tx, service_name);
let libp2p_context = lighthouse_network::Context {
config,
enr_fork_id: EnrForkId::default(),
@@ -119,7 +117,7 @@ pub async fn build_libp2p_instance(
libp2p_registry: None,
};
Libp2pInstance(
LibP2PService::new(executor, libp2p_context, &log)
LibP2PService::new(executor, libp2p_context)
.await
.expect("should build libp2p instance")
.0,
@@ -143,18 +141,20 @@ pub enum Protocol {
#[allow(dead_code)]
pub async fn build_node_pair(
rt: Weak<Runtime>,
log: &slog::Logger,
fork_name: ForkName,
spec: Arc<ChainSpec>,
protocol: Protocol,
) -> (Libp2pInstance, Libp2pInstance) {
let sender_log = log.new(o!("who" => "sender"));
let receiver_log = log.new(o!("who" => "receiver"));
let mut sender =
build_libp2p_instance(rt.clone(), vec![], sender_log, fork_name, spec.clone()).await;
let mut sender = build_libp2p_instance(
rt.clone(),
vec![],
fork_name,
spec.clone(),
"sender".to_string(),
)
.await;
let mut receiver =
build_libp2p_instance(rt, vec![], receiver_log, fork_name, spec.clone()).await;
build_libp2p_instance(rt, vec![], fork_name, spec.clone(), "receiver".to_string()).await;
// let the two nodes set up listeners
let sender_fut = async {
@@ -179,7 +179,8 @@ pub async fn build_node_pair(
}
}
}
};
}
.instrument(info_span!("Sender", who = "sender"));
let receiver_fut = async {
loop {
if let NetworkEvent::NewListenAddr(addr) = receiver.next_event().await {
@@ -201,7 +202,8 @@ pub async fn build_node_pair(
}
}
}
};
}
.instrument(info_span!("Receiver", who = "receiver"));
let joined = futures::future::join(sender_fut, receiver_fut);
@@ -209,9 +211,9 @@ pub async fn build_node_pair(
match sender.testing_dial(receiver_multiaddr.clone()) {
Ok(()) => {
debug!(log, "Sender dialed receiver"; "address" => format!("{:?}", receiver_multiaddr))
debug!(address = ?receiver_multiaddr, "Sender dialed receiver")
}
Err(_) => error!(log, "Dialing failed"),
Err(_) => error!("Dialing failed"),
};
(sender, receiver)
}
@@ -220,7 +222,6 @@ pub async fn build_node_pair(
#[allow(dead_code)]
pub async fn build_linear(
rt: Weak<Runtime>,
log: slog::Logger,
n: usize,
fork_name: ForkName,
spec: Arc<ChainSpec>,
@@ -228,7 +229,14 @@ pub async fn build_linear(
let mut nodes = Vec::with_capacity(n);
for _ in 0..n {
nodes.push(
build_libp2p_instance(rt.clone(), vec![], log.clone(), fork_name, spec.clone()).await,
build_libp2p_instance(
rt.clone(),
vec![],
fork_name,
spec.clone(),
"linear".to_string(),
)
.await,
);
}
@@ -238,8 +246,8 @@ pub async fn build_linear(
.collect();
for i in 0..n - 1 {
match nodes[i].testing_dial(multiaddrs[i + 1].clone()) {
Ok(()) => debug!(log, "Connected"),
Err(_) => error!(log, "Failed to connect"),
Ok(()) => debug!("Connected"),
Err(_) => error!("Failed to connect"),
};
}
nodes

View File

@@ -2,17 +2,17 @@
mod common;
use common::Protocol;
use common::{build_tracing_subscriber, Protocol};
use lighthouse_network::rpc::{methods::*, RequestType};
use lighthouse_network::service::api_types::AppRequestId;
use lighthouse_network::{rpc::max_rpc_size, NetworkEvent, ReportSource, Response};
use slog::{debug, warn, Level};
use ssz::Encode;
use ssz_types::VariableList;
use std::sync::Arc;
use std::time::Duration;
use tokio::runtime::Runtime;
use tokio::time::sleep;
use tracing::{debug, warn};
use types::{
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockBellatrix, BlobSidecar, ChainSpec,
EmptyBlock, Epoch, EthSpec, FixedBytesExtended, ForkContext, ForkName, Hash256, MinimalEthSpec,
@@ -53,26 +53,19 @@ fn bellatrix_block_large(fork_context: &ForkContext, spec: &ChainSpec) -> Beacon
#[test]
#[allow(clippy::single_match)]
fn test_tcp_status_rpc() {
// set up the logging. The level and enabled logging or not
let log_level = Level::Debug;
// Set up the logging.
let log_level = "debug";
let enable_logging = false;
build_tracing_subscriber(log_level, enable_logging);
let rt = Arc::new(Runtime::new().unwrap());
let log = common::build_log(log_level, enable_logging);
let spec = Arc::new(E::default_spec());
rt.block_on(async {
// get sender/receiver
let (mut sender, mut receiver) = common::build_node_pair(
Arc::downgrade(&rt),
&log,
ForkName::Base,
spec,
Protocol::Tcp,
)
.await;
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), ForkName::Base, spec, Protocol::Tcp).await;
// Dummy STATUS RPC message
let rpc_request = RequestType::Status(StatusMessage {
@@ -98,7 +91,7 @@ fn test_tcp_status_rpc() {
match sender.next_event().await {
NetworkEvent::PeerConnectedOutgoing(peer_id) => {
// Send a STATUS message
debug!(log, "Sending RPC");
debug!("Sending RPC");
sender
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
.unwrap();
@@ -109,9 +102,9 @@ fn test_tcp_status_rpc() {
response,
} => {
// Should receive the RPC response
debug!(log, "Sender Received");
debug!("Sender Received");
assert_eq!(response, rpc_response.clone());
debug!(log, "Sender Completed");
debug!("Sender Completed");
return;
}
_ => {}
@@ -130,7 +123,7 @@ fn test_tcp_status_rpc() {
} => {
if request.r#type == rpc_request {
// send the response
debug!(log, "Receiver Received");
debug!("Receiver Received");
receiver.send_response(peer_id, id, request.id, rpc_response.clone());
}
}
@@ -153,14 +146,13 @@ fn test_tcp_status_rpc() {
#[test]
#[allow(clippy::single_match)]
fn test_tcp_blocks_by_range_chunked_rpc() {
// set up the logging. The level and enabled logging or not
let log_level = Level::Debug;
// Set up the logging.
let log_level = "debug";
let enable_logging = false;
build_tracing_subscriber(log_level, enable_logging);
let messages_to_send = 6;
let log = common::build_log(log_level, enable_logging);
let rt = Arc::new(Runtime::new().unwrap());
let spec = Arc::new(E::default_spec());
@@ -169,7 +161,6 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
// get sender/receiver
let (mut sender, mut receiver) = common::build_node_pair(
Arc::downgrade(&rt),
&log,
ForkName::Bellatrix,
spec.clone(),
Protocol::Tcp,
@@ -206,7 +197,7 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
match sender.next_event().await {
NetworkEvent::PeerConnectedOutgoing(peer_id) => {
// Send a STATUS message
debug!(log, "Sending RPC");
debug!("Sending RPC");
sender
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
.unwrap();
@@ -216,7 +207,7 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
id: _,
response,
} => {
warn!(log, "Sender received a response");
warn!("Sender received a response");
match response {
Response::BlocksByRange(Some(_)) => {
if messages_received < 2 {
@@ -227,7 +218,7 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
assert_eq!(response, rpc_response_bellatrix_small.clone());
}
messages_received += 1;
warn!(log, "Chunk received");
warn!("Chunk received");
}
Response::BlocksByRange(None) => {
// should be exactly `messages_to_send` messages before terminating
@@ -254,7 +245,7 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
} => {
if request.r#type == rpc_request {
// send the response
warn!(log, "Receiver got request");
warn!("Receiver got request");
for i in 0..messages_to_send {
// Send first third of responses as base blocks,
// second as altair and third as bellatrix.
@@ -300,15 +291,14 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
#[test]
#[allow(clippy::single_match)]
fn test_blobs_by_range_chunked_rpc() {
// set up the logging. The level and enabled logging or not
let log_level = Level::Debug;
// Set up the logging.
let log_level = "debug";
let enable_logging = false;
build_tracing_subscriber(log_level, enable_logging);
let slot_count = 32;
let messages_to_send = 34;
let log = common::build_log(log_level, enable_logging);
let rt = Arc::new(Runtime::new().unwrap());
rt.block_on(async {
@@ -316,7 +306,6 @@ fn test_blobs_by_range_chunked_rpc() {
let spec = Arc::new(E::default_spec());
let (mut sender, mut receiver) = common::build_node_pair(
Arc::downgrade(&rt),
&log,
ForkName::Deneb,
spec.clone(),
Protocol::Tcp,
@@ -342,7 +331,7 @@ fn test_blobs_by_range_chunked_rpc() {
match sender.next_event().await {
NetworkEvent::PeerConnectedOutgoing(peer_id) => {
// Send a STATUS message
debug!(log, "Sending RPC");
debug!("Sending RPC");
sender
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
.unwrap();
@@ -352,12 +341,12 @@ fn test_blobs_by_range_chunked_rpc() {
id: _,
response,
} => {
warn!(log, "Sender received a response");
warn!("Sender received a response");
match response {
Response::BlobsByRange(Some(_)) => {
assert_eq!(response, rpc_response.clone());
messages_received += 1;
warn!(log, "Chunk received");
warn!("Chunk received");
}
Response::BlobsByRange(None) => {
// should be exactly `messages_to_send` messages before terminating
@@ -384,7 +373,7 @@ fn test_blobs_by_range_chunked_rpc() {
} => {
if request.r#type == rpc_request {
// send the response
warn!(log, "Receiver got request");
warn!("Receiver got request");
for _ in 0..messages_to_send {
// Send first third of responses as base blocks,
// second as altair and third as bellatrix.
@@ -423,14 +412,13 @@ fn test_blobs_by_range_chunked_rpc() {
#[test]
#[allow(clippy::single_match)]
fn test_tcp_blocks_by_range_over_limit() {
// set up the logging. The level and enabled logging or not
let log_level = Level::Debug;
// Set up the logging.
let log_level = "debug";
let enable_logging = false;
build_tracing_subscriber(log_level, enable_logging);
let messages_to_send = 5;
let log = common::build_log(log_level, enable_logging);
let rt = Arc::new(Runtime::new().unwrap());
let spec = Arc::new(E::default_spec());
@@ -439,7 +427,6 @@ fn test_tcp_blocks_by_range_over_limit() {
// get sender/receiver
let (mut sender, mut receiver) = common::build_node_pair(
Arc::downgrade(&rt),
&log,
ForkName::Bellatrix,
spec.clone(),
Protocol::Tcp,
@@ -466,7 +453,7 @@ fn test_tcp_blocks_by_range_over_limit() {
match sender.next_event().await {
NetworkEvent::PeerConnectedOutgoing(peer_id) => {
// Send a STATUS message
debug!(log, "Sending RPC");
debug!("Sending RPC");
sender
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
.unwrap();
@@ -492,7 +479,7 @@ fn test_tcp_blocks_by_range_over_limit() {
} => {
if request.r#type == rpc_request {
// send the response
warn!(log, "Receiver got request");
warn!("Receiver got request");
for _ in 0..messages_to_send {
let rpc_response = rpc_response_bellatrix_large.clone();
receiver.send_response(
@@ -529,15 +516,14 @@ fn test_tcp_blocks_by_range_over_limit() {
// Tests that a streamed BlocksByRange RPC Message terminates when all expected chunks were received
#[test]
fn test_tcp_blocks_by_range_chunked_rpc_terminates_correctly() {
// set up the logging. The level and enabled logging or not
let log_level = Level::Debug;
// Set up the logging.
let log_level = "debug";
let enable_logging = false;
build_tracing_subscriber(log_level, enable_logging);
let messages_to_send = 10;
let extra_messages_to_send = 10;
let log = common::build_log(log_level, enable_logging);
let rt = Arc::new(Runtime::new().unwrap());
let spec = Arc::new(E::default_spec());
@@ -546,7 +532,6 @@ fn test_tcp_blocks_by_range_chunked_rpc_terminates_correctly() {
// get sender/receiver
let (mut sender, mut receiver) = common::build_node_pair(
Arc::downgrade(&rt),
&log,
ForkName::Base,
spec.clone(),
Protocol::Tcp,
@@ -574,7 +559,7 @@ fn test_tcp_blocks_by_range_chunked_rpc_terminates_correctly() {
match sender.next_event().await {
NetworkEvent::PeerConnectedOutgoing(peer_id) => {
// Send a STATUS message
debug!(log, "Sending RPC");
debug!("Sending RPC");
sender
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
.unwrap();
@@ -586,7 +571,7 @@ fn test_tcp_blocks_by_range_chunked_rpc_terminates_correctly() {
} =>
// Should receive the RPC response
{
debug!(log, "Sender received a response");
debug!("Sender received a response");
match response {
Response::BlocksByRange(Some(_)) => {
assert_eq!(response, rpc_response.clone());
@@ -630,7 +615,7 @@ fn test_tcp_blocks_by_range_chunked_rpc_terminates_correctly() {
)) => {
if request.r#type == rpc_request {
// send the response
warn!(log, "Receiver got request");
warn!("Receiver got request");
message_info = Some((peer_id, id, request.id));
}
}
@@ -643,7 +628,7 @@ fn test_tcp_blocks_by_range_chunked_rpc_terminates_correctly() {
messages_sent += 1;
let (peer_id, stream_id, request_id) = message_info.as_ref().unwrap();
receiver.send_response(*peer_id, *stream_id, *request_id, rpc_response.clone());
debug!(log, "Sending message {}", messages_sent);
debug!("Sending message {}", messages_sent);
if messages_sent == messages_to_send + extra_messages_to_send {
// stop sending messages
return;
@@ -666,11 +651,11 @@ fn test_tcp_blocks_by_range_chunked_rpc_terminates_correctly() {
#[test]
#[allow(clippy::single_match)]
fn test_tcp_blocks_by_range_single_empty_rpc() {
// set up the logging. The level and enabled logging or not
let log_level = Level::Trace;
// Set up the logging.
let log_level = "trace";
let enable_logging = false;
build_tracing_subscriber(log_level, enable_logging);
let log = common::build_log(log_level, enable_logging);
let rt = Arc::new(Runtime::new().unwrap());
let spec = Arc::new(E::default_spec());
@@ -679,7 +664,6 @@ fn test_tcp_blocks_by_range_single_empty_rpc() {
// get sender/receiver
let (mut sender, mut receiver) = common::build_node_pair(
Arc::downgrade(&rt),
&log,
ForkName::Base,
spec.clone(),
Protocol::Tcp,
@@ -709,7 +693,7 @@ fn test_tcp_blocks_by_range_single_empty_rpc() {
match sender.next_event().await {
NetworkEvent::PeerConnectedOutgoing(peer_id) => {
// Send a STATUS message
debug!(log, "Sending RPC");
debug!("Sending RPC");
sender
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
.unwrap();
@@ -722,7 +706,7 @@ fn test_tcp_blocks_by_range_single_empty_rpc() {
Response::BlocksByRange(Some(_)) => {
assert_eq!(response, rpc_response.clone());
messages_received += 1;
warn!(log, "Chunk received");
warn!("Chunk received");
}
Response::BlocksByRange(None) => {
// should be exactly 10 messages before terminating
@@ -748,7 +732,7 @@ fn test_tcp_blocks_by_range_single_empty_rpc() {
} => {
if request.r#type == rpc_request {
// send the response
warn!(log, "Receiver got request");
warn!("Receiver got request");
for _ in 1..=messages_to_send {
receiver.send_response(
@@ -788,13 +772,13 @@ fn test_tcp_blocks_by_range_single_empty_rpc() {
#[test]
#[allow(clippy::single_match)]
fn test_tcp_blocks_by_root_chunked_rpc() {
// set up the logging. The level and enabled logging or not
let log_level = Level::Debug;
// Set up the logging.
let log_level = "debug";
let enable_logging = false;
build_tracing_subscriber(log_level, enable_logging);
let messages_to_send = 6;
let log = common::build_log(log_level, enable_logging);
let spec = Arc::new(E::default_spec());
let rt = Arc::new(Runtime::new().unwrap());
@@ -802,7 +786,6 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
rt.block_on(async {
let (mut sender, mut receiver) = common::build_node_pair(
Arc::downgrade(&rt),
&log,
ForkName::Bellatrix,
spec.clone(),
Protocol::Tcp,
@@ -847,7 +830,7 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
match sender.next_event().await {
NetworkEvent::PeerConnectedOutgoing(peer_id) => {
// Send a STATUS message
debug!(log, "Sending RPC");
debug!("Sending RPC");
sender
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
.unwrap();
@@ -866,7 +849,7 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
assert_eq!(response, rpc_response_bellatrix_small.clone());
}
messages_received += 1;
debug!(log, "Chunk received");
debug!("Chunk received");
}
Response::BlocksByRoot(None) => {
// should be exactly messages_to_send
@@ -892,7 +875,7 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
} => {
if request.r#type == rpc_request {
// send the response
debug!(log, "Receiver got request");
debug!("Receiver got request");
for i in 0..messages_to_send {
// Send equal base, altair and bellatrix blocks
@@ -904,7 +887,7 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
rpc_response_bellatrix_small.clone()
};
receiver.send_response(peer_id, id, request.id, rpc_response);
debug!(log, "Sending message");
debug!("Sending message");
}
// send the stream termination
receiver.send_response(
@@ -913,7 +896,7 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
request.id,
Response::BlocksByRange(None),
);
debug!(log, "Send stream term");
debug!("Send stream term");
}
}
_ => {} // Ignore other events
@@ -933,14 +916,14 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
// Tests a streamed, chunked BlocksByRoot RPC Message terminates when all expected reponses have been received
#[test]
fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
// set up the logging. The level and enabled logging or not
let log_level = Level::Debug;
// Set up the logging.
let log_level = "debug";
let enable_logging = false;
build_tracing_subscriber(log_level, enable_logging);
let messages_to_send: u64 = 10;
let extra_messages_to_send: u64 = 10;
let log = common::build_log(log_level, enable_logging);
let spec = Arc::new(E::default_spec());
let rt = Arc::new(Runtime::new().unwrap());
@@ -948,7 +931,6 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
rt.block_on(async {
let (mut sender, mut receiver) = common::build_node_pair(
Arc::downgrade(&rt),
&log,
ForkName::Base,
spec.clone(),
Protocol::Tcp,
@@ -988,7 +970,7 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
match sender.next_event().await {
NetworkEvent::PeerConnectedOutgoing(peer_id) => {
// Send a STATUS message
debug!(log, "Sending RPC");
debug!("Sending RPC");
sender
.send_request(peer_id, AppRequestId::Router, rpc_request.clone())
.unwrap();
@@ -998,12 +980,12 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
id: AppRequestId::Router,
response,
} => {
debug!(log, "Sender received a response");
debug!("Sender received a response");
match response {
Response::BlocksByRoot(Some(_)) => {
assert_eq!(response, rpc_response.clone());
messages_received += 1;
debug!(log, "Chunk received");
debug!("Chunk received");
}
Response::BlocksByRoot(None) => {
// should be exactly messages_to_send
@@ -1044,7 +1026,7 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
)) => {
if request.r#type == rpc_request {
// send the response
warn!(log, "Receiver got request");
warn!("Receiver got request");
message_info = Some((peer_id, id, request.id));
}
}
@@ -1057,7 +1039,7 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
messages_sent += 1;
let (peer_id, stream_id, request_id) = message_info.as_ref().unwrap();
receiver.send_response(*peer_id, *stream_id, *request_id, rpc_response.clone());
debug!(log, "Sending message {}", messages_sent);
debug!("Sending message {}", messages_sent);
if messages_sent == messages_to_send + extra_messages_to_send {
// stop sending messages
return;
@@ -1078,8 +1060,9 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
/// Establishes a pair of nodes and disconnects the pair based on the selected protocol via an RPC
/// Goodbye message.
fn goodbye_test(log_level: Level, enable_logging: bool, protocol: Protocol) {
let log = common::build_log(log_level, enable_logging);
fn goodbye_test(log_level: &str, enable_logging: bool, protocol: Protocol) {
// Set up the logging.
build_tracing_subscriber(log_level, enable_logging);
let rt = Arc::new(Runtime::new().unwrap());
@@ -1088,8 +1071,7 @@ fn goodbye_test(log_level: Level, enable_logging: bool, protocol: Protocol) {
// get sender/receiver
rt.block_on(async {
let (mut sender, mut receiver) =
common::build_node_pair(Arc::downgrade(&rt), &log, ForkName::Base, spec, protocol)
.await;
common::build_node_pair(Arc::downgrade(&rt), ForkName::Base, spec, protocol).await;
// build the sender future
let sender_future = async {
@@ -1097,7 +1079,7 @@ fn goodbye_test(log_level: Level, enable_logging: bool, protocol: Protocol) {
match sender.next_event().await {
NetworkEvent::PeerConnectedOutgoing(peer_id) => {
// Send a goodbye and disconnect
debug!(log, "Sending RPC");
debug!("Sending RPC");
sender.goodbye_peer(
&peer_id,
GoodbyeReason::IrrelevantNetwork,
@@ -1137,18 +1119,16 @@ fn goodbye_test(log_level: Level, enable_logging: bool, protocol: Protocol) {
#[test]
#[allow(clippy::single_match)]
fn tcp_test_goodbye_rpc() {
// set up the logging. The level and enabled logging or not
let log_level = Level::Debug;
let enable_logging = false;
goodbye_test(log_level, enable_logging, Protocol::Tcp);
let log_level = "debug";
let enabled_logging = false;
goodbye_test(log_level, enabled_logging, Protocol::Tcp);
}
// Tests a Goodbye RPC message
#[test]
#[allow(clippy::single_match)]
fn quic_test_goodbye_rpc() {
// set up the logging. The level and enabled logging or not
let log_level = Level::Debug;
let enable_logging = false;
goodbye_test(log_level, enable_logging, Protocol::Quic);
let log_level = "debug";
let enabled_logging = false;
goodbye_test(log_level, enabled_logging, Protocol::Quic);
}