Test the atomic registration-plus-metadata entrypoint
Description
register_service_with_metadata in contracts/escrow/src/lib.rs sets ServiceRegistered(service_id) = true and writes ServiceMetadata(service_id) in one admin-gated call, emitting svc_reg(service_id, owner). contracts/escrow/src/test.rs does not verify that both slots are set by the single call, that the event carries the owner, or that the entrypoint honours the admin and pause gates. This issue adds the missing coverage for the combined entrypoint.
Requirements and context
- Repository scope:
Agentpay-Org/Agentpay-contracts only.
- Cover: after one call,
is_service_registered is true AND get_service_metadata returns the exact description + owner; the svc_reg(service_id, owner) event is emitted via env.events().all().
- Cover: re-registering an existing id overwrites its metadata (idempotent overwrite); an empty description is accepted.
- Cover: a non-admin caller is rejected; calling while paused panics
#4.
- Cover that the combined call is equivalent to the separate
register_service + set_service_metadata sequence; test-only change unless a genuine bug surfaces.
Suggested execution
- Fork the repo and create a branch
git checkout -b test/contracts-register-with-metadata-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 atomicity, event, idempotency, and gate scenarios above.
- Add documentation: note the covered behaviour in the test module header comment.
- Include NatSpec-style doc comments (
///) on any test helpers.
- Validate security: registration and metadata land together; only admin can call.
- Test and commit
Test and commit
- Run
cargo fmt --all -- --check, cargo build, and cargo test.
- Cover edge cases: overwrite existing service, empty description, paused contract, non-admin caller.
- Include the full
cargo test output and a short security notes section in the PR description.
Example commit message
test: cover register_service_with_metadata atomicity and svc_reg event
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 atomic registration-plus-metadata entrypoint
Description
register_service_with_metadataincontracts/escrow/src/lib.rssetsServiceRegistered(service_id) = trueand writesServiceMetadata(service_id)in one admin-gated call, emittingsvc_reg(service_id, owner).contracts/escrow/src/test.rsdoes not verify that both slots are set by the single call, that the event carries the owner, or that the entrypoint honours the admin and pause gates. This issue adds the missing coverage for the combined entrypoint.Requirements and context
Agentpay-Org/Agentpay-contractsonly.is_service_registeredistrueANDget_service_metadatareturns the exactdescription+owner; thesvc_reg(service_id, owner)event is emitted viaenv.events().all().#4.register_service+set_service_metadatasequence; test-only change unless a genuine bug surfaces.Suggested execution
git checkout -b test/contracts-register-with-metadata-testscontracts/escrow/src/lib.rs— no changes expected; only touch if a bug is found.contracts/escrow/src/test.rs— the atomicity, event, idempotency, and gate 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 register_service_with_metadata atomicity and svc_reg eventGuidelines
Community & contribution rewards