Skip to content

chore: do not rely on src libraries in test libraries #210

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

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

fedgiac
Copy link
Contributor

@fedgiac fedgiac commented Aug 15, 2024

Description

We define a broad set of library functions to make testing the contracts in src easier. However, these libraries themselves rely on the tested contracts. This could lead to issues when the tests pass because both the libraries and the files in src are broken in the same way. To guarantee that tests are independent of the tested libraries, all use of src libraries has been removed.

What I really wanted

Unfortunately, it's still possible that we forget about this and use some function in, e.g., GPv2Order in the test library, especially since we need to import this library to get related types and constants.

I tried to create a Solidity file that reexports everything we need from the libraries without the functions themselves (this would, for example, allow us to define a custom linting rule asserting that there's no import from src in any test file) but I was unsuccessful. It was very easy to reexport contracts (e.g., GPv2Settlement) and interfaces (e.g., IERC20), and it was also easy to reexport constants (e.g., GPv2Order.KIND_SELL), The issue was with reexporting type structs: to my understanding, this is impossible in Solidity ≤0.8.26, confirmed by the fact that there is no statement that appears to enable this use case in the language grammar.
Since neither reexporting everything but the structs nor reexporting the entire libraries make sense, I decided to keep everything as it is without further reexporting.

Test Plan

Nothing broken in CI.

@fedgiac fedgiac requested a review from a team as a code owner August 15, 2024 15:10
Base automatically changed from migrate-test-signing-cleanup to main August 15, 2024 16:06
@fedgiac fedgiac force-pushed the self-contained-test-libraries branch from fae8dd1 to 2ab252f Compare August 16, 2024 07:29
@fedgiac fedgiac merged commit 1ff7aef into main Sep 10, 2024
11 checks passed
@fedgiac fedgiac deleted the self-contained-test-libraries branch September 10, 2024 09:50
@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 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