From dafa2dbb1335c96cc7f873f9745955d1d1290384 Mon Sep 17 00:00:00 2001 From: Benjamin Smith Date: Fri, 16 Aug 2024 13:44:12 +0200 Subject: [PATCH] fix tests by updating web3 (#386) More issues with type upgrade: https://github.com/cowprotocol/solver-rewards/actions/runs/10418093867/job/28853575355 --- requirements.txt | 2 +- tests/e2e/test_post_transaction.py | 12 +++++++----- tests/e2e/test_token_details.py | 12 +++++------- tests/unit/test_multisend.py | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/requirements.txt b/requirements.txt index b7a3f4f6..8580fa40 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ requests>=2.28.1 safe-cli==0.7.0 safe-eth-py==5.5.0 slackclient==2.9.4 -web3==6.5.0 +web3>=6.20.0 SQLAlchemy<2.0.0 sqlalchemy-stubs==0.4 pandas==2.0.3 diff --git a/tests/e2e/test_post_transaction.py b/tests/e2e/test_post_transaction.py index 008c56c3..ebd09219 100644 --- a/tests/e2e/test_post_transaction.py +++ b/tests/e2e/test_post_transaction.py @@ -1,4 +1,3 @@ -import os import unittest from dune_client.types import Address @@ -9,6 +8,7 @@ from src.fetch.transfer_file import Transfer from src.models.token import Token from src.multisend import post_multisend +import pytest class TestTransactionPost(unittest.TestCase): @@ -18,11 +18,13 @@ def setUp(self) -> None: self.test_safe = "0xAb4178341C37e2307726361eEAE47FCA606cd458" self.cow = Token("0x3430d04E42a722c5Ae52C5Bffbf1F230C2677600", 18) self.receiver = Address("0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0") - self.client = EthereumClient( - URI(f"https://goerli.infura.io/v3/{os.environ.get('INFURA_KEY')}") - ) + self.client = EthereumClient(URI("https://rpc.ankr.com/eth_goerli")) - def test_token_decimals(self): + @pytest.mark.skip( + reason="Need to deploy a safe owned by the pk above on sepolia" + "Issue https://github.com/cowprotocol/solver-rewards/issues/387" + ) + def test_post_multisend(self): token_transfer = Transfer( token=self.cow, amount_wei=15, diff --git a/tests/e2e/test_token_details.py b/tests/e2e/test_token_details.py index a6ebfd9a..835b2acf 100644 --- a/tests/e2e/test_token_details.py +++ b/tests/e2e/test_token_details.py @@ -3,21 +3,19 @@ from dune_client.types import Address from web3 import Web3 -from src.constants import INFURA_KEY from src.utils.token_details import get_token_decimals -W3 = Web3(Web3.HTTPProvider(f"https://goerli.infura.io/v3/{INFURA_KEY}")) +W3 = Web3(Web3.HTTPProvider("https://rpc.ankr.com/eth_sepolia")) class TestTokenDecimals(unittest.TestCase): def test_token_decimals(self): - # Goerli doesn't seem to have tokens with anything other than 18 decimals. - cow = "0x3430d04E42a722c5Ae52C5Bffbf1F230C2677600" - self.assertEqual(get_token_decimals(W3, cow), 18) - self.assertEqual(get_token_decimals(W3, Address(cow)), 18) + usdc = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238" + self.assertEqual(get_token_decimals(W3, usdc), 6) + self.assertEqual(get_token_decimals(W3, Address(usdc)), 6) def test_token_decimals_cache(self): - new_token = "0x40c92339fd9c0f59d976af127e82de61914efd0f" + new_token = "0x0625afb445c3b6b7b929342a04a22599fd5dbb59" with self.assertLogs("src.utils.token_details", level="INFO"): get_token_decimals(W3, new_token) diff --git a/tests/unit/test_multisend.py b/tests/unit/test_multisend.py index 93cdfb19..2e84ed43 100644 --- a/tests/unit/test_multisend.py +++ b/tests/unit/test_multisend.py @@ -6,7 +6,7 @@ from web3 import Web3 from src.abis.load import weth9 -from src.constants import COW_TOKEN_ADDRESS, INFURA_KEY +from src.constants import COW_TOKEN_ADDRESS from src.fetch.transfer_file import Transfer from src.models.token import Token from src.multisend import build_encoded_multisend, prepend_unwrap_if_necessary @@ -14,7 +14,7 @@ class TestMultiSend(unittest.TestCase): def setUp(self) -> None: - node_url = f"https://mainnet.infura.io/v3/{INFURA_KEY}" + node_url = "https://rpc.ankr.com/eth" self.client = EthereumClient(URI(node_url)) def test_prepend_unwrap(self): @@ -58,7 +58,7 @@ def test_prepend_unwrap(self): hex_weth_balance = hex(weth_balance)[2:].rjust(64, "0") self.assertEqual( f"{unwrap_method_id}{hex_weth_balance}", - "0x" + unwrap.data.hex(), + unwrap.data.hex(), ) def test_multisend_encoding(self):