Description
create_contract enforces TooManyMilestones when milestone_amounts.len() > MAX_MILESTONES (10), InvalidMilestoneAmount for non-positive amounts or totals over MAX_TOTAL_ESCROW_STROOPS, and PotentialOverflow via safe_add_amounts. The orphaned test_bounds.rs covers some of this but is not compiled. Add wired tests for all bounds.
Requirements and context
- Scoped to TalentTrust
escrow Soroban contract (contracts/escrow).
- Assert: exactly 10 milestones succeeds; 11 panics
TooManyMilestones; zero/negative milestone panics InvalidMilestoneAmount; total over MAX_TOTAL_ESCROW_STROOPS panics; near-i128::MAX amounts panic PotentialOverflow.
- Assert
InvalidParticipant when client == freelancer and EmptyMilestones for an empty vector.
- Acceptance: each guard in
create_contract has a dedicated case.
- Must be secure, tested, and documented.
Suggested execution
- Fork the repo and create a branch:
git checkout -b test/create-contract-bounds
- Implement changes:
contracts/escrow/src/test/milestone_schedule.rs
- Tests:
contracts/escrow/src/test/milestone_schedule.rs
- Docs:
docs/escrow/milestone-validation.md
- Include rustdoc/NatSpec-style doc comments on public functions
- Validate security assumptions (auth, overflow, fail-closed state machine, storage TTL, fee accounting)
Test and commit
- Run tests:
cargo test
- Cover edge cases (unauthorized callers, double release/refund, expired approvals, fee rounding, paused state)
- Include test output and security notes in the PR
Example commit message
test(escrow): cover create_contract bounds and overflow
Guidelines
- Minimum 95% test coverage on new/changed code
- Clear documentation
- Timeframe: 96 hours from assignment
Description
create_contractenforcesTooManyMilestoneswhenmilestone_amounts.len() > MAX_MILESTONES(10),InvalidMilestoneAmountfor non-positive amounts or totals overMAX_TOTAL_ESCROW_STROOPS, andPotentialOverflowviasafe_add_amounts. The orphanedtest_bounds.rscovers some of this but is not compiled. Add wired tests for all bounds.Requirements and context
escrowSoroban contract (contracts/escrow).TooManyMilestones; zero/negative milestone panicsInvalidMilestoneAmount; total overMAX_TOTAL_ESCROW_STROOPSpanics; near-i128::MAXamounts panicPotentialOverflow.InvalidParticipantwhenclient == freelancerandEmptyMilestonesfor an empty vector.create_contracthas a dedicated case.Suggested execution
git checkout -b test/create-contract-boundscontracts/escrow/src/test/milestone_schedule.rscontracts/escrow/src/test/milestone_schedule.rsdocs/escrow/milestone-validation.mdTest and commit
cargo testExample commit message
Guidelines