test(python/evm): add unit tests for multicall module#141
Open
0xAxiom wants to merge 1 commit intocoinbase:mainfrom
Open
test(python/evm): add unit tests for multicall module#1410xAxiom wants to merge 1 commit intocoinbase:mainfrom
0xAxiom wants to merge 1 commit intocoinbase:mainfrom
Conversation
Add 32 unit tests for python/x402/x402/mechanisms/evm/multicall.py — the largest EVM mechanism source file without a dedicated unit test module. Coverage: - MULTICALL3_ADDRESS canonical deployment and MULTICALL3_TRY_AGGREGATE_ABI shape - encode_contract_call: address argument, no-arg function, tuple input canonicalization, missing function ValueError, non-function ABI entries - multicall typed-call path: single uint, string, multi-output list, no-output None, ABI decode failure marked unsuccessful with error - multicall raw call_data path: skips decoding, propagates raw bytes to aggregate calls, revert maps to RuntimeError - typed entries without ABI / function name raise ValueError - mixed typed and raw arrays preserve input ordering - _normalize_results accepts dict, attribute object, and tuple shapes; rejects non-sequence response, malformed entries, and non-bytes returnData - length mismatch (too few or too many) raises ValueError - MulticallResult dataclass defaults and error propagation
🟡 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.
What
Add 32 unit tests for
python/x402/x402/mechanisms/evm/multicall.py— the largest EVM mechanism source file in the Python SDK without a dedicated unit test module.Why
multicall.pyis exercised indirectly througheip3009_utilspaths but has no module-level test file. This PR fills that gap with focused tests that pin the public API and the key normalization edge cases.Coverage
MULTICALL3_ADDRESS/MULTICALL3_TRY_AGGREGATE_ABI(3 tests)tryAggregatefunction(bool, tuple[](address,bytes))encode_contract_call(5 tests)balanceOf(address)submit((address,uint256)))ValueErrorwhen function name not in ABImulticalltyped path (5 tests)uint256outputstringoutputNonefor function with no outputserrorpopulatedmulticallrawcall_datapath (3 tests)success=Truewithresult=None(False, b"")maps toRuntimeError("multicall: call reverted")Validation guards (4 tests)
ValueErrorfunction_nameraiseValueErrorMULTICALL3_ADDRESS/tryAggregate/require_success=FalsepropagationResult-shape normalization (
_normalize_results, 6 tests)returnDatasuccess/returnDataattributes(bool, bytes)tuple entriesreturnDataMixed ordering & failures (2 tests)
success=Falsewithout attempting to decodeLength mismatch (2 tests)
ValueErrorValueErrorMulticallResultdataclass (2 tests)Test Run
Checklist
uvx ruff formatcleanuvx ruff checkcleanchangelog.d/multicall-unit-tests.doc.md)