test(python/evm): add unit tests for register helpers#143
Open
0xAxiom wants to merge 1 commit into
Open
Conversation
Add 30 unit tests for python/x402/x402/mechanisms/evm/exact/register.py covering register_exact_evm_client, register_exact_evm_server, and register_exact_evm_facilitator. This is the only file in mechanisms/evm/exact/ that previously lacked a dedicated unit test module. Coverage: - register_exact_evm_client: default wildcard + V1 fanout, str/list networks, suppression of wildcard when networks specified, policy registration (with and without policies arg), V2/V1 scheme instance binding to signer, LocalAccount auto-wrapping, sync variant. - register_exact_evm_server: default wildcard, str/list networks, no V1 registration, scheme instance type, sync variant. - register_exact_evm_facilitator: str/list networks, V1 fanout across all V1_NETWORKS, V2/V1 scheme instance binding to signer, default config flags (False), full propagation of deploy_erc4337_with_eip6492 and simulate_in_settle to both V2 and V1 configs, partial flag propagation, sync variant. Signed-off-by: Axiom Bot <0xAxiom@users.noreply.github.com>
🟡 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 30 unit tests for
python/x402/x402/mechanisms/evm/exact/register.py— the only source file inmechanisms/evm/exact/without a dedicated unit test module.The three public helpers (
register_exact_evm_client,register_exact_evm_server,register_exact_evm_facilitator) are the canonical entry points users hit when wiring EVM exact schemes intox402Client,x402ResourceServer, andx402Facilitator(and their sync variants), so direct coverage is worthwhile.What's tested
register_exact_evm_client(13 tests)eip155:*V2 wildcard + V1 schemes for every entry inV1_NETWORKSnetworks="eip155:8453"(string) registers a single V2 entry;networks=["eip155:8453", "eip155:1", "eip155:137"]registers eachnetworkssuppresses the wildcard fallback but does not suppress the V1 fanoutpolicies=[...]appends to the client's policy list; omitting policies leaves it untouchedExactEvmClientSchemewith_signer is signer; V1 scheme on"base"isExactEvmSchemeV1with_signer is signereth_account.LocalAccountis auto-wrapped inEthAccountSignervia_wrap_if_local_accountx402ClientSyncas well asx402Clientregister_exact_evm_server(7 tests)eip155:*wildcard;networksarg as string or list registers exactly those networksExactEvmServerSchemex402ResourceServerSyncas well asx402ResourceServerregister_exact_evm_facilitator(10 tests)networksas string or list registers each V2 network correctlyV1_NETWORKSsetExactEvmScheme(facilitator) with_signer is signer; V1 isExactEvmSchemeV1(facilitator) with_signer is signerdeploy_erc4337_with_eip6492andsimulate_in_settleareFalseon V2 and V1 configsx402FacilitatorSyncas well asx402FacilitatorTest fixture notes
Client tests use a real
EthAccountSignerwrapping a fresheth_account.Account.create()(no network calls). Facilitator tests use aMagicMocksigner with anaddressattribute — sufficient becauseregister_exact_evm_facilitatoronly stores the signer reference on the scheme; no signer methods are invoked during registration.Verification
Changelog
Added
python/x402/changelog.d/register-helpers-unit-tests.doc.md.Test plan
ruff formatandruff checkcleanSigned-off-byline included