Skip to content

Commit

Permalink
Few fixes to get_y() test
Browse files Browse the repository at this point in the history
  • Loading branch information
michwill committed Apr 9, 2024
1 parent 1aa0652 commit 6dec22f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/unitary/math/test_get_y.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,27 @@ def calculate_F_by_y0(y0):
assert not "gamma" in str(e)
assert gamma > 2 * 10**16
return
else: # Did not converge?
raise
pytest.gas_original += math_unoptimized._computation.get_gas_used()

result_get_y, K0 = math_optimized.get_y(A, gamma, X, D, j)
try:
result_get_y, K0 = math_optimized.get_y(A, gamma, X, D, j)
except Exception as e:
if "unsafe value" in str(e):
# The only possibility for old one to not revert and new one to revert is to have
# very small difference near the unsafe y value boundary.
# So, here we check if it was indeed small
lim_mul = 100 * 10**18
if gamma > 2 * 10**16:
lim_mul = lim_mul * 2 * 10**16 // gamma
frac = result_original * 10**18 // D
if abs(frac - 10**36 // 2 // lim_mul) < 100 or abs(frac - lim_mul // 2) < 100:
return
else:
raise
else:
raise
pytest.gas_new += math_optimized._computation.get_gas_used()

note(
Expand Down

0 comments on commit 6dec22f

Please sign in to comment.