Skip to content

Commit

Permalink
test(blockifier): test contract for validate and execute merging
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavGrs committed Dec 4, 2024
1 parent 9a66da9 commit 3ef88f8
Show file tree
Hide file tree
Showing 4 changed files with 1,089 additions and 352 deletions.
21 changes: 21 additions & 0 deletions crates/blockifier/feature_contracts/cairo1/account_faulty.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ mod Account {
const GET_BLOCK_HASH: felt252 = 3;
// Use get_execution_info syscall.
const GET_EXECUTION_INFO: felt252 = 4;
// Write to the storage.
const STORAGE_WRITE: felt252 = 8;

// get_selector_from_name('foo').
const FOO_ENTRY_POINT_SELECTOR: felt252 = (
0x1b1a0649752af1b28b3dc29a1556eee781e4a4c3a1f7f53f90fa834de098c4d
);

const STORAGE_WRITE_KEY: felt252 = 15;

#[storage]
struct Storage {
}
Expand Down Expand Up @@ -80,6 +84,16 @@ mod Account {
selector: felt252,
calldata: Array<felt252>
) -> felt252 {
let tx_info = starknet::get_tx_info().unbox();
let signature = tx_info.signature;
let scenario = *signature[0_u32];

if (scenario == STORAGE_WRITE) {
let key = STORAGE_WRITE_KEY.try_into().unwrap();
let value: felt252 = *signature[2_u32];
starknet::syscalls::storage_write_syscall(0, key, value).unwrap_syscall();
}

let to_address = 0;

send_message_to_l1_syscall(
Expand Down Expand Up @@ -129,6 +143,13 @@ mod Account {
return starknet::VALIDATED;
}

if (scenario == STORAGE_WRITE) {
let key = STORAGE_WRITE_KEY.try_into().unwrap();
let value: felt252 = *signature[1_u32];
starknet::syscalls::storage_write_syscall(0, key, value).unwrap_syscall();
return starknet::VALIDATED;
}

assert (scenario == GET_EXECUTION_INFO, 'Unknown scenario');

let block_number: felt252 = *signature[1_u32];
Expand Down
Loading

0 comments on commit 3ef88f8

Please sign in to comment.