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

Modifiers for each testing branch (plus other enhancements) #90

Merged
merged 18 commits into from
Jul 19, 2022

Conversation

PaulRBerg
Copy link
Member

@PaulRBerg PaulRBerg commented Jun 26, 2022

Changelog:

  • Implement Modifiers for each testing branch #77 using the V4 method agreed upon in discussion #91
  • Remove the UnitTest descriptor from each contract name (the contract names have become quite long)
  • Rename the streamId variable to daiStreamId to make it clear that we're referring to a $DAI stream

Copy link
Member

@andreivladbrg andreivladbrg left a comment

Choose a reason for hiding this comment

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

We are going to use V4 #91 (comment).

@PaulRBerg
Copy link
Member Author

PaulRBerg commented Jul 19, 2022

In commits 50844c0 and a62326f, you have re-added the UnitTest descriptor in each testing contract name. Haven't you seen the changelog in my original comment? I have purposefully removed UnitTest.

@PaulRBerg
Copy link
Member Author

In commit test: change test functions name, you have bumped solidity to v0.8.15, which is quite an important change. It should have been the first message, listed at the top.

@PaulRBerg PaulRBerg force-pushed the test/enhancements branch from 9945116 to 4ab571d Compare July 19, 2022 08:50
PaulRBerg and others added 7 commits July 19, 2022 11:52
chore: improve wording in comments
chore: disable "no-empty-blocks" solhint rule
test: refactor all test function names

Closes #77
test: remove test contracts for each testing branch in SablierV2Linear

See discussion in #91
test: add modifiers for the create function in SablierV2Linear
test: fix comments on IsCancelable tests
test: remove test contracts for each testing branch in SablierV2Pro

See discussion in #91
test: rename test functions
test: solve inheritance issue
chore: update remapping for "forge-std"
test: import new "NonCompliantERC20" from "@prb/contracts"
test: rename "nonStandardToken" to "nonCompliantToken"
@PaulRBerg PaulRBerg force-pushed the test/enhancements branch from 4ab571d to 7050e51 Compare July 19, 2022 09:12
@PaulRBerg PaulRBerg changed the title Two testing enhancements Modifiers for each testing branch (plus other enhancements) Jul 19, 2022
ci: run fuzzer 10,000 times
style: indent toml with 2 spaces
chore: order fields alphabetically in "foundry.toml"
test: change "Overflow" to "Overflows" in function names
@PaulRBerg PaulRBerg force-pushed the test/enhancements branch from a06cfaf to 0e25245 Compare July 19, 2022 10:28
test: delete "OneSegment", "Token6Decimals" and "Token18Decimals"
modifiers
test: structure "getWithdrawableAmount" tests properly
test: change "CallerUnauthorized" to "CallerNotRecipient"
test: change "CallerUnauthorized" to "CallerNotSender"
test: fix whitespace in "withdrawAll" testing tree
test: delete "CallerSender" and "Token18Decimals" modifiers
test: rename "testCannotCreate" to "testCannotCreate__StartTimeGreaterThanFirstMilestone"
test: rename "testWithdrawAll" to "testWithdrawAll__CallerSender"
@PaulRBerg
Copy link
Member Author

I fixed a couple of mistakes in your implementation @andreivladbrg.

  1. In sablier-v2-linear/cancel.t.sol, you forgot to add the StreamEnded descriptor in the test function for the case when the stream ended which tests that the Cancel event gets emitted (testCancel__Event should have been testCancel__StreamEnded__Event)
  2. The branches in sablier-v2-linear/create.t.sol and sablier-v2-pro/create.t.sol have not been construed correctly. You should have mirrored the Token6Decimals and Token18Decimals descriptors, and likewise the CallerNotSender and CallerSender descriptors, instead of creating modifiers for them.
  3. The branches in sablier-v2-pro/getWithdrawableAmount.t.sol have not been construed correctly. You should have mirrored the Token6Decimals and Token18Decimals descriptors, and likewise the OneSegment and MultipleSegments descriptors, instead of creating modifiers for them.
  4. The function testCannotCreate in sablier-v2-pro/create.t.sol should have been named testCannotCreate__StartTimeGreaterThanFirstMilestone.
  5. The function testWithdrawAll__CallerSender should have been named testWithdrawAll__CallerSenderAllStreams.
  6. You forgot to create a modifier for the case when the caller is the sender in the sablier-v2-linear/withdraw.t.sol tests.

As a rule of thumb, whenever there are complex branches which do not revert early, the names of the test functions should follow the testing branches so that we don't end up with name collisions.

@PaulRBerg PaulRBerg force-pushed the test/enhancements branch from d615bfa to d15bebd Compare July 19, 2022 13:12
@PaulRBerg
Copy link
Member Author

Gonna merge this now. Good job @andreivladbrg.

@PaulRBerg PaulRBerg merged commit 1139d8b into main Jul 19, 2022
@PaulRBerg PaulRBerg deleted the test/enhancements branch July 19, 2022 13:15
@andreivladbrg
Copy link
Member

andreivladbrg commented Jul 19, 2022

  1. Right, missed that.
  2. I think you missed that for the create function from the linear contract because you use descriptors and the modifier:
    https://github.com/sablierhq/v2-core/blob/1139d8b93b3f91a758590ed106e3d81a03c6a84c/test/unit/sablier-v2-linear/create/create.t.sol#L364-L373
  3. Ok
  4. I don't understand.
  5. Ok.
  6. Right, missed that.

@PaulRBerg
Copy link
Member Author

I think you missed that for the create function from the linear contract because you use descriptors and the modifier:

Good catch. Fixed on main via eb36d41.

I don't understand.

See this: testCannotCreate. It should have been named testCannotCreate__StartTimeGreaterThanFirstMilestone.

@andreivladbrg
Copy link
Member

See this: testCannotCreate. It should have been named testCannotCreate__StartTimeGreaterThanFirstMilestone.

Oh, didn't see that.

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 this pull request may close these issues.

2 participants