From 91d373e5f377a24a433fac34b589a1ac162360c1 Mon Sep 17 00:00:00 2001 From: MexicanAce Date: Mon, 18 Sep 2023 17:05:28 +0100 Subject: [PATCH] chore: add trace LogLevel. Update incoming request logs with full params to Trace. Fix unit test. --- src/logging_middleware.rs | 4 ++-- src/main.rs | 2 ++ src/node.rs | 26 +------------------------- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/logging_middleware.rs b/src/logging_middleware.rs index ceaa726e..d99ba059 100644 --- a/src/logging_middleware.rs +++ b/src/logging_middleware.rs @@ -35,7 +35,7 @@ impl Middleware for LoggingMiddleware { { if let Request::Single(Call::MethodCall(method_call)) = &request { match self.log_level_filter { - LevelFilter::Debug => { + LevelFilter::Trace => { let full_params = match &method_call.params { Params::Array(values) => { if values.is_empty() { @@ -47,7 +47,7 @@ impl Middleware for LoggingMiddleware { _ => String::default(), }; - log::debug!("{} was called {}", method_call.method.cyan(), full_params); + log::trace!("{} was called {}", method_call.method.cyan(), full_params); } _ => { // Generate truncated params for requests with massive payloads diff --git a/src/main.rs b/src/main.rs index 6f538247..fd6e2e31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -149,6 +149,7 @@ async fn build_json_http< /// Log filter level for the node. #[derive(Debug, Clone, ValueEnum)] enum LogLevel { + Trace, Debug, Info, Warn, @@ -158,6 +159,7 @@ enum LogLevel { impl From for LevelFilter { fn from(value: LogLevel) -> Self { match value { + LogLevel::Trace => LevelFilter::Trace, LogLevel::Debug => LevelFilter::Debug, LogLevel::Info => LevelFilter::Info, LogLevel::Warn => LevelFilter::Warn, diff --git a/src/node.rs b/src/node.rs index 812b0ff6..bae5f483 100644 --- a/src/node.rs +++ b/src/node.rs @@ -2120,31 +2120,7 @@ mod tests { async fn test_get_fee_history_with_multiple_blocks() { // Arrange let node = InMemoryNode::::default(); - - let private_key = H256::random(); - let from_account = PackedEthSignature::address_from_private_key(&private_key) - .expect("failed generating address"); - node.set_rich_account(from_account); - let mut tx = L2Tx::new_signed( - Address::random(), - vec![], - Nonce(0), - Fee { - gas_limit: U256::from(1_000_000), - max_fee_per_gas: U256::from(250_000_000), - max_priority_fee_per_gas: U256::from(250_000_000), - gas_per_pubdata_limit: U256::from(20000), - }, - U256::from(1), - L2ChainId(260), - &private_key, - None, - Default::default(), - ) - .unwrap(); - tx.set_input(vec![], H256::repeat_byte(0x01)); - - node.apply_txs(vec![tx]).expect("failed applying tx"); + testing::apply_tx(&node, H256::repeat_byte(0x01)); // Act let fee_history = node