test: boundary invariants, max amounts, error docs, storage notes#187
Merged
Chucks1093 merged 4 commits intoApr 25, 2026
Conversation
Add comprehensive test suite verifying fee split invariants at boundary values: - Balance conservation: creator_amount + protocol_amount == total - Rounding direction: remainder from division goes to creator - Boundary handling: zero, negative, dust amounts, and i128 limits - Overflow prevention in checked variant Tests cover: - All typical amounts (1, 10, 99, 100, 999, 1000, 10000, 100000, 1M) - All valid fee configurations (protocol_bps from 0 to 10000) - Edge cases: equal splits, remainder favoring creator - Safe and unsafe amounts for multiplication Refs #159
Add tests for near-maximum amount input values in buy and sell paths: - Large safe amounts (1 trillion, max safe i128/10000) - Quote operations with maximum safe amounts - Buy/sell transactions with large amounts - Fee configurations with maximum amounts (50/50 split) Tests verify overflow-safe behavior and error-free operation when amounts approach i128 limits. Coverage includes both buy and sell paths with various fee configurations. Refs #173
Document all ContractError enum values with: - Numeric error codes (1-9) - Meaning and context for each error - Likely causes and error conditions - Expected caller behavior and remediation - Integration notes for authorization, pricing, overflow - Event emission and version stability guidance Maps errors to their discriminant values and provides guidance for clients on handling each error type appropriately. Refs #171
Document storage access patterns and performance considerations: - Query paths: 1-4 storage reads per call (get_buy_quote, get_sell_quote) - State-modifying paths: read counts for buy_key, sell_key, register - Optimization candidates for short/medium-term improvements - Reproducible profiling methodology for contributors - Storage layout summary and testing guidance Identify hot paths (get_buy_quote: 3 reads, get_sell_quote: 4 reads) and potential optimizations including client-side caching, separate holder count storage, and quote batching API extensions. Refs #172
|
@williamedvard Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Comprehensive test coverage and documentation for fee rounding behavior, maximum amount inputs, error codes, and storage performance characteristics. This batch adds boundary-value testing for invariants, documentation for error handling, and performance notes for contributors.
Changes
Testing
All cargo CI checks pass:
cargo fmt --all -- --check: ✓cargo clippy --workspace --all-targets -- -D warnings: ✓cargo test --workspace: ✓ (152 tests passed, including 28 new tests)Closes #159
Closes #171
Closes #172
Closes #173