Skip to content

Add tests for strict service-registration and service-disabled gates #18

Description

@mikewheeleer

Test the service-registration and service-disabled rejection paths

Description

The RequireServiceRegistration gate (ServiceNotRegistered #7) and the ServiceDisabled gate (#12) in record_usage in contracts/escrow/src/lib.rs are uncovered by contracts/escrow/src/test.rs. Neither register_service/unregister_service nor set_service_disabled is exercised against record_usage. This issue adds the missing coverage.

Requirements and context

  • Repository scope: Agentpay-Org/Agentpay-contracts only.
  • Cover: strict mode off allows unknown services; strict on + unregistered → panic #7; register then succeed; unregister then reject again.
  • Cover: registered + disabled service → panic #12; re-enable then succeed; verify registration/metadata survive a disable.
  • Assert is_service_registration_required, is_service_registered, and is_service_disabled round-trips.
  • Test-only change unless a genuine bug surfaces.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/contracts-18-registry-gate-tests
  • Implement changes
    • Write code in: contracts/escrow/src/lib.rs — no changes expected.
    • Write comprehensive tests in: contracts/escrow/src/test.rs — the registry/disabled scenarios above.
    • Add documentation: note covered behaviour in the test module header.
    • Include NatSpec-style doc comments (///) on any test helpers.
    • Validate security: disabled services cannot accrue usage.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases: disable an unregistered service, strict mode with disabled service, toggling order.
  • Include the full cargo test output and a short security notes section in the PR description.

Example commit message

test: cover service-registration and service-disabled gates

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 fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions