Repository navigation
Conversation
…cesslayerorg#559) Add a shared test assertion helper `assert_event` to reduce boilerplate when verifying emitted contract events in integration tests. - Implement `assert_event(env, contract_id, topic, expected_fields)` in `creator-keys/tests/contract_test_env/mod.rs` to filter events by both contract address and primary topic (index 0). - Deserialize event payloads into generic types and compare them against expected fields, providing clear panic messages showing the topic, expected fields, and actual emitted values on mismatch (or reporting when no matching event was found). - Refactor existing event test cases in `contract_initialization_event.rs` and `creator_registered_event_fields.rs` to replace manual log extraction with `assert_event`. - Add unit tests for the helper in `creator-keys/tests/assert_event.rs` verifying exact match, topic filtering, contract filtering, field mismatch messages, and empty log behavior.
|
@EneGab Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
assert_event(env, contract_id, topic, expected_fields)to eliminate repetitive boilerplate across event test assertions.assert_eventtocreator-keys/tests/contract_test_env/mod.rs:env.events().all()by both emitting contract address (contract_id) and canonical event topic at index 0 (topic).TryFromVal<Env, Val> + PartialEq + core::fmt::Debug.creator-keys/tests/assert_event.rsverifying exact match, topic filtering, contract ID filtering, field value mismatch messages, and behavior when no events are emitted.assert_event:creator-keys/tests/contract_initialization_event.rs(test_initialization_event_emitted_on_first_set_fee_config) forContractInitializedEvent.creator-keys/tests/creator_registered_event_fields.rs(test_creator_registered_event_all_four_fields_present_in_one_registration) forCreatorRegisteredEvent.Testing
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspaceChecklist
creator-keysunit/integration tests for every changed contract behavior, including failure paths for new or reachableContractErrorvariantscargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings, andcargo test --workspace, or explained exactly why a command was not rundocs/storage-key-invariants.md; any storage layout change includes a migration/backward-compatibility note (N/A - no storage layout modifications)docs/contract-event-conventions.md, or documented the breaking change and versioning plan (N/A - event schemas unchanged)