Fix ordering in failing tests - chain id needs to be set before creating EthereumClient.

pull/3531/head
derekpierre 2024-07-26 13:11:12 -04:00
parent 49af6cbefd
commit a0f21e8f4d
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View File

@ -10,11 +10,11 @@ CHAIN_ID = 23
@pytest.mark.parametrize("chain_id_return_value", [hex(CHAIN_ID), CHAIN_ID])
def test_cached_chain_id(mocker, chain_id_return_value):
web3_mock = mocker.MagicMock()
mock_client = EthereumClient(w3=web3_mock)
chain_id_property_mock = PropertyMock(return_value=chain_id_return_value)
type(web3_mock.eth).chain_id = chain_id_property_mock
mock_client = EthereumClient(w3=web3_mock)
assert mock_client.chain_id == CHAIN_ID
chain_id_property_mock.assert_called_once()

View File

@ -15,11 +15,11 @@ CHAIN_ID = 11155111 # pretend to be sepolia
@pytest.mark.parametrize("chain_id_return_value", [hex(CHAIN_ID), CHAIN_ID])
def test_cached_chain_id(mocker, chain_id_return_value):
web3_mock = mocker.MagicMock()
mock_client = EthereumClient(w3=web3_mock)
chain_id_property_mock = PropertyMock(return_value=chain_id_return_value)
type(web3_mock.eth).chain_id = chain_id_property_mock
mock_client = EthereumClient(w3=web3_mock)
assert mock_client.chain_id == CHAIN_ID
chain_id_property_mock.assert_called_once()