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

chore: migrate GPv2Signing recoverOrderFromTrade tests to Foundry #204

Merged
merged 16 commits into from
Aug 15, 2024

Conversation

fedgiac
Copy link
Contributor

@fedgiac fedgiac commented Aug 12, 2024

Description

See title.
This also introduces a small library to make it easier to create a test that uses fuzzed orders.
Fuzzed tests are used here because the exact bytes used in the tests are important, and fuzzing allows us to check if changing some bytes affects the test output. Previously, the sample order in the test was built by filling each byte with a nonzero value.

I also merged the tests "should round-trip encode order data" and "should compute order unique identifier" because it was just one line more in the first test, and now that we do fuzzing it's more efficient to do both in the same test rather than running independent fuzzes on both.

Here the signing and encoding libraries proved to be very nice to use!

Test Plan

CI.

Related Issues

#120

@fedgiac fedgiac requested a review from a team as a code owner August 12, 2024 15:19
Base automatically changed from migrate-test-signing-set-pre-signature to main August 15, 2024 09:07
Copy link
Contributor

@mfw78 mfw78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, with with some discussion on why OrderFuzz.sol outside of Order.sol in test libraries.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason why this is not part of the Order test library? If not, I'd be a fan of including this in the Order test library - thinking of the event that downstream consumers want to fuzz orders as well (such as some kind of testing for programmatic orders) - having this all in one library to retrieve would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be that the library was an abstract contract to be inherited by the test (I was experimenting with Foundry's fixtures) but I came to the conclusion it was better to keep it a simple library. Agreed that merging into Order makes sense.

@fedgiac fedgiac requested a review from mfw78 August 15, 2024 12:45
@fedgiac fedgiac merged commit 1d1628c into main Aug 15, 2024
9 checks passed
@fedgiac fedgiac deleted the migrate-test-signing-recover-order-from-trade branch August 15, 2024 13:48
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants