Skip to content

Commit

Permalink
prefer simulate transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed Jun 19, 2024
1 parent 3a4ea49 commit c2b71b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/governor.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@ pub mod Governor {
fn __execute__(ref self: ContractState, mut calls: Array<Call>) -> Array<Span<felt252>> {
assert(get_caller_address().is_zero(), 'Invalid caller');
let tx_version = get_tx_info().unbox().version.into();
assert(tx_version == 1 || tx_version == 3, 'Invalid TX version');
assert(
tx_version == 0x100000000000000000000000000000001
|| tx_version == 0x100000000000000000000000000000003,
'Invalid TX version'
);
let mut results: Array<Span<felt252>> = array![];
while let Option::Some(call) = calls.pop_front() {
results.append(call.execute());
Expand Down
16 changes: 15 additions & 1 deletion src/governor_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -1041,12 +1041,26 @@ fn test_governor_execute_fails_from_non_zero() {

#[test]
#[should_panic(expected: ('Invalid TX version', 'ENTRYPOINT_FAILED'))]
fn test_governor_execute_fails_invalid_tx_version() {
fn test_governor_execute_fails_tx_version_0() {
let (_staker, _token, governor, _config) = setup();
set_version(0);
AccountContractDispatcher { contract_address: governor.contract_address }.__execute__(array![]);
}

#[test]
#[should_panic(expected: ('Invalid TX version', 'ENTRYPOINT_FAILED'))]
fn test_governor_execute_fails_tx_version_1() {
let (_staker, _token, governor, _config) = setup();
set_version(1);
AccountContractDispatcher { contract_address: governor.contract_address }.__execute__(array![]);
}

#[test]
fn test_governor_execute_succeeds_version_simulate() {
let (_staker, _token, governor, _config) = setup();
set_version(0x100000000000000000000000000000001);
AccountContractDispatcher { contract_address: governor.contract_address }.__execute__(array![]);
}

#[test]
fn test_reconfigure_succeeds_self_call() {
Expand Down

0 comments on commit c2b71b8

Please sign in to comment.