Skip to content

Commit 6228420

Browse files
committed
changed ValueError -> ValidationError and updated corresponding test
1 parent 89d8503 commit 6228420

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tests/core/eth-module/test_poa.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import pytest
22

3+
from web3.exceptions import (
4+
ValidationError,
5+
)
36
from web3.middleware import (
47
construct_fixture_middleware,
58
geth_poa_middleware,
@@ -12,7 +15,7 @@ def test_long_extra_data(web3):
1215
'eth_getBlockByNumber': {'extraData': '0x' + 'ff' * 33},
1316
})
1417
web3.middleware_stack.inject(return_block_with_long_extra_data, layer=0)
15-
with pytest.raises(ValueError):
18+
with pytest.raises(ValidationError):
1619
web3.eth.getBlock('latest')
1720

1821

web3/middleware/pythonic.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
HexBytes,
2929
)
3030

31+
from web3.exceptions import (
32+
ValidationError,
33+
)
3134
from web3.utils.encoding import (
3235
hexstr_if_str,
3336
to_hex,
@@ -70,7 +73,7 @@ def check_extradata_length(val, length):
7073
return val
7174
result = HexBytes(val)
7275
if len(result) > length:
73-
raise ValueError(
76+
raise ValidationError(
7477
"The field extraData: %r is %d bytes, but should be %d. "
7578
"It is quite likely that you are connected to a POA chain. "
7679
"Refer "

0 commit comments

Comments
 (0)