-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(blockifier): add address and selector for intermediate cairo1 re…
…vert errors
- Loading branch information
1 parent
75b7b99
commit dcc2473
Showing
5 changed files
with
128 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 14 additions & 18 deletions
32
crates/blockifier/src/execution/syscalls/syscall_tests/failure_format.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
use cairo_lang_utils::byte_array::BYTE_ARRAY_MAGIC; | ||
use starknet_types_core::felt::Felt; | ||
use starknet_api::core::{ContractAddress, EntryPointSelector}; | ||
use starknet_api::felt; | ||
|
||
use crate::execution::call_info::{CallExecution, CallInfo, Retdata}; | ||
use crate::execution::errors::EntryPointExecutionError; | ||
use crate::execution::stack_trace::extract_trailing_cairo1_revert_trace; | ||
|
||
#[test] | ||
fn test_syscall_failure_format() { | ||
let error_data = Retdata( | ||
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 execution_failure = "0x457865637574696f6e206661696c757265"; | ||
let error_data = Retdata(vec![felt!(execution_failure)]); | ||
let callinfo = CallInfo { | ||
execution: CallExecution { retdata: error_data, failed: true, ..Default::default() }, | ||
..Default::default() | ||
}; | ||
let error = EntryPointExecutionError::ExecutionFailed { | ||
error_trace: extract_trailing_cairo1_revert_trace(&callinfo), | ||
}; | ||
assert_eq!(error.to_string(), "Execution failed. Failure reason: \"Execution failure\"."); | ||
assert_eq!( | ||
error.to_string(), | ||
format!( | ||
"Execution failed. Failure reason: | ||
Error in contract (contract address: {:#064x}, selector: {:#064x}): | ||
{execution_failure} ('Execution failure').", | ||
ContractAddress::default().0.key(), | ||
EntryPointSelector::default().0 | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters