Skip to content

test(python/svm): add unit tests for ExactSvmSchemeV1 client#151

Open
0xAxiom wants to merge 1 commit into
coinbase:mainfrom
0xAxiom:test/python-svm-exact-v1-client-unit-tests
Open

test(python/svm): add unit tests for ExactSvmSchemeV1 client#151
0xAxiom wants to merge 1 commit into
coinbase:mainfrom
0xAxiom:test/python-svm-exact-v1-client-unit-tests

Conversation

@0xAxiom
Copy link
Copy Markdown

@0xAxiom 0xAxiom commented May 4, 2026

Summary

Add 28 unit tests for python/x402/x402/mechanisms/svm/exact/v1/client.py — the only file in mechanisms/svm/exact/v1/ without a dedicated test module. test_facilitator.py imports v1.facilitator briefly for shared-cache testing, but the V1 client surface had zero direct coverage.

Coverage

  • Constructor: scheme attribute, signer reference, default rpc_url=None, custom rpc_url stored, empty client cache.
  • _get_client: CAIP-2 devnet/mainnet → default RPC URL, V1 legacy solana-devnet/solana name normalization to CAIP-2 RPC URL, custom rpc_url priority, per-network client caching across legacy + CAIP-2 inputs (single SolanaClient construction), unsupported CAIP-2 + unsupported legacy network errors surfaced through normalize_network.
  • create_payment_payload: missing feePayer in extra, extra=None case, mint not found, unknown token program owner, oversized memo, V1 reads max_amount_required (different amounts → different serialized bytes), Token-2022 mint owner accepted, default random memo divergence across calls, custom memo round-trips into the transaction bytes, non-string memo (int) falls back to random nonce, boundary MAX_MEMO_BYTES accepted.

Test plan

  • uv run pytest tests/unit/mechanisms/svm/test_exact_v1_client.py -q → 28 passed
  • uv run ruff format clean
  • uv run ruff check clean
  • Changelog fragment added at python/x402/changelog.d/python-svm-exact-v1-client-tests.doc.md
  • Commit GPG-signed

Add 28 unit tests for python/x402/x402/mechanisms/svm/exact/v1/client.py
- the only file in mechanisms/svm/exact/v1/ without a dedicated test
module. test_facilitator.py imports v1.facilitator briefly for shared-cache
testing, but the V1 client surface had zero direct coverage.

Coverage:

- Constructor: scheme attribute, signer reference, default rpc_url=None,
  custom rpc_url stored, empty client cache.
- _get_client: CAIP-2 devnet/mainnet -> default RPC URL, V1 legacy
  'solana-devnet'/'solana' name normalization to CAIP-2 RPC URL,
  custom rpc_url priority, per-network client caching across legacy +
  CAIP-2 inputs (single SolanaClient construction), unsupported CAIP-2
  network and unsupported legacy network errors surfaced through
  normalize_network.
- create_payment_payload: missing feePayer in extra, extra=None case,
  mint not found, unknown token program owner, oversized memo, V1
  reads max_amount_required (different amounts -> different serialized
  bytes), Token-2022 mint owner accepted, default random memo
  divergence across calls, custom memo round-trips into the transaction
  bytes, non-string memo (int) falls back to random nonce, boundary
  MAX_MEMO_BYTES accepted.

All 28 tests pass; ruff format and ruff check clean.
@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

@0xAxiom
Copy link
Copy Markdown
Author

0xAxiom commented May 20, 2026

Friendly ping — this PR has been open for 16 days awaiting review. Happy to address any feedback or rebase if needed. Thanks for your time!

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