Skip to content

test(fees): cover tier-boundary billing and validation - #439

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

test(fees): cover tier-boundary billing and validation#439
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Jagadeeshftw:test/fees-02-boundary

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Summary

docs/escrow/pricing.md documents tier boundaries as inclusive at the upper edge (tier k covers [threshold_{k-1}+1 .. threshold_k]), but no existing test lands exactly on a threshold or one past it — the one tiered-billing test in the suite uses a mid-range value (1500 against thresholds 100/1000). Separately, set_price_tiers's validation invariants (empty schedule, non-ascending thresholds, negative price, zero first threshold) had no test at all before this PR.

  • compute_billing/settle at the exact first-tier threshold, one request past it, and at an interior (non-final) tier threshold.
  • settle's billed amount cross-checked against compute_billing at the same boundary.
  • set_price_tiers rejection tests: empty schedule, zero first threshold, tied thresholds, negative price — all InvalidPriceTiers (Add tests for strict service-registration and service-disabled gates #18).
  • Confirms thresholds exactly one apart are accepted (strictly-ascending means "no ties," not "a minimum gap").

No contract code changes — test-only.

Closes #294

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test -p escrow — 362 passed (9 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

looks good @Jagadeeshftw — CI passing, merging 👍

@mikewheeleer
mikewheeleer merged commit 5d06896 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 fees logic

2 participants