test(settlement): cover the settle_all MAX_SETTLE_ALL boundary - #323
Merged
mikewheeleer merged 1 commit intoJul 28, 2026
Merged
Conversation
record_usage caps the per-agent service index at MAX_AGENT_SERVICE_INDEX (== MAX_SETTLE_ALL), so settle_all's SettleAllTooLarge guard had zero test coverage: it can't be reached through the public API alone (it exists to protect a future migration that could write a larger index). Added two tests that write an oversized index directly via `as_contract`, mirroring the existing `..._via_storage_helper` pattern: - exactly-at-boundary (256 services): succeeds, settles all of them. - one-over-boundary (257 services): panics with SettleAllTooLarge (Agentpay-Org#19). Note: the exactly-at-boundary test needs env.budget().reset_unlimited() — settling 256 services in one call (2 storage reads + 2 writes + 1 event each) exceeds the default test budget around service Agentpay-Org#178. This is a test-harness-only accommodation, but it's a real signal: a settle_all call anywhere near the configured MAX_SETTLE_ALL would likely also exceed real network resource limits on-chain. Worth a follow-up look at whether MAX_SETTLE_ALL should be tightened, separate from this test-coverage change.
Contributor
|
neat work @thlpkee20-wq — thanks for the care. merging 🌱 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #299
`record_usage` caps the per-agent service index at
`MAX_AGENT_SERVICE_INDEX` (== `MAX_SETTLE_ALL`), so `settle_all`'s
`SettleAllTooLarge` guard had zero test coverage — it can't be
reached through the public API alone (its own doc comment says as much:
it exists to protect a future migration that could write a larger
index).
Added two tests that write an oversized index directly via
`as_contract`, mirroring the existing `..._via_storage_helper` pattern
used for other invariants in this file:
(Add tests for lifetime usage counters and last-settlement timestamps #19).
A real finding along the way
The exactly-at-boundary test needed `env.budget().reset_unlimited()` —
settling 256 services in one call (2 storage reads + 2 writes + 1 event
each) exceeded the default test budget around service #178. That's a
test-harness-only accommodation for this PR, but it's a genuine signal:
a `settle_all` call anywhere near the configured `MAX_SETTLE_ALL` would
likely also exceed real network resource limits on-chain. Flagging this
as worth a follow-up look at whether `MAX_SETTLE_ALL` should be
tightened — that's a behavior change I did not make here, out of scope
for a test-coverage PR.
Test plan
pre-existing, unrelated test covered by fix(test): correct cross-call event-count assumption in ownership-transfer test #315.