test(python/svm): add unit tests for ExactSvmSchemeV1 client#151
Open
0xAxiom wants to merge 1 commit intocoinbase:mainfrom
Open
test(python/svm): add unit tests for ExactSvmSchemeV1 client#1510xAxiom wants to merge 1 commit intocoinbase:mainfrom
0xAxiom wants to merge 1 commit intocoinbase:mainfrom
Conversation
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.
🟡 Heimdall Review Status
|
7 tasks
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.
Summary
Add 28 unit tests for
python/x402/x402/mechanisms/svm/exact/v1/client.py— the only file inmechanisms/svm/exact/v1/without a dedicated test module.test_facilitator.pyimportsv1.facilitatorbriefly for shared-cache testing, but the V1 client surface had zero direct coverage.Coverage
rpc_url=None, customrpc_urlstored, empty client cache._get_client: CAIP-2 devnet/mainnet → default RPC URL, V1 legacysolana-devnet/solananame normalization to CAIP-2 RPC URL, customrpc_urlpriority, per-network client caching across legacy + CAIP-2 inputs (singleSolanaClientconstruction), unsupported CAIP-2 + unsupported legacy network errors surfaced throughnormalize_network.create_payment_payload: missingfeePayerinextra,extra=Nonecase, mint not found, unknown token program owner, oversized memo, V1 readsmax_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, boundaryMAX_MEMO_BYTESaccepted.Test plan
uv run pytest tests/unit/mechanisms/svm/test_exact_v1_client.py -q→ 28 passeduv run ruff formatcleanuv run ruff checkcleanpython/x402/changelog.d/python-svm-exact-v1-client-tests.doc.md