Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
itegulov committed Sep 13, 2024
1 parent 985cf8a commit a3c70ec
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion core/node/fee_model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down Expand Up @@ -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::<Core>::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);
}
}

0 comments on commit a3c70ec

Please sign in to comment.