test(events): verify deterministic event emission order across contract operations#153
Merged
Merged
Conversation
test(events): verify deterministic event emission order across contract operations
…s contract operations"
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
This PR adds comprehensive event sequence tests to ensure all contract operations emit the expected events in the correct order. The new test suite validates the exact event count, topic symbols, and emission sequence, preventing regressions where events are emitted out of order, duplicated, or omitted during future refactoring.
Motivation
Many integrations rely on contract events for indexing, analytics, notifications, and off-chain processing. Changes to event emission order or missing events can silently break downstream consumers even when contract logic remains functionally correct.
This PR establishes deterministic event sequence validation to safeguard the contract's event interface.
Changes
Event Sequence Validation
Added tests that capture the complete list of emitted events using:
Each test validates:
Covered Operations
Added event sequence assertions for all state-changing operations:
create_shipmentsubmit_proofconfirm_milestoneraise_disputeresolve_disputecancel_shipmentEach operation is validated independently to ensure deterministic behavior.
Strict Event Assertions
The test suite now fails if any of the following occur:
This provides strong regression protection for event-driven integrations.
Testing
Added comprehensive coverage for:
The tests rely on
env.events().all()to validate the complete event stream after each contract call.Benefits
Acceptance Criteria
Result
The contract now has deterministic event regression tests that enforce the exact sequence, count, and topics of emitted events, ensuring a stable event interface for off-chain consumers and reducing the risk of breaking changes during future development.
Closes #123