Skip to content

Commit 8a2f478

Browse files
authored
Address Hypothesis test fails (#3665)
* Limit hypothesis integers in contract data and topic tests to a max_value of MAX_UINT_256 * Add newsfagment
1 parent cdd2afa commit 8a2f478

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

newsfragments/3665.internal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bound hypothesis integers in some tests to a max of uint256 value

tests/core/filtering/test_contract_data_filters.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import pytest_asyncio
1010

1111
from tests.core.filtering.utils import (
12+
MAX_UINT_256,
1213
_async_emitter_fixture_logic,
1314
_async_w3_fixture_logic,
1415
_emitter_fixture_logic,
@@ -39,14 +40,16 @@ def dynamic_values(draw):
3940

4041
@st.composite
4142
def fixed_values(draw):
42-
non_matching_1 = draw(st.integers(min_value=0))
43-
non_matching_2 = draw(st.integers(min_value=0))
44-
non_matching_3 = draw(st.integers(min_value=0))
45-
non_matching_4 = draw(st.integers(min_value=0))
43+
non_matching_1 = draw(st.integers(min_value=0, max_value=MAX_UINT_256))
44+
non_matching_2 = draw(st.integers(min_value=0, max_value=MAX_UINT_256))
45+
non_matching_3 = draw(st.integers(min_value=0, max_value=MAX_UINT_256))
46+
non_matching_4 = draw(st.integers(min_value=0, max_value=MAX_UINT_256))
4647
exclusions = (non_matching_1, non_matching_2, non_matching_3, non_matching_4)
4748
matching_values = draw(
4849
st.lists(
49-
elements=st.integers(min_value=0).filter(lambda x: x not in exclusions),
50+
elements=st.integers(min_value=0, max_value=MAX_UINT_256).filter(
51+
lambda x: x not in exclusions
52+
),
5053
min_size=4,
5154
max_size=4,
5255
)

tests/core/filtering/test_contract_topic_filters.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import pytest_asyncio
1010

1111
from tests.core.filtering.utils import (
12+
MAX_UINT_256,
1213
_async_emitter_fixture_logic,
1314
_async_w3_fixture_logic,
1415
_emitter_fixture_logic,
@@ -39,14 +40,16 @@ def dynamic_values(draw):
3940

4041
@st.composite
4142
def fixed_values(draw):
42-
non_matching_1 = draw(st.integers(min_value=0))
43-
non_matching_2 = draw(st.integers(min_value=0))
44-
non_matching_3 = draw(st.integers(min_value=0))
45-
non_matching_4 = draw(st.integers(min_value=0))
43+
non_matching_1 = draw(st.integers(min_value=0, max_value=MAX_UINT_256))
44+
non_matching_2 = draw(st.integers(min_value=0, max_value=MAX_UINT_256))
45+
non_matching_3 = draw(st.integers(min_value=0, max_value=MAX_UINT_256))
46+
non_matching_4 = draw(st.integers(min_value=0, max_value=MAX_UINT_256))
4647
exclusions = (non_matching_1, non_matching_2, non_matching_3, non_matching_4)
4748
matching_values = draw(
4849
st.lists(
49-
elements=st.integers(min_value=0).filter(lambda x: x not in exclusions),
50+
elements=st.integers(min_value=0, max_value=MAX_UINT_256).filter(
51+
lambda x: x not in exclusions
52+
),
5053
min_size=4,
5154
max_size=4,
5255
)

tests/core/filtering/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
EthereumTesterProvider,
1111
)
1212

13+
MAX_UINT_256 = 2**256 - 1
14+
1315

1416
def _w3_fixture_logic(request):
1517
use_filter_middleware = request.param

0 commit comments

Comments
 (0)