Skip to content

Commit 0597a51

Browse files
authored
Ignore cheats test of meta_tx_v0 on cairo-native (#3871)
<!-- Reference any GitHub issues resolved by this PR --> Closes # ## Introduced changes <!-- A brief description of the changes --> - Ignore cheats test of `meta_tx_v0` on `ciaro-native`, since it is not supported ## Checklist <!-- Make sure all of these are complete --> - [ ] Linked relevant issue - [ ] Updated relevant documentation - [x] Added relevant tests - [x] Performed self-review of the code - [ ] Added changes to `CHANGELOG.md`
1 parent 33784c4 commit 0597a51

File tree

3 files changed

+95
-8
lines changed

3 files changed

+95
-8
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/forge/tests/data/contracts/meta_tx_v0_checkers.cairo

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,25 @@ mod CheatBlockHashCheckerMetaTxV0 {
5555
}
5656
}
5757
}
58+
59+
#[starknet::interface]
60+
trait ISimpleCheckerMetaTxV0<TContractState> {
61+
fn __execute__(ref self: TContractState) -> felt252;
62+
}
63+
64+
#[starknet::contract(account)]
65+
mod SimpleCheckerMetaTxV0 {
66+
use starknet::SyscallResultTrait;
67+
use starknet::syscalls::get_block_hash_syscall;
68+
69+
#[storage]
70+
struct Storage {}
71+
72+
#[abi(embed_v0)]
73+
impl ISimpleCheckerMetaTxV0 of super::ISimpleCheckerMetaTxV0<ContractState> {
74+
fn __execute__(ref self: ContractState) -> felt252 {
75+
1234567890.into()
76+
}
77+
}
78+
}
79+

crates/forge/tests/integration/meta_tx_v0.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,67 @@ fn skip_scarb_lt_2_11_0() -> bool {
2121
}
2222
}
2323

24+
#[test]
25+
fn check_meta_tx_v0_syscall_work_without_cheats() {
26+
// TODO(#3704) Remove scarb version check
27+
if skip_scarb_lt_2_11_0() {
28+
return;
29+
}
30+
31+
let test = test_case!(
32+
indoc!(
33+
r#"
34+
use result::ResultTrait;
35+
use array::ArrayTrait;
36+
use option::OptionTrait;
37+
use traits::TryInto;
38+
use starknet::ContractAddress;
39+
use snforge_std::{
40+
declare, ContractClassTrait, DeclareResultTrait
41+
};
42+
43+
#[starknet::interface]
44+
trait IMetaTxV0Test<TContractState> {
45+
fn execute_meta_tx_v0(
46+
ref self: TContractState,
47+
target: starknet::ContractAddress,
48+
signature: Span<felt252>,
49+
) -> felt252;
50+
}
51+
52+
#[test]
53+
fn test_meta_tx_v0_verify_tx_context_modification() {
54+
let checker_contract = declare("SimpleCheckerMetaTxV0").unwrap().contract_class();
55+
let (checker_address, _) = checker_contract.deploy(@ArrayTrait::new()).unwrap();
56+
57+
let meta_contract = declare("MetaTxV0Test").unwrap().contract_class();
58+
let (meta_address, _) = meta_contract.deploy(@ArrayTrait::new()).unwrap();
59+
let meta_dispatcher = IMetaTxV0TestDispatcher { contract_address: meta_address };
60+
61+
let mut signature = ArrayTrait::new();
62+
63+
let result = meta_dispatcher.execute_meta_tx_v0(checker_address, signature.span());
64+
65+
assert(result == 1234567890, 'Result should be 1234567890');
66+
}
67+
"#
68+
),
69+
Contract::from_code_path(
70+
"SimpleCheckerMetaTxV0".to_string(),
71+
Path::new("tests/data/contracts/meta_tx_v0_checkers.cairo"),
72+
)
73+
.unwrap(),
74+
Contract::from_code_path(
75+
"MetaTxV0Test".to_string(),
76+
Path::new("tests/data/contracts/meta_tx_v0_test.cairo"),
77+
)
78+
.unwrap()
79+
);
80+
81+
let result = run_test_case(&test, ForgeTrackedResource::SierraGas);
82+
assert_passed(&result);
83+
}
84+
2485
#[test]
2586
fn meta_tx_v0_with_cheat_caller_address() {
2687
// TODO(#3704) Remove scarb version check
@@ -95,6 +156,10 @@ fn meta_tx_v0_with_cheat_caller_address() {
95156
assert_passed(&result);
96157
}
97158

159+
#[cfg_attr(
160+
feature = "cairo-native",
161+
ignore = "Cheats in `meta_tx_v0` are not supported on `cairo-native`"
162+
)]
98163
#[test]
99164
fn meta_tx_v0_with_cheat_block_hash() {
100165
// TODO(#3704) Remove scarb version check

0 commit comments

Comments
 (0)