Skip to content

Commit

Permalink
docs: documenting changes in math tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoCentonze committed Apr 15, 2024
1 parent f3c21ab commit befac25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions tests/unitary/math/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@
```
math
├── conftest.py - "Fixtures for new and old math contracts."
├── fuzz_multicoin_curve.py
├── misc.py
├── test_cbrt.py
├── test_exp.py
├── test_get_p.py
├── test_get_y.py
├── test_log2.py
├── test_multicoin_curve.py - "Tests for a minimal reference implementation in python"
├── test_newton_D.py
├── test_newton_D_ref.py
├── test_newton_y.py
├── test_newton_y.py - "Verify that newton_y always convergees to the correct values quickly enough"
└── test_packing.py - "Testing unpacking for (2, 3)-tuples"
```

### Fuzzing parallelization
Due to the nature of the math involved in curve pools (i.e. analytical solutions for equations not always availble), we often require on approximation methods to solve these equations numerically. Testing this requires extensive fuzzing which can be very time consuming sometimes. Hypothesis does not support test parallelisation and this is why in the code you might often see test parametrisation as a hacky way to obtain parallel fuzzing:
Due to the nature of the math involved in curve pools (i.e. analytical solutions for equations not always availble), we often require approximation methods to solve these equations numerically. Testing this requires extensive fuzzing which can be very time consuming sometimes. Hypothesis does not support test parallelisation and this is why in the code we use test parametrisation as a hacky way to obtain parallel fuzzing with `xdist`:

```python
@pytest.mark.parametrize(
"_tmp", range(N_CASES)
) # Parallelisation hack (more details in folder's README)
```

### Checklist when modifying functions using on Newton's method
- The number of iterations required to converge should not increase significantly
- Make sure values converge to the correct value (some initial guesses might lead to wrong results)
2 changes: 1 addition & 1 deletion tests/unitary/math/test_newton_D.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def inv_target_decimal_n2(A, gamma, x, D):

@pytest.mark.parametrize(
"_tmp", range(N_CASES)
) # Create N_CASES independent test instances.
) # Parallelisation hack (more details in folder's README)
@given(
A=st.integers(min_value=MIN_A, max_value=MAX_A),
D=st.integers(
Expand Down

0 comments on commit befac25

Please sign in to comment.