Skip to content

Commit c5bd61b

Browse files
mmsc2fmolettarcatalan98
authored
Linear split test (#1118)
* Implement TryFrom<CasmContractClass> for Program * Add cairo1hintprocessor dependency * Map hints to pc * Add Cairo1HintProcessor * Move cairo-1-hint-processor to cairo-rs crate * fixes * Fix test helper * Remove allow * fix test func * Add builtins to test * Extract builtins from contract_class * Add _builtin to builtin names in etrypoint data * Copy logic from cairo1 contract execution in starknet * Remove unused code * Use lower initial_gas value * Add program segment size argument * Check return values in run_cairo_1_entrypoint fn * Remove debug prints * Add basic fibonacci test * Add another fibonacci case * Always verify secure * Clippy * Compile casm contracts when running test target * Implement a test for linear split hint * Remove unwrap from cell_ref_to_relocatable * Remove paniking macro from extract_buffer * Misc improvements * Misc improvements * Misc improvements * Misc improvements * Remove unwraps & asserts from DictSquashExecScope::pop_current_key * Remove unwraps & asserts from DictManagerExecScope::new_default_dict * Remove expect from get_dict_tracker * Add constants for cairo 1 compiler binaries in makefile * Add cairo 1 compiler to deps target in makefile * Add cairo folder to clean target * Remove todo from execute method * Separate helper functions from Cairo1HintProcessor implementation * Add untracked file * Fix * Add changelog entry * Add a job to compile cairo 1 contracts in ci * Add job dependency * Fix yml syntax * Fix yml syntax * Temporarily extempt cairo-1-hint-processor from codecov * Fix yml syntax * Fix workflow * Remove cache code from new job * Fix yml syntax * Fix wrong path * Fix makefile * Build only compiler binaries * Add cairo-1-contracts-cache * Fetch contracts cache in jobs that need them * Use no-std version of HashMap * Import stdlib::prelude::* * Wrap print in not-wasm block * Remove std path * use slices instead of vec * Make DictSquashExecScope fields private * Add linear split test * Import hint processor dependencies without default features * delete sierra and casm files * -Clippy * Add type * Compile cairo 1 contracts in build-programs job * Rename cache * Use target dependency instead of explicit $(MAKE) * Fix yml syntax * Check for cairo folder before cloning cairo repo * Ommit folder name * Fix tests to cover more cases * Swap paths * Add cairo-1-hints feature flag * Add compile-hint feature to tests run in workflow * Add cairo-1-hints to test_utils * Add cairo-1-hints to test_utils * Use both paths when fetching compiled test data * Remove cairo-1-hints feature from test_utils feature * Move dependencies to cairo-1-hints feature * Update CHANGELOG.md * Fix cfg directive * Modify changelog * Delete merge conflict message * Delete wrong file * Add feature cairo-1-hint to test * Add cairo-1-hints to test workflow * Add Cairo 1 considerations for Gitignore and Makefile (#1144) * Add ignore for casm and sierra files * Add libfunc experimental for cairo 1 compilation * Add new enty to CHANGELOG * Fix clippy * Remove cairo-hint file * fix gitignore * fix changelog --------- Co-authored-by: Federica <[email protected]> Co-authored-by: fmoletta <[email protected]> Co-authored-by: Roberto Catalan <[email protected]>
1 parent bd18580 commit c5bd61b

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ bench/results
1313
.python-version
1414
cairo-rs-env/*
1515
cairo-rs-pypy-env/*
16+
cairo/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[contract]
2+
mod LinearSplit {
3+
use integer::u16_try_from_felt252;
4+
5+
#[external]
6+
fn cast(a: felt252) -> Option<u16> {
7+
u16_try_from_felt252(a)
8+
}
9+
}

src/tests/cairo_1_run_from_entrypoint_tests.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,29 @@ fn divmod_hint_test() {
3535
&[8_usize.into()],
3636
);
3737
}
38+
39+
#[test]
40+
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
41+
fn linear_split() {
42+
let program_data = include_bytes!("../../cairo_programs/cairo-1-contracts/linear_split.casm");
43+
run_cairo_1_entrypoint(
44+
program_data.as_slice(),
45+
0,
46+
&[1_usize.into()],
47+
&[0.into(), 1.into()],
48+
);
49+
50+
run_cairo_1_entrypoint(
51+
program_data.as_slice(),
52+
0,
53+
&[100_usize.into()],
54+
&[0.into(), 100.into()],
55+
);
56+
57+
run_cairo_1_entrypoint(
58+
program_data.as_slice(),
59+
0,
60+
&[1000_usize.into()],
61+
&[0.into(), 1000.into()],
62+
);
63+
}

0 commit comments

Comments
 (0)