Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 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
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
38 changes: 23 additions & 15 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
cairo_programs/**/*.json
!cairo_programs/manually_compiled/*
cairo_programs/cairo-1-programs/bitwise.sierra
vm/src/tests/cairo_test_suite/**/*.json
TEST_COLLECT_COVERAGE: 1
PROPTEST_CASES: 100

Expand Down Expand Up @@ -46,6 +47,7 @@ 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 All @@ -66,7 +68,7 @@ jobs:
id: cache-programs
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}

# This is not pretty, but we need `make` to see the compiled programs are
# actually newer than the sources, otherwise it will try to rebuild them
Expand Down Expand Up @@ -120,37 +122,43 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_test_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Fetch proof programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Fetch bench programs
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_bench_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
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:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_1_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_1_test_contracts-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 2)
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_2_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_2_test_contracts-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true
- name: Merge caches
uses: actions/cache/save@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}

lint:
needs: merge-caches
Expand Down Expand Up @@ -179,7 +187,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Run clippy
Expand Down Expand Up @@ -229,7 +237,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

# NOTE: we do this separately because --workspace operates in weird ways
Expand Down Expand Up @@ -274,7 +282,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Check all features (workspace)
Expand Down Expand Up @@ -309,7 +317,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Install testing tools
Expand Down Expand Up @@ -409,7 +417,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

# This is not pretty, but we need `make` to see the compiled programs are
Expand Down Expand Up @@ -456,7 +464,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Generate traces
Expand Down Expand Up @@ -675,7 +683,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Run script
Expand Down Expand Up @@ -715,7 +723,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CAIRO_PROGRAMS_PATH }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'Makefile', 'requirements.txt') }}
key: cairo_proof_programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'vm/src/tests/cairo_test_suite/**/*.cairo', 'Makefile', 'requirements.txt') }}
fail-on-cache-miss: true

- name: Fetch pie
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
**/*.json
!hint_accountant/whitelists/*.json
!cairo_programs/manually_compiled/*.json
!vm/src/test_helpers/dummy.json
**/*.casm
**/*.sierra
**/*.trace
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Both branches support Stwo prover opcodes (Blake2s, QM31) since v2.0.0.
---

#### Upcoming Changes
* 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)

* 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)

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

Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UNAME := $(shell uname)
compare_trace_memory compare_trace compare_memory compare_pie compare_all_no_proof \
compare_trace_memory_proof compare_all_proof compare_trace_proof compare_memory_proof compare_air_public_input compare_air_private_input\
hyper-threading-benchmarks \
cairo_bench_programs cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_2_test_contracts \
cairo_bench_programs cairo_proof_programs cairo_test_programs cairo_test_suite_programs cairo_1_test_contracts cairo_2_test_contracts \
cairo_trace cairo-vm_trace cairo_proof_trace cairo-vm_proof_trace python-deps python-deps-macos \
build-cairo-lang hint-accountant \ create-proof-programs-symlinks \
$(RELBIN) $(DBGBIN)
Expand Down Expand Up @@ -124,6 +124,10 @@ NORETROCOMPAT_DIR:=cairo_programs/noretrocompat
NORETROCOMPAT_FILES:=$(wildcard $(NORETROCOMPAT_DIR)/*.cairo)
COMPILED_NORETROCOMPAT_TESTS:=$(patsubst $(NORETROCOMPAT_DIR)/%.cairo, $(NORETROCOMPAT_DIR)/%.json, $(NORETROCOMPAT_FILES))

CAIRO_TEST_SUITE_ROOT:=vm/src/tests/cairo_test_suite
CAIRO_TEST_SUITE_FILES:=$(shell find $(CAIRO_TEST_SUITE_ROOT) -name "*.cairo")
COMPILED_CAIRO_TEST_SUITE:=$(patsubst %.cairo,%.json,$(CAIRO_TEST_SUITE_FILES))

$(BENCH_DIR)/%.json: $(BENCH_DIR)/%.cairo
cairo-compile --cairo_path="$(TEST_DIR):$(BENCH_DIR)" $< --output $@ --proof_mode

Expand All @@ -145,6 +149,9 @@ $(BAD_TEST_DIR)/%.json: $(BAD_TEST_DIR)/%.cairo
$(PRINT_TEST_DIR)/%.json: $(PRINT_TEST_DIR)/%.cairo
cairo-compile $< --output $@

$(CAIRO_TEST_SUITE_ROOT)/%.json: $(CAIRO_TEST_SUITE_ROOT)/%.cairo
cairo-compile $< --output $@

# ======================
# Test Cairo 1 Contracts
# ======================
Expand Down Expand Up @@ -268,6 +275,8 @@ run:
check:
cargo 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_proof_programs: $(COMPILED_PROOF_TESTS) $(COMPILED_MOD_BUILTIN_PROOF_TESTS) $(COMPILED_STWO_EXCLUSIVE_TESTS)
cairo_bench_programs: $(COMPILED_BENCHES)
Expand All @@ -286,7 +295,7 @@ ifdef TEST_COLLECT_COVERAGE
TEST_COMMAND:=cargo llvm-cov nextest --no-report
endif

test: cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_2_test_contracts cairo_1_program
test: cairo_proof_programs cairo_test_programs cairo_test_suite_programs cairo_1_test_contracts cairo_2_test_contracts cairo_1_program
$(TEST_COMMAND) --workspace --features "test_utils, cairo-1-hints"
test-extensive_hints: cairo_proof_programs cairo_test_programs cairo_1_test_contracts cairo_1_program cairo_2_test_contracts
$(TEST_COMMAND) --workspace --features "test_utils, cairo-1-hints, cairo-0-secp-hints, cairo-0-data-availability-hints, extensive_hints"
Expand Down
3 changes: 3 additions & 0 deletions vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pub mod types;
pub mod utils;
pub mod vm;

#[cfg(feature = "test_utils")]
pub mod test_helpers;

// TODO: use `Felt` directly
pub use starknet_types_core::felt::Felt as Felt252;

Expand Down
69 changes: 69 additions & 0 deletions vm/src/test_helpers/dummy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"attributes": [],
"builtins": [],
"compiler_version": "0.13.5",
"data": [
"0x208b7fff7fff7ffe"
],
"debug_info": {
"file_contents": {},
"instruction_locations": {
"0": {
"accessible_scopes": [
"__main__",
"__main__.main"
],
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 0
},
"reference_ids": {}
},
"hints": [],
"inst": {
"end_col": 15,
"end_line": 2,
"input_file": {
"filename": "vm/src/test_helpers/dummy.cairo"
},
"start_col": 5,
"start_line": 2
}
}
}
},
"hints": {},
"identifiers": {
"__main__.main": {
"decorators": [],
"pc": 0,
"type": "function"
},
"__main__.main.Args": {
"full_name": "__main__.main.Args",
"members": {},
"size": 0,
"type": "struct"
},
"__main__.main.ImplicitArgs": {
"full_name": "__main__.main.ImplicitArgs",
"members": {},
"size": 0,
"type": "struct"
},
"__main__.main.Return": {
"cairo_type": "()",
"type": "type_definition"
},
"__main__.main.SIZEOF_LOCALS": {
"type": "const",
"value": 0
}
},
"main_scope": "__main__",
"prime": "0x800000000000011000000000000000000000000000000000000000000000001",
"reference_manager": {
"references": []
}
}
Loading
Loading