Skip to content

Commit

Permalink
test(blockifier_reexecution): get_block_numbers_for_reexecution (star…
Browse files Browse the repository at this point in the history
  • Loading branch information
aner-starkware authored Jan 12, 2025
1 parent b1f93c9 commit 8771d7a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/blockifier_reexecution/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ enum Command {
fn parse_block_numbers_args(block_numbers: Option<Vec<u64>>) -> Vec<BlockNumber> {
block_numbers
.map(|block_numbers| block_numbers.into_iter().map(BlockNumber).collect())
.unwrap_or_else(get_block_numbers_for_reexecution)
.unwrap_or_else(|| get_block_numbers_for_reexecution(None))
}

#[derive(Debug, Args)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use rstest::rstest;
use starknet_api::block::BlockNumber;

use crate::state_reader::utils::reexecute_block_for_testing;
use crate::state_reader::utils::{get_block_numbers_for_reexecution, reexecute_block_for_testing};

#[rstest]
#[case::v_0_13_0(600001)]
Expand All @@ -18,5 +19,9 @@ use crate::state_reader::utils::reexecute_block_for_testing;
#[case::example_l1_handler(868429)]
#[ignore = "Requires downloading JSON files prior to running; Long test, run with --release flag."]
fn test_block_reexecution(#[case] block_number: u64) {
assert!(
get_block_numbers_for_reexecution(Some("../../".to_owned()))
.contains(&BlockNumber(block_number))
);
reexecute_block_for_testing(block_number);
}
9 changes: 5 additions & 4 deletions crates/blockifier_reexecution/src/state_reader/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,11 @@ macro_rules! assert_eq_state_diff {
}

/// Returns the block numbers for re-execution.
/// There is block number for each Starknet Version (starting v0.13)
/// And some additional block with specific transactions.
pub fn get_block_numbers_for_reexecution() -> Vec<BlockNumber> {
let file_path = FULL_RESOURCES_DIR.to_string() + "/block_numbers_for_reexecution.json";
/// There is a block number for each Starknet Version (starting v0.13)
/// And some additional blocks with specific transactions.
pub fn get_block_numbers_for_reexecution(relative_path: Option<String>) -> Vec<BlockNumber> {
let file_path = relative_path.unwrap_or_default()
+ &(FULL_RESOURCES_DIR.to_string() + "/block_numbers_for_reexecution.json");
let block_numbers_examples: HashMap<String, u64> =
serde_json::from_str(&read_to_string(file_path.clone()).expect(
&("Failed to read the block_numbers_for_reexecution file at ".to_string() + &file_path),
Expand Down

0 comments on commit 8771d7a

Please sign in to comment.