Skip to content

feat: add multi-milestone support with comprehensive unit and integration tests - #26

Merged
Levi-Ojukwu merged 11 commits into
mainfrom
feat/milestone-support-and-tests
Jul 11, 2026
Merged

Levi-Ojukwu merged 11 commits into
mainfrom
feat/milestone-support-and-tests

Conversation

@SweetBoy-eth

Copy link
Copy Markdown
Contributor

Summary

  • Issue Add multi-milestone support #9: Added multi-milestone support with submit_milestone (freelancer submits work), release_milestone (client releases funds per milestone), and released tracking on each milestone for partial release/approval
  • Issues Write unit tests for create_escrow #6, Write unit tests for fund_escrow #7, Write unit tests for release and refund #8: Added 51 comprehensive tests covering all specified test cases for create_escrow, fund_escrow, release, and refund
    Changes
    Multi-Milestone Support (Issue Add multi-milestone support #9)
  • types.rs: Added released: bool field to Milestone struct
  • events.rs: Added emit_milestone_submitted and emit_milestone_released event functions
  • contract.rs: Added submit_milestone (freelancer submits pending milestones) and release_milestone (client releases funds for approved milestones). Fixed borrow checker issues in fund_escrow, refund, claim_timeout, and resolve_dispute
    Unit Tests (Issues Write unit tests for create_escrow #6, Write unit tests for fund_escrow #7, Write unit tests for release and refund #8)
  • create_escrow_tests.rs: 10 tests — valid creation, zero/negative amount rejection, self-escrow rejection, sequential IDs, duplicate escrow handling, initial state, fee defaults
  • fund_escrow_tests.rs: 9 tests — successful funding, not found, wrong client, already funded/released/refunded/cancelled, timestamp, detail preservation
  • release_refund_tests.rs: 18 tests — release success/not funded/wrong client/already released/already refunded/timestamp/tracking, refund success/not funded/wrong client/already refunded/already released/timestamp/tracking
  • integration_tests.rs: 14 tests — full lifecycle (release/refund/dispute/cancel), milestone lifecycle (approve/reject/submit/release), authorization checks, error cases, history tracking, pause blocking

closes #6
closes #7
closes #8
closes #9

Pin ed25519-dalek to v2.2.0 to resolve compatibility issue with
soroban-env-host test utilities (rand_core CryptoRng trait mismatch).
…el release tracking

Adds a boolean 'released' field to track whether a specific milestone's
funds have been released, enabling partial release per milestone.
Adds emit_milestone_submitted and emit_milestone_released event
functions to track milestone lifecycle transitions.
…milestone support

Adds two new contract functions:
- submit_milestone: Allows freelancers to submit completed milestones
- release_milestone: Allows clients to release funds for individual
  approved milestones, enabling partial release per milestone.

Also fixes borrow checker issues by cloning amounts before mutable
escrow borrows in fund_escrow, refund, claim_timeout, and
resolve_dispute functions.
Exports the contract module publicly to allow integration tests
to access the generated EscrowContractClient type.
Tests cover: valid creation, zero amount rejection, negative amount
rejection, self-escrow rejection (client == freelancer), sequential
ID generation, duplicate escrow handling, initial state verification,
fee defaults, and total released/refunded defaults.
Tests cover: successful funding, funding non-existent escrow,
funding with wrong client, funding already-funded escrow, funding
already-released escrow, funding already-refunded escrow, funding
already-cancelled escrow, funded_at timestamp, and preservation
of escrow details after funding.
…fund

Release tests: success, not funded, wrong client, already released,
already refunded, released_at timestamp, total_released tracking.

Refund tests: success, not funded, wrong client, already refunded,
already released, refunded_at timestamp, total_refunded tracking.
…ycle and milestones

Tests cover: full create-fund-release lifecycle, create-fund-refund
lifecycle, dispute resolution, escrow cancellation, milestone lifecycle
(approve/reject), milestone submit and release, submit authorization,
release authorization, release-not-approved, release-already-released,
milestone-not-found, history tracking, modify before funding, paused
contract blocking, multi-milestone lifecycle, amount mismatch, and
description/amount count mismatch.
@Levi-Ojukwu
Levi-Ojukwu merged commit bcc2ab9 into main Jul 11, 2026
2 of 4 checks 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.

Add multi-milestone support Write unit tests for release and refund Write unit tests for fund_escrow Write unit tests for create_escrow

2 participants