Skip to content

Extend execution-error assertion macros with patter and any arms#2897

Open
marijamijailovic wants to merge 3 commits into
0xMiden:nextfrom
walnuthq:pr/execution-error-assert-macros
Open

Extend execution-error assertion macros with patter and any arms#2897
marijamijailovic wants to merge 3 commits into
0xMiden:nextfrom
walnuthq:pr/execution-error-assert-macros

Conversation

@marijamijailovic
Copy link
Copy Markdown
Contributor

Closes #2807

Adds two new arms to assert_execution_error! and assert_transaction_executor_error!:

  • matches <pat> [if <guard>] - pattern-match the inner ExecutionError directly, with an optional guard. Useful for variants other than FailedAssertion, or to assert on a specific err_code.
  • any - accept any Err.

The existing $expected arm still works as before; tests passing MasmError constants don't change.

New tests/assertion_macros.rs:

  • Macro grammar - each arm exercised against hand-built errors, plus #[should_panic] checks for the failure paths.
  • VM-driven - small MASM programs run on FastProcessor to trigger and assert real ExecutionError variants end-to-end (DivideByZero, CycleLimitExceeded, MemoryError::UnalignedWordAccess, AdviceError::StackReadFailed, EventError, etc).

@Keinberger Keinberger requested a review from mmagician May 12, 2026 09:32
@Keinberger
Copy link
Copy Markdown
Collaborator

@marijamijailovic Would you mind fixing the broken lint workflow? Seems like something is ill-formatted.

@marijamijailovic marijamijailovic force-pushed the pr/execution-error-assert-macros branch from 969c4de to 0702a68 Compare May 12, 2026 09:58
@marijamijailovic
Copy link
Copy Markdown
Contributor Author

@marijamijailovic Would you mind fixing the broken lint workflow? Seems like something is ill-formatted.
Thanks @Keinberger, formatting should be fixed

@marijamijailovic
Copy link
Copy Markdown
Contributor Author

Changelog check is failing now – should we add the ‎no-changelog flag to this PR, or include an entry in the changelog?

@mmagician mmagician added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label May 15, 2026
Copy link
Copy Markdown
Contributor

@PhilippGackstatter PhilippGackstatter left a comment

Choose a reason for hiding this comment

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

Looks good! I left a few small comments.

Comment thread crates/miden-testing/src/utils.rs Outdated
Comment thread crates/miden-testing/src/utils.rs Outdated
Comment thread crates/miden-testing/src/utils.rs Outdated
Comment thread crates/miden-testing/tests/assertion_macros.rs Outdated
Comment thread crates/miden-testing/src/expected_error.rs Outdated
@marijamijailovic marijamijailovic force-pushed the pr/execution-error-assert-macros branch from 7fa6311 to 58ee194 Compare May 26, 2026 09:34
Copy link
Copy Markdown
Contributor

@PhilippGackstatter PhilippGackstatter left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you!

Comment thread crates/miden-testing/src/executor.rs Outdated
@marijamijailovic marijamijailovic force-pushed the pr/execution-error-assert-macros branch from 58ee194 to 9b783c5 Compare May 26, 2026 14:57
@mmagician
Copy link
Copy Markdown
Collaborator

@marijamijailovic could you please not force push in the future, especially after the changes have already been reviewed? Incremental changes are much easier to review, while a force push looks suspicious as the contributor might have pushed completely unrelated malicious code (not saying this is the case here but just regarding the process). Thanks!

@marijamijailovic
Copy link
Copy Markdown
Contributor Author

@marijamijailovic could you please not force push in the future, especially after the changes have already been reviewed? Incremental changes are much easier to review, while a force push looks suspicious as the contributor might have pushed completely unrelated malicious code (not saying this is the case here but just regarding the process). Thanks!

Sorry about that and thanks for pointing it out @mmagician. I’ll stick to incremental commits after reviews.

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

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend execution-error assertion macros

4 participants