Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzz segments in pro tests #256

Closed
PaulRBerg opened this issue Jan 7, 2023 · 1 comment · Fixed by #315
Closed

Fuzz segments in pro tests #256

PaulRBerg opened this issue Jan 7, 2023 · 1 comment · Fixed by #315
Assignees

Comments

@PaulRBerg
Copy link
Member

As explained here, fuzzing arrays is quite difficult in Solidity.

However, given our business logic, it would be extremely beneficial to have a suite of tests that fuzz the segments, testing different values for the amounts, milestones, and exponents.

The difficulty lies in the fact that our segments have special constraints - they can't be just any random sequence of data. Specifically, in the successful function execution paths, both of the following conditions must pass:

  1. The amounts must add up to the net deposit amount.
  2. The milestones must be ordered.

When I attempted to fuzz the arrays during the development of #220, I ended up giving up because I was getting too many test rejects, and also the test runs were unbearably slow (though I can't remember if that was, in part, caused by the activation of via IR).

Here's a GitHub Gist with quick sort algorithm I wrote back then, which might be handy when we pick this task up again:

https://gist.github.com/paulrberg/61e5a90434bd4bad31d9dbe9dd0c500e

@PaulRBerg
Copy link
Member Author

Update: it looks like Solady's LibSort.sol might be a good fit for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant