Skip to content

Commit f2185d9

Browse files
starknet_os_flow_tests: fuzz test call scenario
1 parent 1935464 commit f2185d9

10 files changed

Lines changed: 1256 additions & 470 deletions

File tree

crates/blockifier_test_utils/resources/feature_contracts/cairo0/compiled/fuzz_revert_compiled.json

Lines changed: 90 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
],
3939
"EXTERNAL": [
4040
{
41-
"offset": 177,
41+
"offset": 206,
4242
"selector": "0x8e64dfac867f301a439703710296f437e9f91d1bba17cfea5ad7f137a5acd"
4343
},
4444
{
@@ -49,7 +49,28 @@
4949
"L1_HANDLER": []
5050
},
5151
"program": {
52-
"attributes": [],
52+
"attributes": [
53+
{
54+
"accessible_scopes": [
55+
"__main__",
56+
"__main__",
57+
"__main__.test_revert_fuzz"
58+
],
59+
"end_pc": 202,
60+
"flow_tracking_data": {
61+
"ap_tracking": {
62+
"group": 17,
63+
"offset": 55
64+
},
65+
"reference_ids": {
66+
"__main__.test_revert_fuzz.scenario": 4
67+
}
68+
},
69+
"name": "error_message",
70+
"start_pc": 198,
71+
"value": "Unknown scenario: {scenario}."
72+
}
73+
],
5374
"builtins": [
5475
"pedersen",
5576
"range_check"
@@ -227,18 +248,47 @@
227248
"0x48127ffc7fff8000",
228249
"0x48127ffc7fff8000",
229250
"0x208b7fff7fff7ffe",
230-
"0x48127ffc7fff8000",
231-
"0x48127ffc7fff8000",
232-
"0x48127ffc7fff8000",
251+
"0x4826800180018000",
252+
"0x800000000000011000000000000000000000000000000000000000000000000",
253+
"0x20680017fff7fff",
254+
"0x19",
255+
"0x48127ffb7fff8000",
256+
"0x48127ffb7fff8000",
257+
"0x48127ffb7fff8000",
258+
"0x480a80007fff8000",
259+
"0x1104800180018000",
260+
"0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffcf",
261+
"0x1104800180018000",
262+
"0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffff4d",
263+
"0x48127ff77fff8000",
264+
"0x48127ff97fff8000",
265+
"0x480680017fff8000",
266+
"0x8e64dfac867f301a439703710296f437e9f91d1bba17cfea5ad7f137a5acd",
267+
"0x480680017fff8000",
268+
"0x0",
269+
"0x48127ffb7fff8000",
270+
"0x1104800180018000",
271+
"0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffff49",
272+
"0x48127ffd7fff8000",
273+
"0x48127fec7fff8000",
274+
"0x48127fec7fff8000",
233275
"0x1104800180018000",
234-
"0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffe6",
276+
"0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffd1",
277+
"0x208b7fff7fff7ffe",
278+
"0x480680017fff8000",
279+
"0x0",
280+
"0x400680017fff7fff",
281+
"0x1",
282+
"0x48127ffa7fff8000",
283+
"0x48127ffa7fff8000",
284+
"0x48127ffa7fff8000",
235285
"0x208b7fff7fff7ffe",
236286
"0x402b7ffd7ffc7ffd",
237287
"0x480280007ffb8000",
238288
"0x480280017ffb8000",
239289
"0x480280027ffb8000",
240290
"0x1104800180018000",
241-
"0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffdf",
291+
"0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffc2",
242292
"0x40780017fff7fff",
243293
"0x1",
244294
"0x48127ffc7fff8000",
@@ -359,7 +409,7 @@
359409
}
360410
}
361411
],
362-
"183": [
412+
"212": [
363413
{
364414
"accessible_scopes": [
365415
"__main__",
@@ -379,6 +429,10 @@
379429
]
380430
},
381431
"identifiers": {
432+
"__main__.FUZZ_TEST_SELECTOR": {
433+
"type": "const",
434+
"value": 15724280504397459906927412945650388641747292702364032215010569113747217101
435+
},
382436
"__main__.HashBuiltin": {
383437
"destination": "starkware.cairo.common.cairo_builtins.HashBuiltin",
384438
"type": "alias"
@@ -387,6 +441,10 @@
387441
"type": "const",
388442
"value": 1148028502779661890523359593720089131979067183173988258322045506921168040387
389443
},
444+
"__main__.SCENARIO_CALL": {
445+
"type": "const",
446+
"value": 1
447+
},
390448
"__main__.SCENARIO_RETURN": {
391449
"type": "const",
392450
"value": 0
@@ -730,6 +788,21 @@
730788
"type": "const",
731789
"value": 2
732790
},
791+
"__main__.test_revert_fuzz.scenario": {
792+
"cairo_type": "felt",
793+
"full_name": "__main__.test_revert_fuzz.scenario",
794+
"references": [
795+
{
796+
"ap_tracking_data": {
797+
"group": 17,
798+
"offset": 54
799+
},
800+
"pc": 165,
801+
"value": "[cast(fp + 1, felt*)]"
802+
}
803+
],
804+
"type": "reference"
805+
},
733806
"__wrappers__.constructor": {
734807
"decorators": [
735808
"constructor"
@@ -804,7 +877,7 @@
804877
"decorators": [
805878
"external"
806879
],
807-
"pc": 177,
880+
"pc": 206,
808881
"type": "function"
809882
},
810883
"__wrappers__.test_revert_fuzz.Args": {
@@ -2121,6 +2194,14 @@
21212194
},
21222195
"pc": 34,
21232196
"value": "[cast(fp + (-3), felt*)]"
2197+
},
2198+
{
2199+
"ap_tracking_data": {
2200+
"group": 17,
2201+
"offset": 54
2202+
},
2203+
"pc": 165,
2204+
"value": "[cast(fp + 1, felt*)]"
21242205
}
21252206
]
21262207
}

crates/blockifier_test_utils/resources/feature_contracts/cairo0/fuzz_revert.cairo

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ from starkware.starknet.common.syscalls import call_contract
77
// Scenarios.
88
// The RETURN scenario *must* be zero, as the zero value also indicates end of scenario stream.
99
const SCENARIO_RETURN = 0;
10+
const SCENARIO_CALL = 1;
1011

1112
// selector_from_name("pop_front").
1213
const POP_FRONT_SELECTOR = 0x289c2d7d6351cd03d4f928bde75fa14d5f52e32bdbc750d5296e1b48c12f1c3;
14+
// selector_from_name("test_revert_fuzz").
15+
const FUZZ_TEST_SELECTOR = 0x8e64dfac867f301a439703710296f437e9f91d1bba17cfea5ad7f137a5acd;
1316

1417
@storage_var
1518
func orchestrator_address() -> (address: felt) {
@@ -68,6 +71,19 @@ func test_revert_fuzz{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_chec
6871
return ();
6972
}
7073

71-
test_revert_fuzz();
74+
if (scenario == SCENARIO_CALL) {
75+
call_contract(
76+
contract_address=pop_front(orchestrator),
77+
function_selector=FUZZ_TEST_SELECTOR,
78+
calldata_size=0,
79+
calldata=new(),
80+
);
81+
test_revert_fuzz();
82+
return ();
83+
}
84+
85+
with_attr error_message("Unknown scenario: {scenario}.") {
86+
assert 1 = 0;
87+
}
7288
return ();
7389
}

0 commit comments

Comments
 (0)