test(python/evm): add unit tests for ExactEvmSchemeV1 client#145
Open
0xAxiom wants to merge 1 commit into
Open
test(python/evm): add unit tests for ExactEvmSchemeV1 client#1450xAxiom wants to merge 1 commit into
0xAxiom wants to merge 1 commit into
Conversation
Add 23 unit tests for python/x402/x402/mechanisms/evm/exact/v1/client.py — the last source file in mechanisms/evm/exact/ without a dedicated test module. Coverage: - Constructor: scheme attribute, signer storage, raw LocalAccount auto-wrap, pre-wrapped EthAccountSigner pass-through. - create_payment_payload: returns inner dict with authorization+signature, hex-encoded 65-byte signature, V1 max_amount_required mapped to value, from/to address mapping, valid_after = now-600s, valid_before honors max_timeout_seconds, falsy timeout falls back to 600s, nonce is fresh per call and 32 bytes. - _sign_authorization V1 specifics: legacy network names resolve to chain IDs (base→8453, base-sepolia→84532), unknown legacy names raise ValueError, CAIP-2 format is rejected (V2-only), JSON-string extra is parsed, missing name falls back to V1 asset_info, missing name + unregistered asset raises, missing version defaults to '1', signer receives TypedDataField objects, bytes signature is hex-encoded with 0x prefix. All 23 tests pass; full mechanisms/evm suite still passes (277 tests).
🟡 Heimdall Review Status
|
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 23 unit tests for
python/x402/x402/mechanisms/evm/exact/v1/client.py— the last source file inmechanisms/evm/exact/without a dedicated unit test module.mechanisms/evm/exact/v1/client.py(ExactEvmSchemeV1) is the V1-legacy client counterpart ofmechanisms/evm/exact/client.py(ExactEvmScheme). The V2 client has had dedicated coverage for a while; the V1 client only had partial integration coverage. This PR closes the gap so the V1 codepath is exercised at unit-test granularity.What's covered
TestExactEvmSchemeV1Constructor(4 tests)schemeattribute is"exact"_signerLocalAccountinEthAccountSignerEthAccountSignerTestCreatePaymentPayloadV1(9 tests)authorization+signature0x-prefixed, 132 chars (65-byte ECDSA, hex-encoded)max_amount_required→ authorizationvaluefromis signer address,toisrequirements.pay_tovalid_after = now - 600s(V1 buffer)valid_before = now + max_timeout_secondsmax_timeout_seconds(e.g.0) falls back to 600s0x+ 64 hexTestSignAuthorizationV1(10 tests)base→ 8453,base-sepolia→ 84532)ValueError("Unknown v1 network …")eip155:8453) is rejected (V2-only)extraaccepts a JSON string and is re-parsed (json.loads)namefalls back to V1get_asset_infolookupname+ unregistered asset →ValueError("EIP-712 domain name required …")versiondefaults to"1"TypedDataFieldlists (not raw dicts)0xprefixVerification
Notes
🤖 Generated with Claude Code