Skip to content

test(escrow_contract): write integration tests for full escrow lifecycle - #34

Merged
Tybravo merged 2 commits into
SwiftChainn:mainfrom
Ogstevyn:test/escrow-full-lifecycle-integration
Apr 23, 2026
Merged

test(escrow_contract): write integration tests for full escrow lifecycle#34
Tybravo merged 2 commits into
SwiftChainn:mainfrom
Ogstevyn:test/escrow-full-lifecycle-integration

Conversation

@Ogstevyn

Copy link
Copy Markdown
Contributor

Summary

  • Implemented the escrow lifecycle functions required for the tests to compile: create_escrow, release_escrow, refund_escrow, raise_dispute, resolve_dispute, and get_escrow_record
  • Added EscrowStatus and EscrowRecord contract types and a typed DataKey::Escrow(u64) storage key
  • Every persistent write calls extend_ttl via the constants defined in Smart Contract: Implement Escrow TTL and Storage Ledger Extension #15
  • Wrote 12 integration tests covering: happy-path create→release (driver balance asserted), refund path (sender balance restored), dispute resolved to driver, dispute resolved to sender, all four unauthorized-caller failure modes, duplicate delivery ID rejection, invalid state transitions (double-release, release-then-refund), and event emission across the full dispute lifecycle
  • All tests run with cargo test against the Soroban mock environment — no testnet access required

Test plan

  • test_happy_path_create_and_release — token flows to driver, contract balance zeroed
  • test_refund_path_restores_sender_balance — sender gets tokens back
  • test_dispute_resolved_to_driver — admin awards driver
  • test_dispute_resolved_to_sender — admin refunds sender
  • test_release_by_non_admin_rejected — panics
  • test_refund_by_non_admin_rejected — panics
  • test_raise_dispute_by_non_sender_rejected — panics
  • test_resolve_dispute_by_non_admin_rejected — panics
  • test_duplicate_delivery_id_rejected — panics
  • test_release_on_already_released_rejected — panics
  • test_refund_on_released_escrow_rejected — panics
  • test_lifecycle_events_emitted — events vec non-empty

Closes #16

@drips-wave

drips-wave Bot commented Apr 23, 2026

Copy link
Copy Markdown

@Ogstevyn 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

@Tybravo
Tybravo merged commit 5c43a45 into SwiftChainn:main Apr 23, 2026
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.

Smart Contract: Write Integration Tests for Escrow Full Lifecycle

2 participants