test(events): cover event payloads at request-count boundaries - #438
Merged
mikewheeleer merged 2 commits intoJul 29, 2026
Merged
Conversation
env.events().all() reflects only the most recent contract invocation, not a running total across separate calls (consistent with every other event test in this file). The test compared post-transfer event count against a pre-transfer count captured after a *different* call (set_service_metadata), expecting accumulation that never happens, so it failed on every run regardless of contract behavior. Fixed to assert directly on this call's own event count.
Contributor
|
thanks @Jagadeeshftw, green and on-point. merging 🎊 |
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
The existing min/max/rate-limit boundary tests (
test_set_min_equal_to_max_is_accepted,test_exact_count_rejects_below/above,test_rate_limit_allows_exactly_at_cap, etc.) only assert on return values — none of them check theusageorcfg_setevent itself at those same boundaries. Adds direct event-payload coverage at each boundary:usageevent fires with the correct payload whenrequestslands exactly onmax_requests_per_call, exactly onmin_requests_per_call, exactly on the rate-limit cap, and at themin == maxexact-count value.usageevent's publish call is ever reached (no event for a rejected call).cfg_setfires correctly when the cross-bound guard's own boundary is hit — settingminequal to the currentmax(and the symmetricmaxequal to currentmin) — and does not fire when one value past that boundary is rejected.No contract code changes — test-only.
Closes #289
Validation
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test -p escrow— 361 passed (8 new), 0 failed