Skip to content

[CT-09] Write comprehensive unit tests for the escrow contract #917

@mftee

Description

@mftee

Problem

The escrow contract in contracts/escrow/ handles all payment operations on the platform — fund holding, release, refund, and dispute resolution — but has minimal test coverage. Bugs in financial logic go undetected until real funds are lost.

Proposed Solution

Write a comprehensive test suite for the escrow contract inside contracts/package/tests/escrow/ using the Soroban SDK test harness with mock token contracts.

Note: All work must be done inside the contracts/package/ directory. Do not modify any existing contract files outside this folder.

Acceptance Criteria

  • Tests cover fund_escrow: success path, double-funding the same escrow returns AlreadyFunded
  • Tests cover release_funds: shipper can release, non-shipper caller returns Unauthorized
  • Tests cover refund: only callable when shipment is cancelled, returns InvalidState otherwise
  • Tests cover open_dispute: shipper and carrier can open, third party returns Unauthorized
  • Tests cover admin_resolve: admin can release or refund, non-admin returns Unauthorized
  • All tests use the Soroban Env::default() test environment and a mock SEP-41 token contract
  • cargo test runs all tests successfully from contracts/package/tests/escrow/

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions