Skip to content

Add tests for cancel_admin_transfer and re-proposal overwrite of a pending admin #103

Description

@mikewheeleer

Test the cancel and re-propose paths of the two-step admin handover

Description

The two-step admin handover in contracts/escrow/src/lib.rs supports cancelling a pending transfer (cancel_admin_transfer) and overwriting the pending entry by re-proposing (propose_admin_transfer re-write), with get_pending_admin exposing the state. contracts/escrow/src/test.rs does not cover the cancel path, the re-propose-overwrites-pending behaviour, or the InvalidAdminProposal (#14) self-proposal guard. This issue fills those handover gaps.

Requirements and context

  • Repository scope: Agentpay-Org/Agentpay-contracts only.
  • Cover: propose then cancel clears PendingAdmin (get_pending_admin returns None); a subsequent accept_admin_transfer panics NoPendingAdminTransfer (#5).
  • Cover: re-proposing a different address overwrites the pending entry (get_pending_admin reflects the latest); accepting then uses the latest.
  • Cover: proposing the current admin as the new admin panics InvalidAdminProposal (#14).
  • Cover: cancel_admin_transfer with nothing pending is a no-op; only the admin can cancel; test-only change unless a genuine bug surfaces.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/contracts-admin-cancel-repropose-tests
  • Implement changes
    • Write code in: contracts/escrow/src/lib.rs — no changes expected; only touch if a bug is found.
    • Write comprehensive tests in: contracts/escrow/src/test.rs — the cancel, re-propose, and self-proposal scenarios above.
    • Add documentation: note the covered handover behaviour in the test module header comment.
    • Include NatSpec-style doc comments (///) on any test helpers.
    • Validate security: the handover cannot be left in an inconsistent pending state.
  • 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, re-propose twice, self-proposal rejected.
  • Include the full cargo test output and a short security notes section in the PR description.

Example commit message

test: cover cancel_admin_transfer and pending-admin re-proposal

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