Always call `_check_chain_id` in rpc based condition

pull/3566/head
James Campbell 2024-12-06 13:51:37 +01:00
parent 47f8bd39c7
commit 6f03e2283d
No known key found for this signature in database
2 changed files with 5 additions and 6 deletions

View File

@ -173,11 +173,9 @@ class RPCCall(ExecutionCall):
self,
provider: HTTPProvider,
resolved_parameters: List[Any],
check_chain: bool = True,
) -> Any:
w3 = self._configure_w3(provider)
if check_chain:
self._check_chain_id(w3)
self._check_chain_id(w3)
return self._execute(w3, resolved_parameters)
def execute(self, providers: Dict[int, Set[HTTPProvider]], **context) -> Any:
@ -204,7 +202,7 @@ class RPCCall(ExecutionCall):
if self.rpc_endpoint:
result, error = self._execute_with_provider(
HTTPProvider(self.rpc_endpoint), resolved_parameters, check_chain=False
HTTPProvider(self.rpc_endpoint), resolved_parameters
)
if error:
raise RPCExecutionFailed(error)

View File

@ -145,7 +145,7 @@ def test_rpc_condition_uses_provided_endpoint(mocker):
# Mock eth module
mock_w3 = mocker.Mock()
mock_w3.eth.get_balance.return_value = 0
mock_w3.eth.chain_id = 8453
mock_w3.eth.chain_id = TESTERCHAIN_CHAIN_ID
# Patch RPCCall._configure_w3 method
mocker.patch(
@ -206,7 +206,8 @@ def test_rpc_condition_execution_priority(mocker):
mock_http_provider_spy.reset_mock()
# Test Case 2: Unsupported chain - should use rpc_endpoint
unsupported_chain = 99999 # Chain not in _CONDITION_CHAINS
unsupported_chain = 8453
mock_eth.chain_id = unsupported_chain
condition = RPCCondition(
method="eth_getBalance",
chain=unsupported_chain,