Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0805cf2

Browse filesBrowse files
committed
fix: fixed broken tests, changed exceptions raised for invalid token addresses
1 parent 798b061 commit 0805cf2
Copy full SHA for 0805cf2

File tree

Expand file treeCollapse file tree

2 files changed

+8
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-7
lines changed

‎tests/test_uniswap.py

Copy file name to clipboardExpand all lines: tests/test_uniswap.py
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
from time import sleep
1010

1111
from web3 import Web3
12+
from web3.exceptions import NameNotFound
1213

1314
from uniswap import Uniswap
1415
from uniswap.constants import ETH_ADDRESS
15-
from uniswap.exceptions import InvalidToken, InsufficientBalance
16+
from uniswap.exceptions import InsufficientBalance
1617
from uniswap.util import _str_to_addr
1718

1819

@@ -227,7 +228,7 @@ def test_add_liquidity(self, client: Uniswap, web3: Web3, token, max_eth):
227228
[
228229
(bat, 0.00001 * ONE_ETH, does_not_raise()),
229230
(dai, 0.00001 * ONE_ETH, does_not_raise()),
230-
("btc", ONE_ETH, pytest.raises(InvalidToken)),
231+
("btc", ONE_ETH, pytest.raises(NameNotFound)),
231232
],
232233
)
233234
def test_remove_liquidity(
@@ -251,7 +252,7 @@ def test_remove_liquidity(
251252
# (eth, bat, 0.00001 * ONE_ETH, ZERO_ADDRESS, does_not_raise),
252253
# (bat, eth, 0.00001 * ONE_ETH, ZERO_ADDRESS, does_not_raise),
253254
# (dai, bat, 0.00001 * ONE_ETH, ZERO_ADDRESS, does_not_raise),
254-
(dai, "btc", ONE_ETH, None, lambda: pytest.raises(InvalidToken)),
255+
(dai, "btc", ONE_ETH, None, lambda: pytest.raises(NameNotFound)),
255256
],
256257
)
257258
def test_make_trade(
@@ -301,7 +302,7 @@ def test_make_trade(
301302
None,
302303
lambda: pytest.raises(InsufficientBalance),
303304
),
304-
(dai, "btc", ONE_ETH, None, lambda: pytest.raises(InvalidToken)),
305+
(dai, "btc", ONE_ETH, None, lambda: pytest.raises(NameNotFound)),
305306
],
306307
)
307308
def test_make_trade_output(

‎uniswap/util.py

Copy file name to clipboardExpand all lines: uniswap/util.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from typing import Union, List, Tuple
55

66
from web3 import Web3
7+
from web3.exceptions import NameNotFound
78

89
from .types import AddressLike, Address, Contract
9-
from .exceptions import InvalidToken
1010

1111

1212
def _str_to_addr(s: Union[AddressLike, str]) -> Address:
@@ -15,7 +15,7 @@ def _str_to_addr(s: Union[AddressLike, str]) -> Address:
1515
if s.startswith("0x"):
1616
return Address(bytes.fromhex(s[2:]))
1717
else:
18-
raise Exception(f"Couldn't convert string '{s}' to AddressLike")
18+
raise NameNotFound(f"Couldn't convert string '{s}' to AddressLike")
1919
else:
2020
return s
2121

@@ -29,7 +29,7 @@ def _addr_to_str(a: AddressLike) -> str:
2929
addr = Web3.toChecksumAddress(a)
3030
return addr
3131

32-
raise InvalidToken(a)
32+
raise NameNotFound(a)
3333

3434

3535
def is_same_address(a1: Union[AddressLike, str], a2: Union[AddressLike, str]) -> bool:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.