Skip to content

Commit

Permalink
Fix test cases logging format.
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipp committed Oct 21, 2023
1 parent bff84a3 commit b34a477
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tests/unitary/math/test_get_y.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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)

0 comments on commit b34a477

Please sign in to comment.