Skip to content

Commit

Permalink
Fix weak test (#1562)
Browse files Browse the repository at this point in the history
  • Loading branch information
moisses89 authored Feb 17, 2025
1 parent 2ee47fd commit 7ba475c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions safe_eth/eth/tests/clients/test_etherscan_client_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def get_etherscan_api(cls, network: EthereumNetwork):

return EtherscanClientV2(network, api_key=etherscan_api_key)

@pytest.mark.flaky(reruns=5)
def test_etherscan_get_abi(self):
try:
etherscan_api = self.get_etherscan_api(EthereumNetwork.MAINNET)
Expand All @@ -44,6 +45,7 @@ def test_etherscan_get_abi(self):
except EtherscanRateLimitError:
self.skipTest("Etherscan rate limit reached")

@pytest.mark.flaky(reruns=5)
def test_etherscan_get_contract_metadata(self):
try:
etherscan_api = self.get_etherscan_api(EthereumNetwork.MAINNET)
Expand All @@ -59,6 +61,7 @@ def test_etherscan_get_contract_metadata(self):
except EtherscanRateLimitError:
self.skipTest("Etherscan rate limit reached")

@pytest.mark.flaky(reruns=5)
def test_is_supported_network(self):
try:
self.assertTrue(
Expand All @@ -81,6 +84,7 @@ def get_etherscan_api(cls, network: EthereumNetwork):

return AsyncEtherscanClientV2(network, api_key=etherscan_api_key)

@pytest.mark.flaky(reruns=5)
async def test_async_etherscan_get_abi(self):
try:
etherscan_api = self.get_etherscan_api(EthereumNetwork.MAINNET)
Expand Down
9 changes: 8 additions & 1 deletion safe_eth/eth/tests/test_ethereum_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,11 +1270,18 @@ def test_send_unsigned_transaction(self):
"gas": 25000,
"gasPrice": self.ethereum_client.w3.eth.gas_price,
}
with self.assertRaises(InsufficientFunds):

with self.assertRaises(Exception) as error:
self.ethereum_client.send_unsigned_transaction(
tx, private_key=random_sender_account.key
)

# Depending on RPC side the error could be InsufficientFunds or Web3RPCError
self.assertTrue(
isinstance(error.exception, (InsufficientFunds, Web3RPCError)),
f"Expected InsufficientFunds or Web3RPCError, but got {type(error.exception)}",
)

def test_trace_block(self):
block_numbers = [13191781, 2191709, 15630274]
block_mocks = [
Expand Down

0 comments on commit 7ba475c

Please sign in to comment.