From a3c70ec05a2d09e6fdad81429b472d5d282ad501 Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Fri, 13 Sep 2024 16:51:25 +1000 Subject: [PATCH] add test --- core/node/fee_model/src/lib.rs | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/core/node/fee_model/src/lib.rs b/core/node/fee_model/src/lib.rs index dc87eb44d69c..0275e0c0d798 100644 --- a/core/node/fee_model/src/lib.rs +++ b/core/node/fee_model/src/lib.rs @@ -287,7 +287,10 @@ mod tests { use l1_gas_price::GasAdjusterClient; use zksync_config::{configs::eth_sender::PubdataSendingMode, GasAdjusterConfig}; use zksync_eth_client::{clients::MockSettlementLayer, BaseFees}; - use zksync_types::{commitment::L1BatchCommitmentMode, fee_model::BaseTokenConversionRatio}; + use zksync_types::{ + block::L1BatchHeader, commitment::L1BatchCommitmentMode, + fee_model::BaseTokenConversionRatio, L1BatchNumber, + }; use super::*; @@ -795,4 +798,41 @@ mod tests { .await .expect("Failed to create GasAdjuster") } + + #[tokio::test] + async fn test_take_fee_input_from_unsealed_batch() { + let sealed_batch_fee_input = BatchFeeInput::pubdata_independent(1, 2, 3); + let unsealed_batch_fee_input = BatchFeeInput::pubdata_independent(101, 102, 103); + + let pool = ConnectionPool::::test_pool().await; + let mut conn = pool.connection().await.unwrap(); + let l1_batch_header = L1BatchHeader { + number: L1BatchNumber(1), + timestamp: 1, + l1_tx_count: 0, + l2_tx_count: 0, + priority_ops_onchain_data: vec![], + l2_to_l1_logs: vec![], + l2_to_l1_messages: vec![], + bloom: Default::default(), + used_contract_hashes: vec![], + base_system_contracts_hashes: Default::default(), + system_logs: vec![], + protocol_version: None, + pubdata_input: None, + batch_fee_input: sealed_batch_fee_input, + }; + conn.blocks_dal() + .insert_mock_l1_batch(&l1_batch_header) + .await + .unwrap(); + conn.blocks_dal() + .insert_l1_batch(L1BatchNumber(2), 2, unsealed_batch_fee_input) + .await + .unwrap(); + let provider = + ApiFeeInputProvider::new(Arc::new(MockBatchFeeParamsProvider::default()), pool); + let fee_input = provider.get_batch_fee_input_scaled(1.0, 1.0).await.unwrap(); + assert_eq!(fee_input, unsealed_batch_fee_input); + } }