From 0dcf39aede6d34cc35a910be504f7e3771fe9d93 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Wed, 27 Nov 2024 14:28:59 +0200 Subject: [PATCH] chore(blockifier): fix default strk l2 gas price test util --- .../blockifier/src/versioned_constants_test.rs | 18 ++++++++++++++++++ crates/starknet_api/src/test_utils.rs | 2 +- .../tests/end_to_end_flow_test.rs | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/blockifier/src/versioned_constants_test.rs b/crates/blockifier/src/versioned_constants_test.rs index 320f38aa90..22a4d8baa6 100644 --- a/crates/blockifier/src/versioned_constants_test.rs +++ b/crates/blockifier/src/versioned_constants_test.rs @@ -1,5 +1,8 @@ use glob::{glob, Paths}; use pretty_assertions::assert_eq; +use rstest::rstest; +use starknet_api::block::NonzeroGasPrice; +use starknet_api::test_utils::{DEFAULT_STRK_L1_GAS_PRICE, DEFAULT_STRK_L2_GAS_PRICE}; use super::*; @@ -193,3 +196,18 @@ fn test_syscall_gas_cost_calculation() { EXPECTED_SHA256PROCESSBLOCK_GAS_COST ); } + +#[rstest] +#[case::strk(DEFAULT_STRK_L1_GAS_PRICE, DEFAULT_STRK_L2_GAS_PRICE)] +fn test_convert_l1_to_l2_gas_price_round_up( + #[case] l1_gas_price: NonzeroGasPrice, + #[case] expected_l2_gas_price: NonzeroGasPrice, +) { + let result_l2_gas_price = NonzeroGasPrice::new( + VersionedConstants::latest_constants() + .convert_l1_to_l2_gas_price_round_up(l1_gas_price.into()), + ) + .unwrap(); + + assert_eq!(expected_l2_gas_price.get(), result_l2_gas_price.get()); +} diff --git a/crates/starknet_api/src/test_utils.rs b/crates/starknet_api/src/test_utils.rs index da0968f679..f68d9c26f7 100644 --- a/crates/starknet_api/src/test_utils.rs +++ b/crates/starknet_api/src/test_utils.rs @@ -136,7 +136,7 @@ pub const DEFAULT_ETH_L1_DATA_GAS_PRICE: NonzeroGasPrice = pub const DEFAULT_STRK_L1_DATA_GAS_PRICE: NonzeroGasPrice = NonzeroGasPrice::new_unchecked(GasPrice(u128::pow(10, 9))); // Given in units of STRK. pub const DEFAULT_STRK_L2_GAS_PRICE: NonzeroGasPrice = - NonzeroGasPrice::new_unchecked(GasPrice(u128::pow(10, 9))); + NonzeroGasPrice::new_unchecked(GasPrice(25 * u128::pow(10, 5))); // Deprecated transactions: pub const MAX_FEE: Fee = DEFAULT_L1_GAS_AMOUNT.nonzero_saturating_mul(DEFAULT_ETH_L1_GAS_PRICE); diff --git a/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs b/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs index 2a808996ce..84d05e9771 100644 --- a/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs +++ b/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs @@ -44,10 +44,10 @@ async fn end_to_end(mut tx_generator: MultiAccountTransactionGenerator) { let heights_to_build = next_height.iter_up_to(LAST_HEIGHT.unchecked_next()); let expected_content_ids = [ Felt::from_hex_unchecked( - "0x4597ceedbef644865917bf723184538ef70d43954d63f5b7d8cb9d1bd4c2c32", + "0x877e2a4bfbe9a42a72da964d0470a4c4c864185211d16d2c310d30632b58e2", ), Felt::from_hex_unchecked( - "0x7e2c0e448bea6bbf00962017d8addd56c6146d5beb5a273b2e02f5fb862d20f", + "0x4f0a0632b3ac70723868b25aacd892fb9b5ffbf95601d19426a238aa89013b2", ), ];