Extend execution-error assertion macros with patter and any arms#2897
Conversation
|
@marijamijailovic Would you mind fixing the broken lint workflow? Seems like something is ill-formatted. |
969c4de to
0702a68
Compare
|
|
Changelog check is failing now – should we add the |
PhilippGackstatter
left a comment
There was a problem hiding this comment.
Looks good! I left a few small comments.
7fa6311 to
58ee194
Compare
PhilippGackstatter
left a comment
There was a problem hiding this comment.
Looks good to me, thank you!
58ee194 to
9b783c5
Compare
|
@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. |
| /// - `..., matches <pat> [if <guard>]` — matches the inner `ExecutionError` against `<pat>`. Use | ||
| /// this for variants other than `FailedAssertion`, or to assert on a specific `err_code`. |
There was a problem hiding this comment.
nit: if I'm reading this correctly, then these are two distinct use cases. I'd maybe rephrase to make the distinction explicit:
/// Use this when you need to:
/// - match a variant other than `FailedAssertion` (e.g. `CycleLimitExceeded`, or
/// - pin a specific `err_code` on a `FailedAssertion`
Closes #2807
Adds two new arms to
assert_execution_error!andassert_transaction_executor_error!:matches <pat> [if <guard>]- pattern-match the innerExecutionErrordirectly, with an optional guard. Useful for variants other thanFailedAssertion, or to assert on a specificerr_code.any- accept anyErr.The existing
$expectedarm still works as before; tests passingMasmErrorconstants don't change.New
tests/assertion_macros.rs:#[should_panic]checks for the failure paths.FastProcessorto trigger and assert realExecutionErrorvariants end-to-end (DivideByZero,CycleLimitExceeded,MemoryError::UnalignedWordAccess,AdviceError::StackReadFailed,EventError, etc).