CI was crashing with intermittent errors. For example:
---- long::targeted::tests::test_calculate_targeted_long_with_budget stdout ----
thread 'long::targeted::tests::test_calculate_targeted_long_with_budget' panicked at crates/hyperdrive-math/src/long/targeted.rs:532:17:
The new_rate=0.065615470865036337 should be <= target_rate=0.040702128765527778 when budget constrained.
failures:
long::targeted::tests::test_calculate_targeted_long_with_budget
test result: FAILED. 33 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 520.83s
This particular error was caused by an incorrect sign. In that condition, we expected that the test undershot & should raise an error on the opposite condition (the else condition presumes that we undershot, which would be >= instead of <=).
I also added another check for an acceptable but unlikely (if not impossible in this test) failure condition where the target rate is too low, resulting in insolvency.
Review Checklists
Please check each item before approving the pull request. While going
through the checklist, it is recommended to leave comments on items that are
referenced in the checklist to make sure that they are reviewed. If there are
multiple reviewers, copy the checklists into sections titled ## [Reviewer Name].
If the PR doesn't touch Solidity and/or Rust, the corresponding checklist can
be removed.
Rust
[ ] Testing
[ ] Are there new or updated unit or integration tests?
[ ] Do the tests cover the happy paths?
[ ] Do the tests cover the unhappy paths?
[ ] Are there an adequate number of fuzz tests to ensure that we are
covering the full input space?
[ ] If matching Solidity behavior, are there differential fuzz tests that
ensure that Rust matches Solidity?
Resolved Issues
intermittent CI crashes; no issue created
Description
CI was crashing with intermittent errors. For example:
This particular error was caused by an incorrect sign. In that condition, we expected that the test undershot & should raise an error on the opposite condition (the else condition presumes that we undershot, which would be
>=
instead of<=
).I also added another check for an acceptable but unlikely (if not impossible in this test) failure condition where the target rate is too low, resulting in insolvency.
Review Checklists
Please check each item before approving the pull request. While going through the checklist, it is recommended to leave comments on items that are referenced in the checklist to make sure that they are reviewed. If there are multiple reviewers, copy the checklists into sections titled
## [Reviewer Name]
. If the PR doesn't touch Solidity and/or Rust, the corresponding checklist can be removed.Rust