Skip to content

Commit

Permalink
feat: add syscall failure format
Browse files Browse the repository at this point in the history
  • Loading branch information
varex83 committed Aug 12, 2024
1 parent 83d1e2d commit 32c4400
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use cairo_lang_utils::byte_array::BYTE_ARRAY_MAGIC;
use starknet_types_core::felt::Felt;

use crate::execution::errors::EntryPointExecutionError;

#[test]
fn test_syscall_failure_format() {
let error_data = vec![
// Magic to indicate that this is a byte array.
BYTE_ARRAY_MAGIC,
// The number of full words in the byte array.
"0x00",
// The pending word of the byte array: "Execution failure"
"0x457865637574696f6e206661696c757265",
// The length of the pending word.
"0x11",
]
.into_iter()
.map(|x| Felt::from_hex(x).unwrap())
.collect();
let error = EntryPointExecutionError::ExecutionFailed { error_data };
assert_eq!(error.to_string(), "Execution failed. Failure reason: \"Execution failure\".");
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod call_contract;
mod constants;
mod deploy;
mod emit_event;
mod failure_format;
mod get_block_hash;
mod get_execution_info;
mod keccak;
Expand Down

0 comments on commit 32c4400

Please sign in to comment.