-
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.
refactor(blockifier): format retdata in ExecutionFailed and PanicInVa…
…lidate errors
- Loading branch information
1 parent
b5a8777
commit 8921342
Showing
7 changed files
with
40 additions
and
26 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
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
38 changes: 24 additions & 14 deletions
38
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,23 +1,33 @@ | ||
use cairo_lang_utils::byte_array::BYTE_ARRAY_MAGIC; | ||
use starknet_types_core::felt::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 = 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 }; | ||
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 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\"."); | ||
} |
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