Skip to content

test(events): cover event payloads at request-count boundaries - #438

Merged
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Jagadeeshftw:test/events-02-boundary
Jul 29, 2026
Merged

test(events): cover event payloads at request-count boundaries#438
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Jagadeeshftw:test/events-02-boundary

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

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 the usage or cfg_set event itself at those same boundaries. Adds direct event-payload coverage at each boundary:

  • usage event fires with the correct payload when requests lands exactly on max_requests_per_call, exactly on min_requests_per_call, exactly on the rate-limit cap, and at the min == max exact-count value.
  • One request past the ceiling panics before the usage event's publish call is ever reached (no event for a rejected call).
  • cfg_set fires correctly when the cross-bound guard's own boundary is hit — setting min equal to the current max (and the symmetric max equal to current min) — and does not fire when one value past that boundary is rejected.

No contract code changes — test-only.

Closes #289

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test -p escrow — 361 passed (8 new), 0 failed

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.
@mikewheeleer

Copy link
Copy Markdown
Contributor

thanks @Jagadeeshftw, green and on-point. merging 🎊

@mikewheeleer
mikewheeleer merged commit 5a97ded into Agentpay-Org:main Jul 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add boundary tests for the events logic

2 participants