|
7 | 7 | Web3, |
8 | 8 | ) |
9 | 9 | from web3.exceptions import ( |
10 | | - InvalidAddress, |
| 10 | + NameNotFound, |
11 | 11 | ) |
12 | | -from web3.middleware import ( # noqa: F401 |
13 | | - construct_fixture_middleware, |
| 12 | +from web3.middleware import ( |
14 | 13 | name_to_address_middleware, |
15 | 14 | ) |
16 | | -from web3.middleware.names import async_name_to_address_middleware |
| 15 | +from web3.middleware.names import ( |
| 16 | + async_name_to_address_middleware, |
| 17 | +) |
17 | 18 | from web3.providers.eth_tester import ( |
18 | 19 | AsyncEthereumTesterProvider, |
19 | 20 | EthereumTesterProvider, |
@@ -49,24 +50,12 @@ def w3(_w3_setup, ens_mapped_address): |
49 | 50 |
|
50 | 51 |
|
51 | 52 | def test_pass_name_resolver(w3, ens_mapped_address): |
52 | | - return_chain_on_mainnet = construct_fixture_middleware( |
53 | | - { |
54 | | - "net_version": "1", |
55 | | - } |
56 | | - ) |
57 | 53 | known_account_balance = w3.eth.get_balance(ens_mapped_address) |
58 | | - w3.middleware_onion.inject(return_chain_on_mainnet, layer=0) |
59 | 54 | assert w3.eth.get_balance(NAME) == known_account_balance |
60 | 55 |
|
61 | 56 |
|
62 | 57 | def test_fail_name_resolver(w3): |
63 | | - return_chain_on_mainnet = construct_fixture_middleware( |
64 | | - { |
65 | | - "net_version": "2", |
66 | | - } |
67 | | - ) |
68 | | - w3.middleware_onion.inject(return_chain_on_mainnet, layer=0) |
69 | | - with pytest.raises(InvalidAddress, match=r".*ethereum\.eth.*"): |
| 58 | + with pytest.raises(NameNotFound, match=r".*ethereum\.eth.*"): |
70 | 59 | w3.eth.get_balance("ethereum.eth") |
71 | 60 |
|
72 | 61 |
|
@@ -104,5 +93,5 @@ async def test_async_pass_name_resolver(async_w3, async_ens_mapped_address): |
104 | 93 |
|
105 | 94 | @pytest.mark.asyncio |
106 | 95 | async def test_async_fail_name_resolver(async_w3): |
107 | | - with pytest.raises(InvalidAddress, match=r".*ethereum\.eth.*"): |
| 96 | + with pytest.raises(NameNotFound, match=r".*ethereum\.eth.*"): |
108 | 97 | await async_w3.eth.get_balance("ethereum.eth") |
0 commit comments