Commit 1ff7aef
authored
chore: do not rely on src libraries in test libraries (#210)
## 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](https://docs.soliditylang.org/en/v0.8.26/grammar.html).
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.1 parent 5957d67 commit 1ff7aef
File tree
4 files changed
+36
-24
lines changed- test/libraries
- encoders
4 files changed
+36
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 6 | + | |
11 | 7 | | |
| 8 | + | |
12 | 9 | | |
13 | 10 | | |
14 | 11 | | |
| |||
134 | 131 | | |
135 | 132 | | |
136 | 133 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
141 | 152 | | |
142 | 153 | | |
143 | 154 | | |
| |||
146 | 157 | | |
147 | 158 | | |
148 | 159 | | |
149 | | - | |
| 160 | + | |
150 | 161 | | |
151 | 162 | | |
152 | 163 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
160 | 170 | | |
161 | 171 | | |
162 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
14 | | - | |
15 | 14 | | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| |||
0 commit comments