Skip to content

Add tests for pause/unpause event emission and idempotent toggling #42

Description

@mikewheeleer

Test the pause lifecycle events and idempotency

Description

pause and unpause in contracts/escrow/src/lib.rs each publish a ("paused",) event carrying true/false and are documented as idempotent. The existing tests test_pause_admin_can_pause and test_unpause_admin_can_unpause assert the is_paused state but never check the emitted event and never exercise the idempotent double-pause / double-unpause paths or a non-admin caller. This issue closes those gaps.

Requirements and context

  • Repository scope: Agentpay-Org/Agentpay-contracts only.
  • Cover: pause emits a paused event with true; unpause emits one with false, asserted via env.events().all().
  • Cover: pausing an already-paused contract and unpausing an already-unpaused contract are no-op writes that keep is_paused consistent (and document whether a duplicate event is still emitted).
  • Cover: a non-admin caller to pause/unpause is rejected (use scoped auth, consistent with the convention used elsewhere).
  • Test-only change unless a genuine bug surfaces.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/contracts-pause-events
  • Implement changes
    • Write code in: contracts/escrow/src/lib.rs — no changes expected.
    • Write comprehensive tests in: contracts/escrow/src/test.rs — the pause/unpause event and idempotency scenarios above.
    • Add documentation: note the covered behaviour in the test module header.
    • Include NatSpec-style doc comments (///) on any test helpers.
    • Validate security: the emergency-stop toggle behaves predictably under repeated calls.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases: pause→pause→unpause sequence, unpause before any pause, event ordering.
  • Include the full cargo test output and a short security notes section in the PR description.

Example commit message

test: cover pause/unpause events and idempotent toggling

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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions