-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parsing
EntryPointExecutionError
(#1420)
<!-- Reference any GitHub issues resolved by this PR --> Closes #1406 ## Introduced changes <!-- A brief description of the changes --> - Fix `invalid entry point error` in segment arena test - Fix `assert_panic` macro - The error string from `CallContractFailure::Error` looks now like: ```rust 0x73686f7274737472696e67 ('shortstring')\n0x0 ('')\n0x800000000000011000000000000000000000000000000000000000000000000\n0x73686f7274737472696e6732 ('shortstring2') ``` ## Checklist <!-- Make sure all of these are complete --> - [x] Linked relevant issue - [x] Updated relevant documentation - [x] Added relevant tests - [x] Performed self-review of the code - [x] Added changes to `CHANGELOG.md`
- Loading branch information
Showing
10 changed files
with
109 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
mod panic_call; | ||
mod segment_arena; |
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use crate::common::state::create_cheatnet_state; | ||
use crate::common::{deploy_contract, felt_selector_from_name, state::create_cached_state}; | ||
use crate::{assert_error, assert_panic}; | ||
use cairo_felt::Felt252; | ||
use cheatnet::runtime_extensions::call_to_blockifier_runtime_extension::rpc::call_contract; | ||
use conversions::felt252::FromShortString; | ||
use num_traits::Bounded; | ||
|
||
#[test] | ||
fn call_contract_error() { | ||
let mut cached_state = create_cached_state(); | ||
let (mut blockifier_state, mut cheatnet_state) = create_cheatnet_state(&mut cached_state); | ||
|
||
let contract_address = | ||
deploy_contract(&mut blockifier_state, &mut cheatnet_state, "PanicCall", &[]); | ||
|
||
let selector = felt_selector_from_name("panic_call"); | ||
|
||
let output = call_contract( | ||
&mut blockifier_state, | ||
&mut cheatnet_state, | ||
&contract_address, | ||
&selector, | ||
&[Felt252::from(420)], | ||
) | ||
.unwrap(); | ||
|
||
assert_error!(output, "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473 ('Input too long for arguments')"); | ||
} | ||
|
||
#[test] | ||
fn call_contract_panic() { | ||
let mut cached_state = create_cached_state(); | ||
let (mut blockifier_state, mut cheatnet_state) = create_cheatnet_state(&mut cached_state); | ||
|
||
let contract_address = | ||
deploy_contract(&mut blockifier_state, &mut cheatnet_state, "PanicCall", &[]); | ||
|
||
let selector = felt_selector_from_name("panic_call"); | ||
|
||
let output = call_contract( | ||
&mut blockifier_state, | ||
&mut cheatnet_state, | ||
&contract_address, | ||
&selector, | ||
&[], | ||
) | ||
.unwrap(); | ||
|
||
assert_panic!( | ||
output, | ||
vec![ | ||
Felt252::from_short_string("shortstring").unwrap(), | ||
Felt252::from(0), | ||
Felt252::max_value(), | ||
Felt252::from_short_string("shortstring2").unwrap() | ||
] | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ mod elect; | |
mod starknet; | ||
mod warp; | ||
mod segment_arena_user; | ||
mod panic_call; | ||
mod store_load; |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#[starknet::contract] | ||
mod PanicCall { | ||
#[storage] | ||
struct Storage {} | ||
|
||
#[external(v0)] | ||
fn panic_call(ref self: ContractState) { | ||
panic( | ||
array![ | ||
'shortstring', | ||
0, | ||
0x800000000000011000000000000000000000000000000000000000000000000, | ||
'shortstring2' | ||
] | ||
); | ||
} | ||
} |
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