Test that cancel_admin_transfer wipes the pending admin and its queued eta together
Description
cancel_admin_transfer in src/lib.rs removes both DataKey::PendingAdmin and DataKey::PendingAdminEta, and is documented as a no-op when nothing is pending. A botched cancel that cleared only one of the two slots would leave a dangling eta or a pending admin with no eta, breaking the timelock invariant. The existing suites cover propose/accept and the eta read, but there is no direct assertion that cancel clears both slots and is safely idempotent. This issue adds that coverage.
Requirements and context
- Repository scope: StableRoute-Org/Stableroute-contracts only.
- Test the full flow: set a timelock, propose a transfer (stamping pending admin + eta), then cancel and assert
get_pending_admin() and get_pending_admin_eta() both return None.
- Test that calling
cancel_admin_transfer with nothing pending is a no-op and does not panic.
- Test that a non-admin caller is rejected.
- Distinct from issues-4 "emit a cancelled event on cancel" (a feature) — this issue is pure cancel-state coverage.
Suggested execution
- Fork the repo and create a branch
git checkout -b test/contracts-cancel-admin-transfer-coverage
- Implement changes
- Write code in:
src/lib.rs — no production change expected.
- Write comprehensive tests in:
src/lib.rs (inline #[cfg(test)] mod test) — cover the propose-then-cancel clearing of both slots, the no-pending no-op, and non-admin rejection.
- Add documentation: none required beyond test doc comments.
- Include NatSpec-style doc comments (
///) on each new test, matching the existing style in lib.rs.
- Validate security assumptions: no dangling eta, no orphan pending admin, admin-only cancel.
- Test and commit
Test and commit
- Run
cargo fmt --all -- --check, cargo build, and cargo test.
- Cover edge cases: cancel after propose, cancel with nothing pending, and unauthorized cancel.
- Include the full
cargo test output in the PR description.
Example commit message
test: cover cancel_admin_transfer clearing both pending admin and eta
Guidelines
- Minimum 95 percent test coverage for impacted modules.
- Clear, reviewer-focused documentation.
- Timeframe: 96 hours.
Community & contribution rewards
- 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
- ⭐ 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 that cancel_admin_transfer wipes the pending admin and its queued eta together
Description
cancel_admin_transferinsrc/lib.rsremoves bothDataKey::PendingAdminandDataKey::PendingAdminEta, and is documented as a no-op when nothing is pending. A botched cancel that cleared only one of the two slots would leave a dangling eta or a pending admin with no eta, breaking the timelock invariant. The existing suites cover propose/accept and the eta read, but there is no direct assertion that cancel clears both slots and is safely idempotent. This issue adds that coverage.Requirements and context
get_pending_admin()andget_pending_admin_eta()both returnNone.cancel_admin_transferwith nothing pending is a no-op and does not panic.Suggested execution
git checkout -b test/contracts-cancel-admin-transfer-coveragesrc/lib.rs— no production change expected.src/lib.rs(inline#[cfg(test)] mod test) — cover the propose-then-cancel clearing of both slots, the no-pending no-op, and non-admin rejection.///) on each new test, matching the existing style inlib.rs.Test and commit
cargo fmt --all -- --check,cargo build, andcargo test.cargo testoutput in the PR description.Example commit message
test: cover cancel_admin_transfer clearing both pending admin and etaGuidelines
Community & contribution rewards