Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit0805cf2

Browse files
committed
fix: fixed broken tests, changed exceptions raised for invalid token addresses
1 parent798b061 commit0805cf2

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

‎tests/test_uniswap.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
fromtimeimportsleep
1010

1111
fromweb3importWeb3
12+
fromweb3.exceptionsimportNameNotFound
1213

1314
fromuniswapimportUniswap
1415
fromuniswap.constantsimportETH_ADDRESS
15-
fromuniswap.exceptionsimportInvalidToken,InsufficientBalance
16+
fromuniswap.exceptionsimportInsufficientBalance
1617
fromuniswap.utilimport_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
deftest_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
deftest_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
deftest_make_trade_output(

‎uniswap/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
fromtypingimportUnion,List,Tuple
55

66
fromweb3importWeb3
7+
fromweb3.exceptionsimportNameNotFound
78

89
from .typesimportAddressLike,Address,Contract
9-
from .exceptionsimportInvalidToken
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
ifs.startswith("0x"):
1616
returnAddress(bytes.fromhex(s[2:]))
1717
else:
18-
raiseException(f"Couldn't convert string '{s}' to AddressLike")
18+
raiseNameNotFound(f"Couldn't convert string '{s}' to AddressLike")
1919
else:
2020
returns
2121

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

32-
raiseInvalidToken(a)
32+
raiseNameNotFound(a)
3333

3434

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp