Skip to content

Add cancel_vault refund balance-assertion tests aligned with real token transfer #232

@1nonlypiece

Description

@1nonlypiece

📌 Description

README_CANCEL_VAULT.md still describes cancel_vault as refunding a simulated
per-vault balance stored under ("vault_balance", vault_id), but the current
src/lib.rs performs a real Soroban token::Client::transfer from the
contract back to the creator. The tests should assert the real on-ledger refund,
and the doc should be corrected to match.

Goal: add tests asserting cancel_vault credits the creator by exactly
vault.amount and zeroes the contract's escrow, and update the cancel doc.

🎯 Requirements and Context

  • Must be deterministic and isolated.
  • Assert creator balance increases by vault.amount and contract balance returns
    to its pre-create value.
  • Confirm the vault_cancelled event is emitted.
  • Confirm cancel is rejected on non-Active vaults (Error::VaultNotActive).

🛠️ Suggested Execution

1. Fork the repo and create a branch

git checkout -b feature/cancel-vault-refund-tests

2. Implement changes

  • Tests: extend tests/lifecycle.rs with refund balance-delta assertions using
    TokenClient::balance.
  • Docs: rewrite README_CANCEL_VAULT.md to describe the real token transfer
    (remove the "simulated balance" language) and add a docs/CANCEL.md if helpful.

3. Test and commit

  • Run cargo test and regenerate coverage.
  • Cover edge cases: cancel right after create, cancel on completed/failed/cancelled
    (reject), non-creator cancel (reject), double cancel (reject).

Example commit message

test+docs: real-transfer refund coverage for cancel_vault

✅ Guidelines

  • Minimum 95% test coverage on cancel_vault lines.
  • Clear, corrected documentation in README_CANCEL_VAULT.md.
  • All tests deterministic and passing.
  • Timeframe: 96 hours.

🏷️ Labels

type-testing · area-contracts · type-documentation · MAYBE REWARDED ·
GRANTFOX OSS · OFFICIAL CAMPAIGN

💬 Community & Support

  • Join the Disciplr contributor Discord to coordinate, ask questions, and get
    unblocked fast: https://discord.gg/xvNAvMJf
  • Please introduce yourself before you start so we can avoid duplicate work,
    pair you with a reviewer, and merge your PR quickly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions