test(python/evm): add unit tests for EthAccountSignerWithRPC#147
Open
0xAxiom wants to merge 1 commit intocoinbase:mainfrom
Open
test(python/evm): add unit tests for EthAccountSignerWithRPC#1470xAxiom wants to merge 1 commit intocoinbase:mainfrom
0xAxiom wants to merge 1 commit intocoinbase:mainfrom
Conversation
EthAccountSignerWithRPC was the only signer class in python/x402/mechanisms/evm/signers.py without dedicated unit tests (test_signer.py covered EthAccountSigner and FacilitatorWeb3Signer but not the RPC-extended subclass used by gas-sponsoring extensions). Tests cover: - TestEthAccountSignerWithRPC: address inheritance from EthAccountSigner, isinstance subclass relationship, Web3.HTTPProvider construction wiring, inherited sign_typed_data still works, read_contract checksums the contract address and returns the call() value, sign_transaction returns the '0x'-prefixed hex of raw_transaction bytes and forwards account.key, get_transaction_count checksums the input address before the RPC call, estimate_fees_per_gas computes (base*2 + priority, priority) from the latest block, estimate_fees_per_gas falls back to 1 gwei base when the block omits baseFeePerGas (legacy chain path), and the RPC-extended client signer surface is present and callable.
🟡 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
EthAccountSignerWithRPC(inpython/x402/mechanisms/evm/signers.py) was the only signer class in that module without dedicated unit tests.tests/unit/mechanisms/evm/test_signer.pyalready coveredEthAccountSignerandFacilitatorWeb3Signer, but the RPC-extended client signer used by gas-sponsoring extensions (EIP-2612, ERC-20 approval) had no tests.This PR adds 9 tests in a new
TestEthAccountSignerWithRPCclass covering the constructor, the inherited surface, and each of the four added RPC methods (read_contract,sign_transaction,get_transaction_count,estimate_fees_per_gas), including thebaseFeePerGas-missing fallback path.Tests
test_should_create_signer_and_inherit_address— address inherited fromEthAccountSignertest_should_be_subclass_of_eth_account_signer—isinstance(EthAccountSigner)holdstest_should_construct_web3_with_rpc_url—Web3.HTTPProviderwired with the given URLtest_should_inherit_sign_typed_data— inheritedsign_typed_datastill produces a 65+ byte signaturetest_read_contract_should_call_function_and_return_value— checksums the contract address and returns thecall()valuetest_sign_transaction_should_return_hex_prefixed_raw_tx— returns"0x" + raw_transaction.hex()and forwardsaccount.keytest_get_transaction_count_should_checksum_address— passes a checksummed address toweb3.eth.get_transaction_counttest_estimate_fees_per_gas_should_compute_eip1559_fees— returns(base*2 + priority, priority)frometh.get_block("latest")test_estimate_fees_per_gas_should_default_base_fee_when_missing— falls back to 1 gwei base when the block omitsbaseFeePerGas(legacy / non-EIP-1559 chain path)test_implements_client_evm_signer_protocol— verifies the inherited + added surface is present and callableVerification
No changeset fragment per the contributor guide (test-only changes are skipped).
Scope
Tests only. No changes to
signers.pyitself.