Skip to content

Test/contracts blocklist precedence tests - #180

Merged
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Yerimahjr:test/contracts-blocklist-precedence-tests
Jul 17, 2026
Merged

Test/contracts blocklist precedence tests#180
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Yerimahjr:test/contracts-blocklist-precedence-tests

Conversation

@Yerimahjr

@Yerimahjr Yerimahjr commented Jul 16, 2026

Copy link
Copy Markdown

Closes #176

Summary

Adds focused test coverage for the per-agent blocklist (set_agent_blocked, is_agent_blocked, AgentBlocked / #17) in record_usage, and locks down its precedence over the allowlist. No changes to contracts/escrow/src/lib.rs — the existing implementation was correct; this is test-only.

Coverage added

  • Default (no block) allows the agent to record usage.
  • Blocked agent is rejected with #17.
  • Unblock restores access.
  • is_agent_blocked round-trips (false → true → false).
  • Precedence invariant: an agent that is both allow-listed (with the allowlist enabled) and blocked is still rejected with #17, not #10 — proving the block check fires before the allowlist check.
  • Blocked agent is rejected regardless of whether the allowlist is enabled or disabled.
  • Block → unblock → re-block cycle ends in the correctly blocked state.
  • Multiple agents with mixed block/allow status handled independently in a
    running 207 tests
    ...
    test result: FAILED. 202 passed; 5 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.59s

Note on the 5 failures: these are pre-existing on main at the current HEAD (test_nonadmin_settle_without_metadata_rejected, test_owner_cannot_settle_other_service, test_record_usage_accumulates_across_calls, test_record_usage_contract_exactly_one_event_per_call, test_record_usage_isolates_services_and_large_deltas) — verified they fail identically on a clean checkout of main with none of this PR's changes applied, so they're unrelated to this PR. All new and existing blocklist tests pass.

cargo fmt --all -- --check and cargo build both pass clean.

@Yerimahjr

Copy link
Copy Markdown
Author

Note on CI: the repository's CI currently fails to build due to an unrelated upstream dependency issue — the ethnum crate (v1.5.2, pulled in transitively via soroban-env-host) fails to compile with error[E0512]: cannot transmute between types of different sizes against the current pinned Rust toolchain. This affects CI on main itself, independent of this PR, and is out of scope for this test-only change. Locally, cargo update -p ethnum resolves it; maintainers may want to bump the ethnum pin or lockfile separately.

@mikewheeleer

Copy link
Copy Markdown
Contributor

nice one — thanks for this!

@mikewheeleer
mikewheeleer merged commit e7af709 into Agentpay-Org:main Jul 17, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for the agent blocklist precedence over the allowlist in record_usage

3 participants