Skip to content

Test/create contract bounds#373

Open
alexitsejames-cpu wants to merge 3 commits into
Talenttrust:mainfrom
alexitsejames-cpu:test/create-contract-bounds
Open

Test/create contract bounds#373
alexitsejames-cpu wants to merge 3 commits into
Talenttrust:mainfrom
alexitsejames-cpu:test/create-contract-bounds

Conversation

@alexitsejames-cpu
Copy link
Copy Markdown

Added create_contract_bounds.rs with 11 tests covering every input guard in create_contract — same-participant rejection, empty milestones, milestone count boundary (exactly 10 passes, 11 fails), zero/negative amounts, i128 overflow via safe_add_amounts, and total exceeding MAX_TOTAL_ESCROW_STROOPS. Also verified guard ordering: count check fires before amount check. Updated milestone-validation.md to reflect the actual implemented guards and map each one to its test.
closed #329

alexatsejames-alt and others added 3 commits May 26, 2026 23:30
Add wired tests for every input-validation guard in create_contract:

- InvalidParticipant  when client == freelancer
- EmptyMilestones     when milestone_amounts is empty
- TooManyMilestones   when len > MAX_MILESTONES (11 milestones)
- boundary success    when len == MAX_MILESTONES (exactly 10)
- InvalidMilestoneAmount for zero and negative amounts
- PotentialOverflow   when safe_add_amounts overflows i128
- InvalidMilestoneAmount when total > MAX_TOTAL_ESCROW_STROOPS
- ordering assertion  count guard fires before amount guard

Tests live in contracts/escrow/src/test/create_contract_bounds.rs
and are wired via mod.rs. The orphaned test_bounds.rs and
milestone_schedule.rs are left untouched.

Closes Talenttrust#329
- Add create_contract_bounds.rs wired into test/mod.rs
- Covers all 7 guards in execution order:
    1. InvalidParticipant  (client == freelancer)
    2. EmptyMilestones     (empty vec)
    3. TooManyMilestones   (len > MAX_MILESTONES = 10)
    4. boundary success    (len == MAX_MILESTONES accepted)
    5. InvalidMilestoneAmount (zero or negative amount)
    6. PotentialOverflow   (safe_add_amounts overflow on i128)
    7. InvalidMilestoneAmount (total > MAX_TOTAL_ESCROW_STROOPS)
- Guard ordering test: count check fires before amount check
- Update docs/escrow/milestone-validation.md with guard table and test map

Closes Talenttrust#329
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@alexitsejames-cpu 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

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.

Add tests for create_contract bounds (MAX_MILESTONES and MAX_TOTAL_ESCROW_STROOPS)

2 participants