From ace8450f32ad0ed97931c9ef4f02ce355e21f7c5 Mon Sep 17 00:00:00 2001 From: kclowes Date: Thu, 17 Apr 2025 10:47:56 -0600 Subject: [PATCH 1/2] Limit hypothesis integers in contract data and topic tests to a max_value of MAX_UINT_256 --- tests/core/filtering/test_contract_data_filters.py | 13 ++++++++----- tests/core/filtering/test_contract_topic_filters.py | 13 ++++++++----- tests/core/filtering/utils.py | 2 ++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/core/filtering/test_contract_data_filters.py b/tests/core/filtering/test_contract_data_filters.py index d35457ca5e..0a95a56276 100644 --- a/tests/core/filtering/test_contract_data_filters.py +++ b/tests/core/filtering/test_contract_data_filters.py @@ -9,6 +9,7 @@ import pytest_asyncio from tests.core.filtering.utils import ( + MAX_UINT_256, _async_emitter_fixture_logic, _async_w3_fixture_logic, _emitter_fixture_logic, @@ -39,14 +40,16 @@ def dynamic_values(draw): @st.composite def fixed_values(draw): - non_matching_1 = draw(st.integers(min_value=0)) - non_matching_2 = draw(st.integers(min_value=0)) - non_matching_3 = draw(st.integers(min_value=0)) - non_matching_4 = draw(st.integers(min_value=0)) + non_matching_1 = draw(st.integers(min_value=0, max_value=MAX_UINT_256)) + non_matching_2 = draw(st.integers(min_value=0, max_value=MAX_UINT_256)) + non_matching_3 = draw(st.integers(min_value=0, max_value=MAX_UINT_256)) + non_matching_4 = draw(st.integers(min_value=0, max_value=MAX_UINT_256)) exclusions = (non_matching_1, non_matching_2, non_matching_3, non_matching_4) matching_values = draw( st.lists( - elements=st.integers(min_value=0).filter(lambda x: x not in exclusions), + elements=st.integers(min_value=0, max_value=MAX_UINT_256).filter( + lambda x: x not in exclusions + ), min_size=4, max_size=4, ) diff --git a/tests/core/filtering/test_contract_topic_filters.py b/tests/core/filtering/test_contract_topic_filters.py index 6ba4673520..2f16750b9f 100644 --- a/tests/core/filtering/test_contract_topic_filters.py +++ b/tests/core/filtering/test_contract_topic_filters.py @@ -9,6 +9,7 @@ import pytest_asyncio from tests.core.filtering.utils import ( + MAX_UINT_256, _async_emitter_fixture_logic, _async_w3_fixture_logic, _emitter_fixture_logic, @@ -39,14 +40,16 @@ def dynamic_values(draw): @st.composite def fixed_values(draw): - non_matching_1 = draw(st.integers(min_value=0)) - non_matching_2 = draw(st.integers(min_value=0)) - non_matching_3 = draw(st.integers(min_value=0)) - non_matching_4 = draw(st.integers(min_value=0)) + non_matching_1 = draw(st.integers(min_value=0, max_value=MAX_UINT_256)) + non_matching_2 = draw(st.integers(min_value=0, max_value=MAX_UINT_256)) + non_matching_3 = draw(st.integers(min_value=0, max_value=MAX_UINT_256)) + non_matching_4 = draw(st.integers(min_value=0, max_value=MAX_UINT_256)) exclusions = (non_matching_1, non_matching_2, non_matching_3, non_matching_4) matching_values = draw( st.lists( - elements=st.integers(min_value=0).filter(lambda x: x not in exclusions), + elements=st.integers(min_value=0, max_value=MAX_UINT_256).filter( + lambda x: x not in exclusions + ), min_size=4, max_size=4, ) diff --git a/tests/core/filtering/utils.py b/tests/core/filtering/utils.py index 714505966a..60cd8d46a8 100644 --- a/tests/core/filtering/utils.py +++ b/tests/core/filtering/utils.py @@ -14,6 +14,8 @@ EthereumTesterProvider, ) +MAX_UINT_256 = 2**256 - 1 + def _w3_fixture_logic(request): use_filter_middleware = request.param From 0f6ecddcd671ee45760a6209281956eb4a24b20a Mon Sep 17 00:00:00 2001 From: kclowes Date: Thu, 17 Apr 2025 11:52:28 -0600 Subject: [PATCH 2/2] Add newsfragment --- newsfragments/3666.internal.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/3666.internal.rst diff --git a/newsfragments/3666.internal.rst b/newsfragments/3666.internal.rst new file mode 100644 index 0000000000..72280daa69 --- /dev/null +++ b/newsfragments/3666.internal.rst @@ -0,0 +1 @@ +Fix test failures on v6 from hypothesis upgrade