Skip to content

test: add unit tests for math, validation and status helpers - #714

Merged
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
joshfatoye0011-bit:test/math-validation-status-661-664
Aug 30, 2026
Merged

test: add unit tests for math, validation and status helpers#714
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
joshfatoye0011-bit:test/math-validation-status-661-664

Conversation

@joshfatoye0011-bit

Copy link
Copy Markdown
Contributor

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

…-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
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Kingsman-99
Kingsman-99 merged commit 21e44b7 into Stellar-split:main Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants