From 32c4400f94aebd40e87ede986017604dff81d308 Mon Sep 17 00:00:00 2001 From: Bohdan Ohorodnii Date: Mon, 12 Aug 2024 12:56:21 +0300 Subject: [PATCH] feat: add syscall failure format --- .../syscalls/syscall_tests/failure_format.rs | 23 +++++++++++++++++++ .../execution/syscalls/syscall_tests/mod.rs | 1 + 2 files changed, 24 insertions(+) create mode 100644 crates/blockifier/src/execution/syscalls/syscall_tests/failure_format.rs diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/failure_format.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/failure_format.rs new file mode 100644 index 0000000000..27891c2f2d --- /dev/null +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/failure_format.rs @@ -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\"."); +} diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/mod.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/mod.rs index 3f048e319a..fbebf14ba8 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/mod.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/mod.rs @@ -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;