Test the agent allowlist gate end to end
Description
The allowlist logic in record_usage (and set_allowlist_enabled, set_agent_allowed, is_agent_allowed) in contracts/escrow/src/lib.rs has no coverage in contracts/escrow/src/test.rs — no test asserts that an off-allowlist agent is rejected with AgentNotAllowed (#10) or that disabling the gate restores access. This issue closes that gap with focused tests.
Requirements and context
- Repository scope:
Agentpay-Org/Agentpay-contracts only.
- Cover: allowlist disabled (default) allows any agent; enabled + agent not listed → panic
#10; enabled + agent allowed → succeeds; allowed then revoked → rejected again.
- Assert
is_allowlist_enabled and is_agent_allowed round-trips.
- Use
#[should_panic(expected = "Error(Contract, #10)")] matching the existing test conventions.
- Do not modify contract logic; this is a test-only change unless a genuine bug surfaces (then file separately).
Suggested execution
- Fork the repo and create a branch
git checkout -b test/contracts-16-allowlist-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 allowlist scenarios above.
- Add documentation: note the covered behaviour in the test module header comment.
- Include NatSpec-style doc comments (
///) where helper functions are added.
- Validate security: tests prove the gate cannot be bypassed.
- Test and commit
Test and commit
- Run
cargo fmt --all -- --check, cargo build, and cargo test.
- Cover edge cases: toggling the gate while usage exists, multiple agents with mixed status.
- Include the full
cargo test output and a short security notes section in the PR description.
Example commit message
test: cover agent allowlist enforcement in record_usage
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 agent allowlist gate end to end
Description
The allowlist logic in
record_usage(andset_allowlist_enabled,set_agent_allowed,is_agent_allowed) incontracts/escrow/src/lib.rshas no coverage incontracts/escrow/src/test.rs— no test asserts that an off-allowlist agent is rejected withAgentNotAllowed (#10)or that disabling the gate restores access. This issue closes that gap with focused tests.Requirements and context
Agentpay-Org/Agentpay-contractsonly.#10; enabled + agent allowed → succeeds; allowed then revoked → rejected again.is_allowlist_enabledandis_agent_allowedround-trips.#[should_panic(expected = "Error(Contract, #10)")]matching the existing test conventions.Suggested execution
git checkout -b test/contracts-16-allowlist-testscontracts/escrow/src/lib.rs— no changes expected; only touch if a bug is found.contracts/escrow/src/test.rs— the allowlist scenarios above.///) where helper functions are added.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 agent allowlist enforcement in record_usageGuidelines
Community & contribution rewards