-
Notifications
You must be signed in to change notification settings - Fork 48
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
Test the code identity between the Lockup contracts #771
Comments
Given how our test structure is designed ( We are running the same tests for these functions: I believe this test would be helpful only if we want to check if the comments are identical, thus we should lower the priority. Regarding the test method, using forge seems to be an overkill. Adding a Bash script in the |
Yes, performing these code identity checks would still be helpful even if we run the same tests for these contracts.
Fair enough |
@PaulRBerg since we implemented #813 should we close this issue? |
Not sure. Isn't there duplicated code still? If there is, we should keep this issue open (though revise the description in light of the new spec). |
Just these lines, but I don't think they count Linear: v2-core/src/SablierV2LockupLinear.sol Lines 238 to 244 in aabd935
Dynamic: v2-core/src/SablierV2LockupDynamic.sol Lines 319 to 325 in aabd935
Everything else is completely different |
Yeah, they don't count, especially since we might end up removing protocol fees. |
Problem
Because Solidity does not have anything equivalent to Rust traits, we are forced to duplicate any logic that touches upon different structs despite the logic being completely identical.
_cancel
_renounce
_withdraw
Technically speaking, there is a way out, but it's ugly and not worth it. We could implement a setter for every struct field (e.g.,
setIsCancelable
,setWasCanceled
, etc.), but:Solution
Introduce a new class of tests, i.e. differential tests, that perform the following checks:
LockupLinear
and theLockupDynamic
contracts (and potentiallyLockupTranched
in the future)_cancel
and the_withdraw
functions. They should be 100% identical, down to the English comments.awk
utility might be helpful hereThe tests would use Bash scripting and the
ffi
cheat code to read the file contents.Alternatively, if implementing this in Forge is too complicated, we can write a CI check. There should be GitHub Actions for performing diffs between files.
References
The text was updated successfully, but these errors were encountered: