Skip to content

Commit

Permalink
chore(blockifier): fix default strk l2 gas price test util
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Dec 4, 2024
1 parent f1030a1 commit 0dcf39a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
18 changes: 18 additions & 0 deletions crates/blockifier/src/versioned_constants_test.rs
Original file line number Diff line number Diff line change
@@ -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::*;

Expand Down Expand Up @@ -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());
}
2 changes: 1 addition & 1 deletion crates/starknet_api/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
];

Expand Down

0 comments on commit 0dcf39a

Please sign in to comment.