refactor: replace panic-based test error handling with Result (#319) - #321
Merged
MaryammAli merged 2 commits intoJul 21, 2026
Merged
Conversation
…ash-Studios#319) - Replace panic!() calls in test match arms with descriptive assert! macros - Replace bare .unwrap() calls with .expect() containing descriptive messages - Improve assert_contract_error to provide detailed failure context - Update latest_contract_event to use descriptive expect/panic messages - Convert event_data_map to use .expect() instead of .unwrap() Closes BlockDash-Studios#319
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces panic-based error handling in test files with explicit Result handling and descriptive failure messages.
Changes
app/contract/contracts/Folder/build.rs.unwrap()onOUT_DIRwith.expect()describing the missing env var.unwrap()onfs::writewith.expect()describing the write failure.unwrap_or_else(|_| panic!(...))ongit rev-parsewith.expect()with descriptive messageapp/contract/contracts/Folder/src/test.rspanic!()in match arms oftest_emergency_mode_blocks_risky_entry_points_and_allows_safe_pathswithassert!()macros with descriptive messagesassert_contract_errorhelper: all match arms now produce descriptive assertions instead of a genericpanic!()latest_contract_event:.unwrap()to.expect(), panic message made more descriptiveevent_data_map:.unwrap()to.expect()with conversion error contextapp/contract/contracts/Folder/src/role_test.rspanic!("Expected InsufficientRole error")intest_insufficient_role_errorwithassert!()including the actual error in the messageTesting
All 317 tests pass (
cargo test).Closes #319