Skip to content

feature(casm): Added blake2s and qm31 encoding tests.#9605

Open
orizi wants to merge 1 commit intomainfrom
orizi/02-04-feature_casm_added_blake2s_and_qm31_encoding_tests
Open

feature(casm): Added blake2s and qm31 encoding tests.#9605
orizi wants to merge 1 commit intomainfrom
orizi/02-04-feature_casm_added_blake2s_and_qm31_encoding_tests

Conversation

@orizi
Copy link
Collaborator

@orizi orizi commented Feb 4, 2026

Summary

Added test cases for encoding Blake2s compression and QM31 assertion instructions. The new tests verify that these instructions are correctly encoded into their binary representation, ensuring proper assembly of complex instructions with various parameters and flags.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

This PR adds test coverage for encoding specialized instructions (Blake2s compression and QM31 assertions) that were previously untested. These tests ensure that the binary encoding of these instructions matches their expected representation, which is critical for the correctness of the Cairo assembly process.


What is the behavior or documentation after?

The test suite now includes specific test cases that verify the encoding of Blake2s compression instructions (with both finalize=true and finalize=false options) and QM31 assertion instructions (with and without ap++). Each test case validates that the instruction is correctly encoded to its expected binary representation.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator Author

orizi commented Feb 4, 2026

@orizi orizi marked this pull request as ready for review February 4, 2026 11:33
@orizi orizi force-pushed the orizi/02-04-feature_casm_added_blake2s_and_qm31_encoding_tests branch from 6fe509a to dc85f9f Compare February 4, 2026 12:41
@orizi orizi force-pushed the orizi/02-04-refactor_casm_using_cell_ref_macro_when_possible branch from 5d9d50d to 6753bb1 Compare February 4, 2026 12:41
SIERRA_UPDATE_NO_CHANGE_TAG=Only new tests.
@orizi orizi changed the base branch from orizi/02-04-refactor_casm_using_cell_ref_macro_when_possible to graphite-base/9605 February 4, 2026 12:52
@orizi orizi force-pushed the orizi/02-04-feature_casm_added_blake2s_and_qm31_encoding_tests branch from dc85f9f to 8414255 Compare February 4, 2026 12:52
@orizi orizi force-pushed the graphite-base/9605 branch from 6753bb1 to 2bd9465 Compare February 4, 2026 12:52
@orizi orizi changed the base branch from graphite-base/9605 to main February 4, 2026 12:53
Copy link
Contributor

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@ilyalesokhin-starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @TomerStarkware).

@ilyalesokhin-starkware
Copy link
Contributor

crates/cairo-lang-casm/src/encoder_test.rs line 169 at r1 (raw file):

    None;
    "{QM31} [ap + 2] = [fp - 1];"
)]

add a test case with an immediate

Code quote:

#[test_case(
    Instruction::new(
        InstructionBody::QM31AssertEq(AssertEqInstruction {
            a: cell_ref!([ap + 2]),
            b: res!([fp + -1]),
        }),
        false,
    ),
    0x1_c00a_7fff_7fff_8002,
    None;
    "{QM31} [ap + 2] = [fp - 1];"
)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants