test(fees): cover tier-boundary billing and validation - #439
Merged
mikewheeleer merged 2 commits intoJul 29, 2026
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
|
looks good @Jagadeeshftw — CI passing, 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
docs/escrow/pricing.mddocuments 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/settleat the exact first-tier threshold, one request past it, and at an interior (non-final) tier threshold.settle's billed amount cross-checked againstcompute_billingat the same boundary.set_price_tiersrejection tests: empty schedule, zero first threshold, tied thresholds, negative price — allInvalidPriceTiers(Add tests for strict service-registration and service-disabled gates #18).No contract code changes — test-only.
Closes #294
Validation
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test -p escrow— 362 passed (9 new), 0 failed