Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
test(execution): get_sequencer_address in test_validate_accounts_tx
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Feb 13, 2024
1 parent dfb193a commit 64ce1d2
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 65 deletions.
35 changes: 25 additions & 10 deletions crates/blockifier/feature_contracts/cairo0/account_faulty.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
from starkware.cairo.common.alloc import alloc
from starkware.cairo.common.bool import FALSE, TRUE
from starkware.cairo.common.cairo_builtins import HashBuiltin
from starkware.starknet.common.syscalls import TxInfo, call_contract, get_tx_info
from starkware.starknet.common.syscalls import (
TxInfo,
call_contract,
get_sequencer_address,
get_tx_info
)
from starkware.starknet.common.messages import send_message_to_l1

// Validate Scenarios.
Expand All @@ -16,6 +21,12 @@ const VALID = 0;
const INVALID = 1;
// Make a contract call.
const CALL_CONTRACT = 2;
// Use get_block_number syscall.
// const GET_BLOCK_NUMBER = 5;
// Use get_block_timestamp syscall.
// const GET_BLOCK_TIMESTAMP = 6;
// Use get_sequencer_address syscall.
const GET_SEQUENCER_ADDRESS = 7;

// get_selector_from_name('foo').
const FOO_ENTRY_POINT_SELECTOR = (
Expand Down Expand Up @@ -84,16 +95,20 @@ func faulty_validate{syscall_ptr: felt*}() {
assert 0 = 1;
return ();
}
if (scenario == CALL_CONTRACT) {
let contract_address = tx_info.signature[1];
let (calldata: felt*) = alloc();
call_contract(
contract_address=contract_address,
function_selector=FOO_ENTRY_POINT_SELECTOR,
calldata_size=0,
calldata=calldata,
);
return ();
}

assert scenario = CALL_CONTRACT;
let contract_address = tx_info.signature[1];
let (calldata: felt*) = alloc();
call_contract(
contract_address=contract_address,
function_selector=FOO_ENTRY_POINT_SELECTOR,
calldata_size=0,
calldata=calldata,
);
assert scenario = GET_SEQUENCER_ADDRESS;
let sequencer_address = get_sequencer_address();
return ();
}

Expand Down
Loading

0 comments on commit 64ce1d2

Please sign in to comment.