File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 1+ Fix bug in geth PoA middleware where a ``None `` response should throw a ``BlockNotFound `` error, but was instead throwing an ``AttributeError ``
Original file line number Diff line number Diff line change 11import pytest
22
33from web3 .exceptions import (
4+ BlockNotFound ,
45 ExtraDataLengthError ,
56)
67from web3 .middleware import (
@@ -37,3 +38,13 @@ def test_geth_proof_of_authority(web3):
3738 block = web3 .eth .get_block ('latest' )
3839 assert 'extraData' not in block
3940 assert block .proofOfAuthorityData == b'\xff ' * 33
41+
42+
43+ def test_returns_none_response (web3 ):
44+ return_none_response = construct_fixture_middleware ({
45+ 'eth_getBlockByNumber' : None ,
46+ })
47+ web3 .middleware_onion .inject (geth_poa_middleware , layer = 0 )
48+ web3 .middleware_onion .inject (return_none_response , layer = 0 )
49+ with pytest .raises (BlockNotFound ):
50+ web3 .eth .get_block (100000000000 )
Original file line number Diff line number Diff line change 11from eth_utils .curried import (
2+ apply_formatter_if ,
23 apply_formatters_to_dict ,
34 apply_key_map ,
5+ is_null ,
46)
57from eth_utils .toolz import (
8+ complement ,
69 compose ,
710)
811from hexbytes import (
912 HexBytes ,
1013)
1114
15+ from web3 ._utils .rpc_abi import (
16+ RPC ,
17+ )
1218from web3 .middleware .formatting import (
1319 construct_formatting_middleware ,
1420)
15- from web3 .types import (
16- RPCEndpoint ,
17- )
21+
22+ is_not_null = complement (is_null )
1823
1924remap_geth_poa_fields = apply_key_map ({
2025 'extraData' : 'proofOfAuthorityData' ,
2833
2934geth_poa_middleware = construct_formatting_middleware (
3035 result_formatters = {
31- RPCEndpoint ( " eth_getBlockByHash" ): geth_poa_cleanup ,
32- RPCEndpoint ( " eth_getBlockByNumber" ): geth_poa_cleanup ,
36+ RPC . eth_getBlockByHash : apply_formatter_if ( is_not_null , geth_poa_cleanup ) ,
37+ RPC . eth_getBlockByNumber : apply_formatter_if ( is_not_null , geth_poa_cleanup ) ,
3338 },
3439)
You can’t perform that action at this time.
0 commit comments