test: add unit tests for math, validation and status helpers - #714
Merged
Kingsman-99 merged 1 commit intoAug 30, 2026
Merged
Conversation
…-split#661 Stellar-split#662 Stellar-split#663 Stellar-split#664) - math.rs: add normalize_amount edge-case tests (decimals 0/7/18, i128::MAX overflow) closing Stellar-split#661; add denormalize_amount round-trip tests for d in {0,6,7,8,18}, negative-input guard, and overflow on large up-scaling closing Stellar-split#662 - validation.rs: add assert_unique_recipients tests for single-element list, non-adjacent duplicate, and 10-address unique list closing Stellar-split#663 - types.rs: add InvoiceStatus::to_u8/from_u8 round-trip test across all ten variants, discriminant-uniqueness check, and unknown-byte fallback to Pending closing Stellar-split#664
|
@joshfatoye0011-bit 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 Adds missing unit tests across three files to cover arithmetic normalisation helpers, recipient uniqueness validation, and invoice status serialisation round-trips. ## Changes ### contracts/split/src/math.rs — closes #661, #662 - **#661 –
ormalize_amount edge cases:** tests for decimals == 0 (scales up by 10^7), decimals == 7 identity, decimals == 18 (scales down by 10^11), negative raw value returns \ArithmeticOverflow, and \i128::MAX-range value triggers overflow. - #662 – \denormalize_amount\ round-trips: full normalize→denormalize round-trip for \d ∈ {0, 6, 7, 8, 18}, standalone identity test for \d == 7, negative normalised value returns \ArithmeticOverflow, and overflow guard when scaling a very large value up (d=18). ### \contracts/split/src/validation.rs\ — closes #663 - #663 – \�ssert_unique_recipients\ edge cases: single-element list passes, non-adjacent duplicate (index 0 and 2) returns \Err(DuplicateRecipient), and all-unique list of 10 addresses passes. ### \contracts/split/src/types.rs\ — closes #664 - #664 – \InvoiceStatus\ round-trip: iterates all ten variants asserting \rom_u8(v.to_u8()) == v, verifies discriminant uniqueness (no collisions), and confirms unknown byte (e.g. 255) falls back to \InvoiceStatus::Pending\ rather than panicking. ## Testing All new tests are pure unit tests inside #[cfg(test)]\ modules; run with: \\ cargo test \\ ## Closes Closes #661 Closes #662 Closes #663 Closes #664