📋 Description
calculate_split and distribute_usdc_hashed in remittance_split/src/lib.rs split a total_amount across four categories (spending, savings, bills, insurance) emitting a DistributionCompletedEvent. Existing tests cover happy paths, but there is no systematic proof that the four split amounts always sum back to the original total with zero dust loss across the full space of valid percentage configurations.
This issue adds a property-based suite asserting the conservation invariant spending + savings + bills + insurance == total_amount for distribute_usdc_hashed across randomized percentages summing to 100 and randomized totals.
Why this matters: rounding bugs in split math silently leak or duplicate funds. Conservation is the single most important financial invariant for this contract and must hold for every valid config, not just the ones that happen to divide evenly.
🎯 Requirements & Context
Functional requirements
Context & constraints
🛠️ Suggested Execution
1. Fork & branch
git checkout -b test/split-dust-conservation
2. Implement changes
- Add the property suite in a new test module wired under
#[cfg(test)].
- Add
/// doc comments documenting the conservation invariant being proven.
3. Test & commit
cargo test -p remittance_split
- Cover edge cases: total of 1 unit, totals near
i128::MAX/2, all-to-one-category splits (100/0/0/0), and near-even four-way splits that force remainder distribution.
Example commit message
test(remittance): add property-based dust-conservation suite for distribute_usdc_hashed
Proves spending+savings+bills+insurance == total across randomized valid splits.
✅ Acceptance Criteria & Guidelines
| Requirement |
Target |
| Conservation invariant proven across randomized configs |
Required |
| Negative/invalid-config rejection covered |
Required |
| Coverage of split math paths |
≥ 95%, all branches |
| Doc comments explaining invariants |
Required |
cargo test -p remittance_split + cargo clippy clean |
Required |
| Timeframe |
96 hours from assignment |
💬 Community & Support
Questions and design discussion — join the Remitwise contributor community on Discord: https://discord.gg/CtQuPZFMA
Please drop a note in the channel when you pick this up so we can avoid duplicate work and unblock you fast. 🚀
📋 Description
calculate_splitanddistribute_usdc_hashedinremittance_split/src/lib.rssplit atotal_amountacross four categories (spending, savings, bills, insurance) emitting aDistributionCompletedEvent. Existing tests cover happy paths, but there is no systematic proof that the four split amounts always sum back to the original total with zero dust loss across the full space of valid percentage configurations.This issue adds a property-based suite asserting the conservation invariant
spending + savings + bills + insurance == total_amountfordistribute_usdc_hashedacross randomized percentages summing to 100 and randomized totals.🎯 Requirements & Context
Functional requirements
distribute_usdc_hashed(andcalculate_split) with randomized inputs.total_amount(no dust created or lost).PercentagesDoNotSumTo100/PercentageOutOfRangereject invalid configs.DistributionCompletedEventpayload matching the computed amounts.Context & constraints
21.7.7; reuse the existingEnv::default()+Address::generate()token mint helpers fromremittance_split/src/test.rs.cargo test -p remittance_split.🛠️ Suggested Execution
1. Fork & branch
2. Implement changes
#[cfg(test)].///doc comments documenting the conservation invariant being proven.3. Test & commit
cargo test -p remittance_spliti128::MAX/2, all-to-one-category splits (100/0/0/0), and near-even four-way splits that force remainder distribution.Example commit message
✅ Acceptance Criteria & Guidelines
cargo test -p remittance_split+cargo clippyclean💬 Community & Support
Questions and design discussion — join the Remitwise contributor community on Discord: https://discord.gg/CtQuPZFMA
Please drop a note in the channel when you pick this up so we can avoid duplicate work and unblock you fast. 🚀