Skip to content

#402 - test(multisig_split_refund): add extreme-value boundary tests for checked arithmetic - #427

Merged
godamongstmen897 merged 2 commits into
Goldii-locks:mainfrom
qa-eden:fix/checked-arithmetic-multisig-split-refund
Sep 1, 2026
Merged

#402 - test(multisig_split_refund): add extreme-value boundary tests for checked arithmetic#427
godamongstmen897 merged 2 commits into
Goldii-locks:mainfrom
qa-eden:fix/checked-arithmetic-multisig-split-refund

Conversation

@qa-eden

@qa-eden qa-eden commented Aug 30, 2026

Copy link
Copy Markdown

Closes #402


Summary

multisig_split_refund already delegates all arithmetic to split_round_nearest, which uses checked_mul, checked_add, and checked_sub throughout. The BPS pair addition is also guarded with checked_add. No production-code changes are required.

What was missing was test coverage proving that extreme operands (i128::MAX, i128::MIN, negatives) return typed errors rather than panicking or wrapping.

Changes

multisig_split_refund_tests.rs — new dedicated test file, 12 tests across 6 sections:

  • Auth / source-state guards — unauthorized caller and unlocked state rejected before any arithmetic runs
  • total_amount boundary guards — i128::MIN, negatives, and zero all return Error::InvalidAmount
  • Overflow cases — i128::MAX with every non-trivial BPS pair returns Error::InvalidAmount; u32::MAX BPS pair returns Error::InvalidRatio
  • Extreme amounts that succeed — i128::MAX with 0-bps client completes correctly; i64::MAX 50/50 split sums exactly to the input
  • Valid-amount regression — 50/50, 70/30, odd rounding, extreme BPS pin exact outputs unchanged
  • Event emission — success emits exactly one splitref event; all failure paths emit none

test.rs — adds the #[path] mod declaration following the existing pattern used by multisig_admin_override_refund_tests and multisig_transfer_admin_tests.

Testing

@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@qa-eden 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

@godamongstmen897
godamongstmen897 merged commit 5952d16 into Goldii-locks:main Sep 1, 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.

Replace unchecked arithmetic in multisig_split_refund with checked operations

2 participants