This guide covers the complete testing workflow for Shielded x402, from baseline checks to integration testing across multiple chains.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nhestrompia/shielded-x402/llms.txt
Use this file to discover all available pages before exploring further.
Testing Philosophy
Shielded x402 testing ensures:- Protocol correctness: Nonce progression, balance enforcement, and state transitions
- Multi-chain reliability: Integration tests across Base and Solana
- Cryptographic soundness: Circuit verification and proof generation
- API contract compliance: Sequencer and relayer behavior validation
Baseline Checks
Run these checks before any development or release:Package-Level Tests
Test individual packages in isolation:Shared Types
Client SDK
- Note management and indexing
- Witness construction
- Payment preparation
- Multi-chain credit client operations
Merchant SDK
- Payment verification
- Header parsing
- Requirement generation
Payment Relayer
- Authorization validation
- Payout provider integration
- Execution report generation
- Chain-specific adapters
Protocol Property Tests
These tests verify critical protocol invariants:Strict per-agent nonce progression
Strict per-agent nonce progression
Validates that
agentNonce == nextAgentNonce for all accepted authorizations.Why it matters: Prevents replay attacks and ensures temporal ordering of payments.No overspend
No overspend
Ensures
balanceMicros never goes negative.Why it matters: Core financial invariant - agents can only spend credited funds.Execution idempotency
Execution idempotency
Verifies:
auth_idis unique across all authorizations- Duplicate transaction hash is accepted (safe retry)
- Conflicting hash for same auth_id is rejected
Reclaim transition guard
Reclaim transition guard
Validates
ISSUED -> RECLAIMED transition only after expiry.Why it matters: Prevents premature reclaims that could enable double-spending.Relayer chainRef enforcement
Relayer chainRef enforcement
Ensures each relayer instance only processes payments for its configured chain.Why it matters: Prevents cross-chain execution errors.
Local Integration Testing
Test the complete flow with a local Anvil chain.Sequencer/Relayer Integration
Test the full sequencer and relayer interaction:Solana Integration Tests
Test Solana-specific functionality:Run authorization flow
Execute authorize → relay pay → execution report sequence.
Verify sequencer status shows
EXECUTED.Indexer Note: Solana indexer is optional for MVP correctness. The sequencer remains the source of truth, with relayers submitting execution reports containing transaction signatures. Add a Solana indexer later for observability and reconciliation.
Base Commitment Registry Tests
Test Base-specific commitment functionality:- Epoch sequencing
prevRootlinkage between epochs- Unauthorized poster rejection
- Commitment merkle tree construction
Pre-Release Regression Checklist
Run this full suite before any release:Continuous Integration
The testing playbook is designed for CI/CD integration. Recommended workflow:Writing New Tests
When adding new functionality, follow these guidelines:Unit Tests
Place tests alongside source code:Integration Tests
Use descriptive test names that explain the scenario:Property-Based Tests
For protocol invariants, use property-based testing:Troubleshooting Test Failures
Circuit check failures
Circuit check failures
Symptoms:
pnpm circuit:check fails with verification errorsSolutions:- Ensure Noir is installed:
noirup - Rebuild circuits:
pnpm circuit:build - Check circuit artifact freshness in
dist/circuits/
Contract test failures
Contract test failures
Symptoms: Foundry tests fail or timeoutSolutions:
- Install contract dependencies:
pnpm contracts:deps - Update Foundry:
foundryup - Check for chain compatibility issues
Integration test timeouts
Integration test timeouts
Symptoms: Tests hang or timeout waiting for servicesSolutions:
- Verify all services are running: check health endpoints
- Increase test timeouts for network operations
- Check service logs for errors
Solana program test failures
Solana program test failures
Symptoms: Program deployment or tests failSolutions:
- Ensure Solana CLI is installed and updated
- Check RPC endpoint availability
- Verify keypair permissions and SOL balance
Test Coverage
Monitor test coverage to ensure adequate testing:- Protocol logic: 90%+
- SDK public APIs: 85%+
- Utility functions: 80%+
Next Steps
Examples
Explore example applications
Installation
Set up your development environment
Infrastructure
Deploy sequencer and relayers
Migration Guide
Migrate from legacy versions