test(python/evm): add unit tests for eip3009_utils helpers#139
Open
0xAxiom wants to merge 1 commit into
Open
Conversation
Add 61 unit tests for python/x402/x402/mechanisms/evm/exact/eip3009_utils.py, the largest source file in the EVM mechanism without a dedicated test module. All public helpers plus the _split_signature_parts private helper are covered. - parse_eip3009_authorization (7): field round-trip, numeric coercion, nonce length validation (short/long/empty/no-prefix), bad value raises. - _split_signature_parts (8): v=27/28 passthrough, v=0/1 normalization, 64/66/0-byte ECDSA inputs raise, high-v values pass through unchanged. - parse_eip3009_transfer_error (10): expired, not-yet-valid, used, insufficient-balance, invalid-signature variants; case insensitivity; unknown/empty fall back to ERR_TRANSACTION_FAILED; first-match priority. - classify_eip3009_signature (6): valid EOA, valid smart wallet (ERC-6492 wrapper), valid non-65-byte inner, invalid w/ deployed code, invalid w/ deployment info but no code (undeployed), invalid plain EOA. - simulate_eip3009_transfer (8): undeployed multicall success/failure/raise/ short-results; 65-byte EOA success and revert; non-65-byte fallback path. - diagnose_eip3009_simulation_failure (12): multicall raise, short results, authState failure/used, name/version mismatch, insufficient balance, empty token_name/version skips check, balance failure swallowed, non-int balance handled, all-clean default. - execute_transfer_with_authorization (3): VRS ABI for 65-byte EOA, bytes ABI for smart wallet, authorization arguments forwarded.
🟡 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
Adds 61 unit tests for
python/x402/x402/mechanisms/evm/exact/eip3009_utils.py— the largest source file in the EVM mechanism without a dedicated test module. Covers every public helper plus the_split_signature_partsprivate helper that gates ECDSA signature handling fortransferWithAuthorization.Coverage
parse_eip3009_authorization_split_signature_partsparse_eip3009_transfer_errorERR_TRANSACTION_FAILED, first-match priorityclassify_eip3009_signaturesimulate_eip3009_transferdiagnose_eip3009_simulation_failuretoken_name/token_versionskips check, balance failure swallowed, non-int balance handled, all-clean defaultexecute_transfer_with_authorizationFacilitatorEvmSignerandmulticallare mocked — the goal is to lock in the control-flow contracts (which ABI is chosen, which error code is returned, which arguments are forwarded), not to replay an actual EVM RPC.Test plan
uv run pytest tests/unit/mechanisms/evm/test_eip3009_utils.py— 61 passeduv run pytest tests/unit/mechanisms/evm/— 315 passed (no regressions)uv run ruff check tests/unit/mechanisms/evm/test_eip3009_utils.pyuv run ruff format --check tests/unit/mechanisms/evm/test_eip3009_utils.pypython/x402/changelog.d/139.doc.md)AI usage
This PR was AI-assisted (Claude). Test cases were derived from reading
eip3009_utils.pydirectly — assertions follow the actual control flow, not a fabricated spec. Reviewed before submission.