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.
Test the cancel and re-propose paths of the two-step admin handover
Description
The two-step admin handover in
contracts/escrow/src/lib.rssupports cancelling a pending transfer (cancel_admin_transfer) and overwriting the pending entry by re-proposing (propose_admin_transferre-write), withget_pending_adminexposing the state.contracts/escrow/src/test.rsdoes not cover the cancel path, the re-propose-overwrites-pending behaviour, or theInvalidAdminProposal (#14)self-proposal guard. This issue fills those handover gaps.Requirements and context
Agentpay-Org/Agentpay-contractsonly.PendingAdmin(get_pending_adminreturnsNone); a subsequentaccept_admin_transferpanicsNoPendingAdminTransfer (#5).get_pending_adminreflects the latest); accepting then uses the latest.InvalidAdminProposal (#14).cancel_admin_transferwith nothing pending is a no-op; only the admin can cancel; test-only change unless a genuine bug surfaces.Suggested execution
git checkout -b test/contracts-admin-cancel-repropose-testscontracts/escrow/src/lib.rs— no changes expected; only touch if a bug is found.contracts/escrow/src/test.rs— the cancel, re-propose, and self-proposal scenarios above.///) on any test helpers.Test and commit
cargo fmt --all -- --check,cargo build, andcargo test.cargo testoutput and a short security notes section in the PR description.Example commit message
test: cover cancel_admin_transfer and pending-admin re-proposalGuidelines
Community & contribution rewards