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.
Test the service-registration and service-disabled rejection paths
Description
The
RequireServiceRegistrationgate (ServiceNotRegistered #7) and theServiceDisabledgate (#12) inrecord_usageincontracts/escrow/src/lib.rsare uncovered bycontracts/escrow/src/test.rs. Neitherregister_service/unregister_servicenorset_service_disabledis exercised againstrecord_usage. This issue adds the missing coverage.Requirements and context
Agentpay-Org/Agentpay-contractsonly.#7; register then succeed; unregister then reject again.#12; re-enable then succeed; verify registration/metadata survive a disable.is_service_registration_required,is_service_registered, andis_service_disabledround-trips.Suggested execution
git checkout -b test/contracts-18-registry-gate-testscontracts/escrow/src/lib.rs— no changes expected.contracts/escrow/src/test.rs— the registry/disabled 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 service-registration and service-disabled gatesGuidelines
Community & contribution rewards