diff --git a/tests/unitary/math/test_get_y.py b/tests/unitary/math/test_get_y.py index 6a9506c4..0e4ee3b8 100644 --- a/tests/unitary/math/test_get_y.py +++ b/tests/unitary/math/test_get_y.py @@ -1,7 +1,6 @@ # flake8: noqa import time from decimal import Decimal - import pytest from hypothesis import given, note, settings from hypothesis import strategies as st @@ -68,7 +67,7 @@ def test_get_y(math_unoptimized, math_optimized, A, D, xD, yD, gamma, j): A_dec = Decimal(A) / 10000 / 4 - print( + case = ( "{" f"'ANN': {A}, 'GAMMA': {gamma}, 'x': {X}, 'D': {D}, 'index': {j}" "}\n" @@ -82,9 +81,15 @@ def calculate_F_by_y0(y0): result_original = math_unoptimized.newton_y(A, gamma, X, D, j) pytest.gas_original += math_unoptimized._computation.get_gas_used() - result_get_y, K0 = math_optimized.get_y(A, gamma, X, D, j) - pytest.gas_new += math_optimized._computation.get_gas_used() - + try: + result_get_y, K0 = math_optimized.get_y(A, gamma, X, D, j) + pytest.gas_new += math_optimized._computation.get_gas_used() + except Exception as e: + with open("log/get_y_fail.txt", "a") as f: + f.write(case) + with open("log/get_y_fail_trace.txt", "a") as f: + f.write(f'{pytest.current_case_id}:\n{e}\n\n') + return if K0 == 0: pytest.negative_sqrt_arg += 1 @@ -101,3 +106,7 @@ def calculate_F_by_y0(y0): ) or abs(calculate_F_by_y0(result_get_y)) <= abs( calculate_F_by_y0(result_original) ) + + with open("log/get_y_pass.txt", "a") as f: + f.write(case) +