Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f97e022
feat: add test_helpers module (error_utils, test_utils) behind functi…
naor-starkware Mar 26, 2026
0edf8b8
test(test_helpers): add unit tests for assert_mr_eq!, load_cairo_prog…
naor-starkware Mar 29, 2026
298b0c0
style: cargo fmt
naor-starkware Mar 29, 2026
26c995c
test: add conversion-failure and allow-large-err fixes to test_helpers
naor-starkware Mar 29, 2026
39fcf0f
chore: update CHANGELOG for PR #2378
naor-starkware Mar 29, 2026
b4cb481
docs: mark load_cairo_program! example as ignore to suppress llvm-cov…
naor-starkware Mar 29, 2026
2ccebe3
fix: replace unwrap_or_else closures in macros to avoid llvm-cov empt…
naor-starkware Mar 30, 2026
153f306
refactor: update function_runner → test_utils cfg gates and docs
naor-starkware Apr 6, 2026
5e2dd11
refactor: make function_runner module and its methods public
naor-starkware Apr 6, 2026
516a2a5
chore: update CHANGELOG PR link from #2378 to #2381
naor-starkware Apr 6, 2026
53a159f
refactor: replace assert_mr_eq! macro with generic function
naor-starkware Apr 9, 2026
3e693fb
chore: apply cargo fmt
naor-starkware Apr 9, 2026
9b1b8f5
fix: expect_diff_type_comparison and expect_diff_index_comp unwrap Hi…
naor-starkware Apr 9, 2026
c4a8e04
feat(makefile,ci): add cairo_test_suite_programs target and CI integr…
naor-starkware Mar 29, 2026
828320a
chore: update CHANGELOG for PR #2380
naor-starkware Mar 29, 2026
d8f7f68
update CHANGELOG.md
naor-starkware Apr 6, 2026
f0bb2d0
fix(ci): remove stale function_runner feature flag from coverage command
naor-starkware Apr 6, 2026
aa8d90d
feat: add math cairo tests under vm/src/tests/cairo_test_suite
naor-starkware Mar 26, 2026
15d89e7
fix: correct CairoFunctionRunner usage in test_math_cairo.rs
naor-starkware Mar 26, 2026
902b78a
fix(cairo_test_suite): rename cairo file and add horner_eval import
naor-starkware Mar 29, 2026
e41b80f
fix(cairo_test_suite): import all functions from math.cairo
naor-starkware Mar 29, 2026
c775891
refactor(cairo_test_suite): remove redundant numeric type suffixes
naor-starkware Mar 29, 2026
a3f510b
fix: remove assert_not_nullptr import not available in cairo-lang 0.13.5
naor-starkware Mar 29, 2026
78fdc0a
test(math_test_utils): add unit tests for is_quad_residue_mod_prime
naor-starkware Mar 29, 2026
db0283d
style: cargo fmt
naor-starkware Mar 29, 2026
fc935bc
chore: update CHANGELOG for PR #2379
naor-starkware Mar 29, 2026
8c01849
refactor: replace function_runner cfg gates with test_utils in cairo_…
naor-starkware Apr 6, 2026
454d393
fix: replace CairoFunctionRunner with CairoRunner in test_math_cairo
naor-starkware Apr 6, 2026
9326c23
update CHANGELOG.md
naor-starkware Apr 6, 2026
fa68c82
refactor: migrate assert_mr_eq! macro calls to function in test suite
naor-starkware Apr 9, 2026
d6a6c58
chore: apply cargo fmt
naor-starkware Apr 9, 2026
efce14d
feat: add math cairo tests to cairo-vm
OmriEshhar1 Apr 28, 2026
b91624d
fix CI failure
OmriEshhar1 May 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
- cairo_bench_programs
- cairo_proof_programs
- cairo_test_programs
- cairo_test_suite_programs
- cairo_1_test_contracts
- cairo_2_test_contracts
name: Build Cairo programs
Expand Down Expand Up @@ -88,8 +87,7 @@ jobs:
&& matrix.program-target != 'cairo_2_test_contracts'
run: |
make python-deps
. cairo-vm-env/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
echo "$(pwd)/cairo-vm-env/bin" >> $GITHUB_PATH

- name: Install cairo 1 compiler
if: steps.cache-programs.outputs.cache-hit != 'true' && matrix.program-target == 'cairo_1_test_contracts'
Expand All @@ -101,7 +99,9 @@ jobs:

- name: Build programs
if: steps.cache-programs.outputs.cache-hit != 'true'
run: make -j ${{ matrix.program-target }}
run: |
[ -d cairo-vm-env ] && . cairo-vm-env/bin/activate || true
make -j ${{ matrix.program-target }}

# NOTE: used to reduce the amount of cache steps we need in later jobs
# TODO: remove this cache once the workflow finishes
Expand Down Expand Up @@ -136,12 +136,6 @@ jobs:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_bench_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Fetch cairo test suite programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_test_suite_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Fetch test contracts (Cairo 1)
uses: actions/cache/restore@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ Both branches support Stwo prover opcodes (Blake2s, QM31) since v2.0.0.
---

#### Upcoming Changes
* feat: add math Cairo test suite under `vm/src/tests/cairo_test_suite` using the `test_utils` feature flag [#2379](https://github.com/starkware-libs/cairo-vm/pull/2379)

* feat: add `test_helpers` module (`error_utils`, `test_utils`) with `assert_mr_eq`, `load_cairo_program!` macro and `expect_*` error checkers, behind `test_utils` feature flag [#2381](https://github.com/starkware-libs/cairo-vm/pull/2381)

* feat(makefile,ci): add `cairo_test_suite_programs` Makefile target and CI integration to compile Cairo test suite programs before running tests [#2380](https://github.com/starkware-libs/cairo-vm/pull/2380)

* Add Stwo cairo runner API [#2351](https://github.com/starkware-libs/cairo-vm/pull/2351)

* feat: make max traceback entries configurable [#2370](https://github.com/starkware-libs/cairo-vm/pull/2370)

* feat: create and use VirtualMachineConfig [#2369](https://github.com/starkware-libs/cairo-vm/pull/2369)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ check:

cairo_test_suite_programs: $(COMPILED_CAIRO_TEST_SUITE)

cairo_test_programs: $(COMPILED_TESTS) $(COMPILED_BAD_TESTS) $(COMPILED_NORETROCOMPAT_TESTS) $(COMPILED_PRINT_TESTS) $(COMPILED_MOD_BUILTIN_TESTS) $(COMPILED_SECP_CAIRO0_HINTS) $(COMPILED_KZG_DA_CAIRO0_HINTS) $(COMPILED_SEGMENT_ARENA_CAIRO0_HINTS)
cairo_test_programs: $(COMPILED_TESTS) $(COMPILED_BAD_TESTS) $(COMPILED_NORETROCOMPAT_TESTS) $(COMPILED_PRINT_TESTS) $(COMPILED_MOD_BUILTIN_TESTS) $(COMPILED_SECP_CAIRO0_HINTS) $(COMPILED_KZG_DA_CAIRO0_HINTS) $(COMPILED_SEGMENT_ARENA_CAIRO0_HINTS) $(COMPILED_CAIRO_TEST_SUITE)
cairo_proof_programs: $(COMPILED_PROOF_TESTS) $(COMPILED_MOD_BUILTIN_PROOF_TESTS) $(COMPILED_STWO_EXCLUSIVE_TESTS)
cairo_bench_programs: $(COMPILED_BENCHES)
cairo_1_test_contracts: $(CAIRO_1_COMPILED_CASM_CONTRACTS)
Expand Down
31 changes: 31 additions & 0 deletions vm/src/tests/cairo_test_suite/common/math_test.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
%builtins range_check

from starkware.cairo.common.math import (
assert_not_zero,
assert_not_equal,
assert_nn,
assert_le,
assert_lt,
assert_nn_le,
assert_in_range,
assert_250_bit,
split_felt,
assert_le_felt,
assert_lt_felt,
abs_value,
sign,
unsigned_div_rem,
signed_div_rem,
safe_div,
safe_mult,
split_int,
sqrt,
horner_eval,
is_quad_residue,
assert_is_power_of_2,
)


func main{range_check_ptr}() {
return ();
}
37 changes: 37 additions & 0 deletions vm/src/tests/cairo_test_suite/common/math_test_utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::sync::LazyLock;

use crate::{math_utils::is_quad_residue, utils::CAIRO_PRIME};
use num_bigint::BigUint;
use num_integer::Integer;

/// RC_BOUND = 2^128
pub static RC_BOUND: LazyLock<BigUint> = LazyLock::new(|| BigUint::from(2u64).pow(128));

/// MAX_DIV = CAIRO_PRIME // RC_BOUND
pub static MAX_DIV: LazyLock<BigUint> = LazyLock::new(|| CAIRO_PRIME.div_floor(&RC_BOUND));

/// Returns 1 if `a` is a quadratic residue modulo CAIRO_PRIME, 0 if not, and -1 on error.
pub fn is_quad_residue_mod_prime(a: &BigUint) -> i64 {
match is_quad_residue(a, &CAIRO_PRIME) {
Ok(true) => 1,
Ok(false) => 0,
Err(_) => -1,
}
}

#[cfg(test)]
mod tests {
use super::*;

/// Returns 1 for a known quadratic residue: 4 = 2² mod CAIRO_PRIME.
#[test]
fn test_quad_residue_mod_prime_returns_1_for_residue() {
assert_eq!(is_quad_residue_mod_prime(&BigUint::from(4u32)), 1);
}

/// Returns 0 for a known non-residue: 3 is not a square mod CAIRO_PRIME.
#[test]
fn test_quad_residue_mod_prime_returns_0_for_non_residue() {
assert_eq!(is_quad_residue_mod_prime(&BigUint::from(3u32)), 0);
}
}
2 changes: 2 additions & 0 deletions vm/src/tests/cairo_test_suite/common/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod math_test_utils;
mod test_math_cairo;
Loading
Loading