Skip to content

test(policy,budget): pin deterministic error codes at boundary - #435

Merged
Cjay-Cyber-2 merged 4 commits into
ASTROIDX556:mainfrom
Martinsbab:test/252-deterministic-error-codes
Oct 7, 2026
Merged

Cjay-Cyber-2 merged 4 commits into
ASTROIDX556:mainfrom
Martinsbab:test/252-deterministic-error-codes

Conversation

@Martinsbab

Copy link
Copy Markdown
Contributor

Summary

  • Added policy boundary and failure-path error validation tests.
  • Added budget limit and boundary error validation tests.
  • Verified deterministic error codes and safe out-of-bounds handling.

Testing

  • cargo test -p astroid-policy
  • cargo test -p astroid-budget
  • cargo test --workspace

Closes #252

Martinsbab and others added 3 commits October 3, 2026 07:47
…ilure paths

Adds unit tests to contracts/policy and contracts/budget that assert the
exact wire code (the literal u32 an off-chain consumer decodes) rather than
only the error variant, so a table renumber or a refusal routed through the
wrong gate fails in CI instead of in production.

Policy: single-transaction ceiling boundary (20), malformed amounts (12),
unknown policy (1), disabled policy (20), cumulative allowance ceiling (83)
including a ceiling lowered below spent, lapsed allowance (84), pinned
recipient (20), recipient blocklist (22), merchant blocklist (23), asset
allow-list (43), and out-of-bounds amounts failing closed without panicking.

Budget: exact-limit acceptance and one-unit-over BUDGET_EXCEEDED (40) on
every spend entrypoint, INVALID_AMOUNT (12), NOT_FOUND (1), UNAUTHORIZED
(3), lifecycle gates frozen (41), archived (42), unregistered asset (43),
expired (44), not-yet-started (45), and i128 boundary spends failing with
OVERFLOW (11) instead of wrapping.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@Cjay-Cyber-2

Copy link
Copy Markdown
Contributor

CI Checks Failed — Action Needed

The required test job does not compile. contracts/budget/src/test.rs has multiple E0308 mismatches because assertions such as lines 2355, 2389, 2402, 2419, 2429, 2437, 2481, 2509, 2529, and 2538 compare try_* results to Err(Ok(Error::...)), but the current generated client returns a nested conversion/invocation result with a different error shape. Update these assertions (and the shared_wire_code call around line 3212) to match the current try_* return types, then rerun the full workspace tests.

@Cjay-Cyber-2
Cjay-Cyber-2 merged commit 9d0fe37 into ASTROIDX556:main Oct 7, 2026
1 of 4 checks passed
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.

Implement deterministic error code validation tests for policy and budget enforcement contracts

2 participants