Skip to content

Commit 117ea26

Browse files
committed
Catch protocolVersion DeprecationWarnings
1 parent 799904e commit 117ea26

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

tests/core/version-module/test_version_module.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ async def test_async_blocking_version(async_w3, blocking_w3):
5353
assert async_w3.async_version.api == blocking_w3.api
5454

5555
assert await async_w3.async_version.node == blocking_w3.clientVersion
56-
assert await async_w3.async_version.ethereum == blocking_w3.eth.protocol_version
56+
with pytest.warns(DeprecationWarning):
57+
assert await async_w3.async_version.ethereum == blocking_w3.eth.protocol_version

web3/_utils/module_testing/eth_module.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@
6060

6161
class EthModuleTest:
6262
def test_eth_protocol_version(self, web3: "Web3") -> None:
63-
protocol_version = web3.eth.protocol_version
63+
with pytest.warns(DeprecationWarning,
64+
match="This method has been deprecated in some clients"):
65+
protocol_version = web3.eth.protocol_version
6466

6567
assert is_string(protocol_version)
6668
assert protocol_version.isdigit()
@@ -1558,7 +1560,9 @@ def test_eth_submit_hashrate(self, web3: "Web3") -> None:
15581560
def test_eth_submitHashrate_deprecated(self, web3: "Web3") -> None:
15591561
# node_id from EIP 1474: https://github.com/ethereum/EIPs/pull/1474/files
15601562
node_id = HexStr('59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c')
1561-
result = web3.eth.submitHashrate(5000, node_id)
1563+
with pytest.warns(DeprecationWarning,
1564+
match='submitHashrate is deprecated in favor of submit_hashrate'):
1565+
result = web3.eth.submitHashrate(5000, node_id)
15621566
assert result is True
15631567

15641568
def test_eth_submit_work(self, web3: "Web3") -> None:

web3/_utils/module_testing/version_module.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
class VersionModuleTest:
1515
def test_eth_protocol_version(self, web3: "Web3") -> None:
16-
protocol_version = web3.eth.protocol_version
16+
with pytest.warns(DeprecationWarning):
17+
protocol_version = web3.eth.protocol_version
1718

1819
assert is_string(protocol_version)
1920
assert protocol_version.isdigit()

0 commit comments

Comments
 (0)