Skip to content

Commit

Permalink
fix tests by updating web3 (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith authored Aug 16, 2024
1 parent a8139b1 commit dafa2db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions tests/e2e/test_post_transaction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import unittest

from dune_client.types import Address
Expand All @@ -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):
Expand All @@ -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,
Expand Down
12 changes: 5 additions & 7 deletions tests/e2e/test_token_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_multisend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
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


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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit dafa2db

Please sign in to comment.