From ffb633905d6880641965f188613ba9ee67e82f7d Mon Sep 17 00:00:00 2001 From: antazoey Date: Thu, 9 Jan 2025 18:12:18 -0600 Subject: [PATCH] test: fix other test --- src/ape_ethereum/provider.py | 5 +---- tests/functional/geth/test_provider.py | 9 ++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ape_ethereum/provider.py b/src/ape_ethereum/provider.py index 1678ec633e..40a3706890 100644 --- a/src/ape_ethereum/provider.py +++ b/src/ape_ethereum/provider.py @@ -616,10 +616,7 @@ def priority_fee(self) -> int: def _get_chain_id(self) -> int: result = self.make_request("eth_chainId", []) - if isinstance(result, int): - return result - - return int(result, 16) + return result if isinstance(result, int) else int(result, 16) def get_block(self, block_id: "BlockID") -> BlockAPI: if isinstance(block_id, str) and block_id.isnumeric(): diff --git a/tests/functional/geth/test_provider.py b/tests/functional/geth/test_provider.py index 2af47b08ab..b2f32b8a57 100644 --- a/tests/functional/geth/test_provider.py +++ b/tests/functional/geth/test_provider.py @@ -240,7 +240,14 @@ def test_connect_to_chain_that_started_poa(mock_web3, web3_factory, ethereum): to fetch blocks during the PoA portion of the chain. """ mock_web3.eth.get_block.side_effect = ExtraDataLengthError - mock_web3.eth.chain_id = ethereum.sepolia.chain_id + + def make_request(rpc, arguments): + if rpc == "eth_chainId": + return {"result": ethereum.sepolia.chain_id} + + return None + + mock_web3.provider.make_request.side_effect = make_request web3_factory.return_value = mock_web3 provider = ethereum.sepolia.get_provider("node") provider.provider_settings = {"uri": "http://node.example.com"} # fake