Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Added a test of formatting an error of entry point execution failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvalsw committed Nov 2, 2023
1 parent 434bc5e commit 7a3c952
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions crates/blockifier/src/execution/syscalls/syscalls_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,29 @@ fn test_out_of_gas() {
assert_matches!(error, EntryPointExecutionError::ExecutionFailed{ error_data }
if error_data == vec![stark_felt!(OUT_OF_GAS_ERROR)]);
}

// TODO(yuval): This test should fail once upgrading the dependency on cairo-lang-runner to version
// 2.4.0. To fix it, merge PR https://github.com/starkware-libs/blockifier/pull/1064.
#[test]
fn test_syscall_failure_format() {
assert_eq!(
get_dummy_string_execution_error().to_string(),
"Execution failed. Failure reason: \
\"0x046a6158a16a947e5916b2a2ca68501a45e93d7110e81aa2d6438b1c57c879a3, , Execution \
failure, \\u{11}\"."
);
}

// TODO(yuval): when updating to compiler of version 2.4.0, use from
// `cairo_lang_utils::byte_array::BYTE_ARRAY_MAGIC` instead.
const BYTE_ARRAY_MAGIC: &str = "0x457865637574696f6e206661696c757265";

// "Execution failure"
const DUMMY_EXECUTION_FAILURE_ERROR: &str = "0x457865637574696f6e206661696c757265";
fn get_dummy_string_execution_error() -> EntryPointExecutionError {
let out_of_range_error = vec![BYTE_ARRAY_MAGIC, "0x00", DUMMY_EXECUTION_FAILURE_ERROR, "0x11"]
.into_iter()
.map(|x| StarkFelt::try_from(x).unwrap())
.collect();
return EntryPointExecutionError::ExecutionFailed { error_data: out_of_range_error };
}

0 comments on commit 7a3c952

Please sign in to comment.