From 39963c84242d151dd1268e81871201da264c1f6c Mon Sep 17 00:00:00 2001 From: bout3fiddy <11488427+bout3fiddy@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:42:38 +0200 Subject: [PATCH] update limits in tests --- contracts/main/CurveCryptoMathOptimized2.vy | 1 + tests/unitary/math/test_get_y.py | 6 ++-- tests/unitary/math/test_newton_D.py | 6 ++-- tests/unitary/pool/test_exchange_received.py | 36 ++++++++++++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 tests/unitary/pool/test_exchange_received.py diff --git a/contracts/main/CurveCryptoMathOptimized2.vy b/contracts/main/CurveCryptoMathOptimized2.vy index dcb98c57..2b3b0b55 100644 --- a/contracts/main/CurveCryptoMathOptimized2.vy +++ b/contracts/main/CurveCryptoMathOptimized2.vy @@ -230,6 +230,7 @@ def get_y( ) -> uint256[2]: # Safety checks + print(_ANN, MIN_A, MAX_A) assert _ANN > MIN_A - 1 and _ANN < MAX_A + 1 # dev: unsafe values A assert _gamma > MIN_GAMMA - 1 and _gamma < MAX_GAMMA + 1 # dev: unsafe values gamma assert _D > 10**17 - 1 and _D < 10**15 * 10**18 + 1 # dev: unsafe values D diff --git a/tests/unitary/math/test_get_y.py b/tests/unitary/math/test_get_y.py index 9e935f5c..905ab2b0 100644 --- a/tests/unitary/math/test_get_y.py +++ b/tests/unitary/math/test_get_y.py @@ -9,9 +9,9 @@ N_COINS = 2 MAX_SAMPLES = 1000000 # Increase for fuzzing -A_MUL = 10000 * 2**2 -MIN_A = int(0.01 * A_MUL) -MAX_A = 1000 * A_MUL +A_MUL = 10000 +MIN_A = int(N_COINS**N_COINS * A_MUL / 10) +MAX_A = int(N_COINS**N_COINS * A_MUL * 100000) # gamma from 1e-8 up to 0.05 MIN_GAMMA = 10**10 diff --git a/tests/unitary/math/test_newton_D.py b/tests/unitary/math/test_newton_D.py index 26bf1973..d7f15c5e 100644 --- a/tests/unitary/math/test_newton_D.py +++ b/tests/unitary/math/test_newton_D.py @@ -40,9 +40,9 @@ def inv_target_decimal_n2(A, gamma, x, D): N_COINS = 2 MAX_SAMPLES = 3000000 # Increase for fuzzing -A_MUL = 10000 * 2**2 -MIN_A = int(0.01 * A_MUL) -MAX_A = 1000 * A_MUL +A_MUL = 10000 +MIN_A = int(N_COINS**N_COINS * A_MUL / 10) +MAX_A = int(N_COINS**N_COINS * A_MUL * 100000) # gamma from 1e-8 up to 0.05 MIN_GAMMA = 10**10 diff --git a/tests/unitary/pool/test_exchange_received.py b/tests/unitary/pool/test_exchange_received.py new file mode 100644 index 00000000..a1eda8dd --- /dev/null +++ b/tests/unitary/pool/test_exchange_received.py @@ -0,0 +1,36 @@ +import boa +from boa.test import strategy +from hypothesis import given, settings # noqa + +from tests.fixtures.pool import INITIAL_PRICES +from tests.utils.tokens import mint_for_testing + +SETTINGS = {"max_examples": 100, "deadline": None} + + +@given( + amount=strategy( + "uint256", min_value=10**10, max_value=10**6 * 10**18 + ), + split_in=strategy( + "uint256", min_value=0, max_value=100 + ), + split_out=strategy( + "uint256", min_value=0, max_value=100 + ), + i=strategy("uint", min_value=0, max_value=1), + j=strategy("uint", min_value=0, max_value=1), +) +@settings(**SETTINGS) +def test_exchange_split( + swap_with_deposit, + views_contract, + coins, + user, + amount, + split_in, + split_out, + i, + j +): + pass \ No newline at end of file