Skip to content

Add tests for the two-step admin transfer and migration version guard #20

@mikewheeleer

Description

@mikewheeleer

Test admin handover edge cases and schema migration guard

Description

contracts/escrow/src/test.rs covers the happy-path admin rotation and the no-pending panic, but misses several edges in contracts/escrow/src/lib.rs: cancel_admin_transfer, accept_admin_transfer by the wrong caller (NotPendingAdmin #6), re-proposing over a pending entry, and the migrate_v1_to_v2 double-run guard (MigrationVersionMismatch #11). This issue adds those tests.

Requirements and context

  • Repository scope: Agentpay-Org/Agentpay-contracts only.
  • Cover: propose → cancel → accept fails with #5; propose → wrong caller accepts → #6; re-propose overwrites pending; get_pending_admin reflects each state.
  • Cover: get_schema_version defaults to 1; migrate_v1_to_v2 advances to 2; second migrate panics #11.
  • Assert the rotated admin can perform an admin action and the old admin can no longer.
  • Test-only change unless a genuine bug surfaces.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/contracts-20-admin-migration-tests
  • Implement changes
    • Write code in: contracts/escrow/src/lib.rs — no changes expected.
    • Write comprehensive tests in: contracts/escrow/src/test.rs — the handover/migration scenarios above.
    • Add documentation: note covered behaviour in the test module header.
    • Include NatSpec-style doc comments (///) on any test helpers.
    • Validate security: lockout-resistance of the two-step handover is proven.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases: cancel with nothing pending, accept after cancel, migrate before any state exists.
  • Include the full cargo test output and a short security notes section in the PR description.

Example commit message

test: cover admin transfer edge cases and migration version guard

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the AgentPay community on Discord for questions, reviews, and faster merges: https://discord.gg/eXvRKkgcv
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions