Skip to content

test(python/evm): add unit tests for ExactEvmSchemeV1 facilitator#146

Open
0xAxiom wants to merge 1 commit into
coinbase:mainfrom
0xAxiom:test/python-evm-v1-facilitator-unit-tests
Open

test(python/evm): add unit tests for ExactEvmSchemeV1 facilitator#146
0xAxiom wants to merge 1 commit into
coinbase:mainfrom
0xAxiom:test/python-evm-v1-facilitator-unit-tests

Conversation

@0xAxiom
Copy link
Copy Markdown

@0xAxiom 0xAxiom commented May 4, 2026

Summary

Adds 36 unit tests for python/x402/x402/mechanisms/evm/exact/v1/facilitator.py — the only file in mechanisms/evm/exact/v1/ without a dedicated test module.

The existing test_facilitator.py contains a single V1 case (TestVerifyV1::test_rejects_overpayment_amount_mismatch); every other path through ExactEvmSchemeV1 (legacy network lookup, JSON-domain validation, validity windows, signature classification fallbacks, settle, smart-wallet deployment) had no coverage.

Coverage

TestExactEvmSchemeV1Constructor (2)

  • default and custom ExactEvmSchemeV1Config wiring

TestExactEvmSchemeV1Attributes (4)

  • scheme, caip_family, get_extra, get_signers

TestVerifyV1 (21)

  • top-level scheme mismatch (payload and requirements)
  • network mismatch (top-level V1 field)
  • unknown legacy network (get_evm_chain_id failure → ERR_FAILED_TO_GET_NETWORK_CONFIG)
  • missing EIP-712 domain (full + version-only)
  • recipient mismatch
  • amount mismatch (under/over)
  • validBefore too close to now (6-second buffer)
  • validAfter in future
  • empty signature → ERR_INVALID_SIGNATURE
  • EOA invalid signature → ERR_INVALID_SIGNATURE
  • undeployed smart wallet without deployment info → ERR_UNDEPLOYED_SMART_WALLET
  • malformed signature triggers ERR_FAILED_TO_VERIFY_SIGNATURE
  • EOA-valid + simulation success
  • deployed ERC-1271 simulation fallback success
  • undeployed ERC-6492 simulation success/failure
  • diagnostic results: name mismatch, nonce already used, insufficient balance

TestSettleV1 (9)

  • short-circuit on verify failure (preserves payer + network)
  • success path with default config (simulate_in_settle=False)
  • success path with simulate_in_settle=True
  • bad receipt → ERR_TRANSACTION_FAILED
  • write exception → wrapped error message
  • undeployed wallet rejected when deploy_erc4337_with_eip6492=False
  • deploy-then-write success when enabled
  • deploy receipt failure → ERR_SMART_WALLET_DEPLOYMENT_FAILED

Test Plan

  • uv run pytest tests/unit/mechanisms/evm/test_v1_facilitator.py — 36/36 pass
  • uv run pytest tests/unit/mechanisms/evm/ — 290/290 pass (no regressions)
  • uvx ruff format — no changes
  • uvx ruff check — no issues
  • GPG-signed commit

Add 36 unit tests for python/x402/x402/mechanisms/evm/exact/v1/facilitator.py
- the only file in mechanisms/evm/exact/v1/ without a dedicated test module.
The existing test_facilitator.py contains a single V1 case (overpayment amount
mismatch) inside TestVerifyV1; the V1 facilitator's other paths (legacy network
lookup, JSON-domain validation, validity windows, signature classification,
settle, smart-wallet deployment) had no coverage.

Tests cover:
- TestExactEvmSchemeV1Constructor: default and custom config wiring
- TestExactEvmSchemeV1Attributes: scheme, caip_family, get_extra, get_signers
- TestVerifyV1: scheme/network mismatch (top-level V1 fields), unknown legacy
  network (get_evm_chain_id failure), missing eip712 domain (full and
  version-only), recipient mismatch, amount mismatch (under/over), validBefore
  too close to now, validAfter in future, empty signature, EOA invalid,
  undeployed smart wallet without deployment info, classify exception path,
  EOA-valid + simulation success, deployed ERC1271 simulation fallback,
  undeployed ERC6492 simulation success/failure, diagnostic name mismatch /
  nonce used / insufficient balance
- TestSettleV1: short-circuit on verify failure, success path with default
  config, simulate_in_settle=True path, transaction failed receipt, write
  exception with parsed error, undeployed wallet rejected when deploy disabled,
  deploy-then-write success, deploy-receipt failure (smart wallet deployment
  failed)
@cb-heimdall
Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants