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 9, 2024
1 parent 4760d79 commit 71ef06d
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 @@ -133,7 +133,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(
"0x7d62e32fd8f1a12104a5d215af26ec0f362da81af3d14c24e08e46976cdfbf5",
"0x78cdcd66ef1a1a42a7371e6a404fdd7128e60b9112343d50fad31fbdbe62d9e",
),
Felt::from_hex_unchecked(
"0x259aeaad847bffe6c342998c4510e5e474577219cfbb118f5cb2f2286260d52",
"0x7666c8a2ba55220e85f64e91897ab17d1a6e74b72cfbaa65e59d50af0a87cef",
),
];

Expand Down

0 comments on commit 71ef06d

Please sign in to comment.