From b47b839a9973caf5bc5cfb13400bfdc1452176d1 Mon Sep 17 00:00:00 2001 From: enitrat Date: Thu, 13 Feb 2025 13:31:31 +0000 Subject: [PATCH] make program with cairo_program fixture quiet --- cairo/tests/ethereum/cancun/test_trie.py | 4 +++- .../cancun/vm/precompiled_contracts/test_mapping.py | 4 +++- cairo/tests/legacy/utils/test_bytes_legacy.py | 5 ++++- .../cairo-core/tests/src/cairo_core/test_maths.py | 6 +++++- python/cairo-ec/tests/circuits/test_circuits.py | 13 ++++++++++++- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/cairo/tests/ethereum/cancun/test_trie.py b/cairo/tests/ethereum/cancun/test_trie.py index 6f333868a..5d6194a51 100644 --- a/cairo/tests/ethereum/cancun/test_trie.py +++ b/cairo/tests/ethereum/cancun/test_trie.py @@ -27,7 +27,7 @@ ) from ethereum_types.bytes import Bytes, Bytes32 from ethereum_types.numeric import U256, Uint -from hypothesis import example, given +from hypothesis import Verbosity, example, given, settings from hypothesis import strategies as st from cairo_addons.testing.errors import cairo_error, strict_raises @@ -79,6 +79,7 @@ def test_common_prefix_length(self, cairo_run, a: Bytes, b: Bytes): assert common_prefix_length(a, b) == cairo_run("common_prefix_length", a, b) @given(a=..., b=...) + @settings(verbosity=Verbosity.quiet) def test_common_prefix_length_should_fail( self, cairo_programs, cairo_run_py, a: Bytes, b: Bytes ): @@ -101,6 +102,7 @@ def test_nibble_list_to_compact(self, cairo_run, x, is_leaf: bool): ) @given(x=nibble.filter(lambda x: len(x) != 0), is_leaf=...) + @settings(verbosity=Verbosity.quiet) def test_nibble_list_to_compact_should_raise_when_wrong_remainder( self, cairo_programs, cairo_run_py, x, is_leaf: bool ): diff --git a/cairo/tests/ethereum/cancun/vm/precompiled_contracts/test_mapping.py b/cairo/tests/ethereum/cancun/vm/precompiled_contracts/test_mapping.py index 78dc2f3af..81048ddc4 100644 --- a/cairo/tests/ethereum/cancun/vm/precompiled_contracts/test_mapping.py +++ b/cairo/tests/ethereum/cancun/vm/precompiled_contracts/test_mapping.py @@ -2,7 +2,7 @@ ECRECOVER_ADDRESS, PRE_COMPILED_CONTRACTS, ) -from hypothesis import example, given +from hypothesis import Verbosity, example, given, settings from hypothesis import strategies as st from cairo_addons.testing.errors import cairo_error @@ -27,6 +27,7 @@ def test_precompile_table_lookup_invalid_addresses(self, cairo_run, address_int) assert table_address == 0 @given(address=st.sampled_from(list(PRE_COMPILED_CONTRACTS.keys()))) + @settings(verbosity=Verbosity.quiet) def test_precompile_table_lookup_hint_index_out_of_bounds( self, cairo_programs, cairo_run_py, address ): @@ -42,6 +43,7 @@ def test_precompile_table_lookup_hint_index_out_of_bounds( cairo_run_py("precompile_table_lookup", address_int) @given(address=st.sampled_from(list(PRE_COMPILED_CONTRACTS.keys()))) + @settings(verbosity=Verbosity.quiet) def test_precompile_table_lookup_hint_index_different_address( self, cairo_programs, cairo_run_py, address ): diff --git a/cairo/tests/legacy/utils/test_bytes_legacy.py b/cairo/tests/legacy/utils/test_bytes_legacy.py index 609c12255..3c71312ce 100644 --- a/cairo/tests/legacy/utils/test_bytes_legacy.py +++ b/cairo/tests/legacy/utils/test_bytes_legacy.py @@ -1,5 +1,5 @@ import pytest -from hypothesis import given +from hypothesis import Verbosity, given, settings from hypothesis.strategies import binary, integers from starkware.cairo.lang.cairo_constants import DEFAULT_PRIME @@ -39,6 +39,7 @@ def test_should_raise_when_value_sup_31_bytes(self, cairo_run, n): # This test checks the function fails if the % base is removed from the hint # All values up to 256 will have the same decomposition if the it is removed @given(n=integers(min_value=256, max_value=2**248 - 1)) + @settings(verbosity=Verbosity.quiet) def test_should_raise_when_byte_value_not_modulo_base( self, cairo_programs, cairo_run, n ): @@ -63,6 +64,7 @@ def test_should_raise_when_byte_value_not_modulo_base( != 0 ) ) + @settings(verbosity=Verbosity.quiet) def test_should_raise_when_bytes_len_is_not_minimal( self, cairo_programs, cairo_run, n ): @@ -76,6 +78,7 @@ def test_should_raise_when_bytes_len_is_not_minimal( ): cairo_run("test__felt_to_bytes_little", n=n) + @settings(verbosity=Verbosity.quiet) def test_should_raise_when_bytes_len_is_greater_than_31( self, cairo_programs, cairo_run ): diff --git a/python/cairo-core/tests/src/cairo_core/test_maths.py b/python/cairo-core/tests/src/cairo_core/test_maths.py index c0b18c228..0b0dd8de8 100644 --- a/python/cairo-core/tests/src/cairo_core/test_maths.py +++ b/python/cairo-core/tests/src/cairo_core/test_maths.py @@ -1,5 +1,5 @@ import pytest -from hypothesis import assume, given, settings +from hypothesis import Verbosity, assume, given, settings from hypothesis import strategies as st from starkware.cairo.lang.cairo_constants import DEFAULT_PRIME @@ -81,6 +81,7 @@ def test_felt252_to_bytes_le_should_panic_on_len_too_big( value=st.integers(min_value=1, max_value=2**248 - 1), len_=st.integers(min_value=1, max_value=31), ) + @settings(verbosity=Verbosity.quiet) def test_felt252_to_bytes_le_should_panic_on_wrong_output( self, cairo_programs, cairo_run, value, len_ ): @@ -95,6 +96,7 @@ def test_felt252_to_bytes_le_should_panic_on_wrong_output( ), cairo_error(message="felt252_to_bytes_le: bad output"): cairo_run("test__felt252_to_bytes_le", value=value, len=len_) + @settings(verbosity=Verbosity.quiet) def test_felt252_to_bytes_le_should_panic_on_wrong_output_noncanonical( self, cairo_programs, cairo_run ): @@ -148,6 +150,7 @@ def test_felt252_to_bytes_be_should_panic_on_len_too_big( value=st.integers(min_value=1, max_value=2**248 - 1), len_=st.integers(min_value=1, max_value=31), ) + @settings(verbosity=Verbosity.quiet) def test_felt252_to_bytes_be_should_panic_on_wrong_output( self, cairo_programs, cairo_run, value, len_ ): @@ -162,6 +165,7 @@ def test_felt252_to_bytes_be_should_panic_on_wrong_output( ), cairo_error(message="felt252_to_bytes_be: bad output"): cairo_run("test__felt252_to_bytes_be", value=value, len=len_) + @settings(verbosity=Verbosity.quiet) def test_felt252_to_bytes_be_should_panic_on_wrong_output_noncanonical( self, cairo_programs, cairo_run ): diff --git a/python/cairo-ec/tests/circuits/test_circuits.py b/python/cairo-ec/tests/circuits/test_circuits.py index 3175b740a..c35c3e995 100644 --- a/python/cairo-ec/tests/circuits/test_circuits.py +++ b/python/cairo-ec/tests/circuits/test_circuits.py @@ -2,7 +2,7 @@ import pytest from ethereum.crypto.finite_field import PrimeField -from hypothesis import assume, given +from hypothesis import Verbosity, assume, given, settings from hypothesis import strategies as st from sympy import sqrt_mod from sympy.core.numbers import mod_inverse @@ -49,6 +49,7 @@ class Curve(ECBase): class TestCircuits: class TestModOps: @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_add(self, cairo_program, cairo_run, prime_cls, st_prime, data): inputs = {"x": data.draw(st_prime), "y": data.draw(st_prime)} values_ptr = [limb for v in inputs.values() for limb in int_to_uint384(v)] @@ -84,6 +85,7 @@ def test_add(self, cairo_program, cairo_run, prime_cls, st_prime, data): ) @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_sub(self, cairo_program, cairo_run, prime_cls, st_prime, data): inputs = {"x": data.draw(st_prime), "y": data.draw(st_prime)} values_ptr = [limb for v in inputs.values() for limb in int_to_uint384(v)] @@ -119,6 +121,7 @@ def test_sub(self, cairo_program, cairo_run, prime_cls, st_prime, data): ) @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_mul(self, cairo_program, cairo_run, prime_cls, st_prime, data): inputs = {"x": data.draw(st_prime), "y": data.draw(st_prime)} values_ptr = [limb for v in inputs.values() for limb in int_to_uint384(v)] @@ -154,6 +157,7 @@ def test_mul(self, cairo_program, cairo_run, prime_cls, st_prime, data): ) @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_div(self, cairo_program, cairo_run, prime, data, prime_cls): inputs = { "x": data.draw(st.integers(min_value=0, max_value=prime - 1)), @@ -194,6 +198,7 @@ def test_div(self, cairo_program, cairo_run, prime, data, prime_cls): ) @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_diff_ratio(self, cairo_program, cairo_run, prime_cls, st_prime, data): inputs = {"x": data.draw(st_prime), "y": data.draw(st_prime)} assume(inputs["x"] != inputs["y"]) @@ -233,6 +238,7 @@ def test_diff_ratio(self, cairo_program, cairo_run, prime_cls, st_prime, data): ) @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_sum_ratio(self, cairo_program, cairo_run, prime_cls, st_prime, data): inputs = {"x": data.draw(st_prime), "y": data.draw(st_prime)} assume(inputs["x"] != -inputs["y"]) @@ -272,6 +278,7 @@ def test_sum_ratio(self, cairo_program, cairo_run, prime_cls, st_prime, data): ) @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_inv(self, cairo_program, cairo_run, prime, data, prime_cls): inputs = { "x": data.draw(st.integers(min_value=1, max_value=prime - 1)), @@ -312,6 +319,7 @@ def test_inv(self, cairo_program, cairo_run, prime, data, prime_cls): ) @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_assert_is_quad_residue( self, cairo_program, cairo_run, curve, data, st_prime ): @@ -346,6 +354,7 @@ def test_assert_is_quad_residue( class TestEcOps: @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_ec_add(self, cairo_program, cairo_run, curve, data, st_prime): seed_p = data.draw(st_prime) seed_q = data.draw(st_prime) @@ -388,6 +397,7 @@ def test_ec_add(self, cairo_program, cairo_run, curve, data, st_prime): ) @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_ec_double(self, cairo_program, cairo_run, curve, data, st_prime): seed_p = data.draw(st_prime) p = curve.random_point(x=seed_p) @@ -427,6 +437,7 @@ def test_ec_double(self, cairo_program, cairo_run, curve, data, st_prime): ) @given(data=st.data()) + @settings(verbosity=Verbosity.quiet) def test_assert_is_on_curve( self, cairo_program, cairo_run, curve, data, st_prime ):