Skip to content

Commit

Permalink
docs: improve readability for streamId requirements
Browse files Browse the repository at this point in the history
test: say "given" for balance zero tests
  • Loading branch information
andreivladbrg committed Apr 22, 2024
1 parent e39449b commit c7cc864
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
15 changes: 5 additions & 10 deletions src/interfaces/ISablierV2OpenEnded.sol
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ interface ISablierV2OpenEnded is ISablierV2OpenEndedState {
///
/// Requiremenets:
/// - Must not be delegate called.
/// - `streamId` must not reference a null stream.
/// - `streamId` must not reference a canceled stream.
/// - `streamId` must not reference a null stream or a canceled stream.
/// - `msg.sender` must be the stream's sender.
/// - `newRatePerSecond` must be greater than zero and not equal to the current rate per second.
///
Expand All @@ -167,8 +166,7 @@ interface ISablierV2OpenEnded is ISablierV2OpenEndedState {
///
/// Requirements:
/// - Must not be delegate called.
/// - `streamId` must not reference a null stream.
/// - `streamId` must not reference a canceled stream.
/// - `streamId` must not reference a null stream or a canceled stream.
/// - `msg.sender` must be the stream's sender.
///
/// @param streamId The ID of the stream to cancel.
Expand Down Expand Up @@ -289,8 +287,7 @@ interface ISablierV2OpenEnded is ISablierV2OpenEndedState {
///
/// Requirements:
/// - Must not be delegate called.
/// - `streamId` must not reference a null stream.
/// - `streamId` must not reference a canceled stream.
/// - `streamId` must not reference a null stream or a canceled stream.
/// - `depositAmount` must be greater than zero.
///
/// @param streamId The ID of the stream to deposit on.
Expand All @@ -315,8 +312,7 @@ interface ISablierV2OpenEnded is ISablierV2OpenEndedState {
///
/// Requirements:
/// - Must not be delegate called.
/// - `streamId` must not reference a null stream.
/// - `streamId` must not reference a canceled stream.
/// - `streamId` must not reference a null stream or a canceled stream.
/// - `msg.sender` must be the sender.
/// - `refundAmount` must be greater than zero and must not exceed the refundable amount.
///
Expand All @@ -330,8 +326,7 @@ interface ISablierV2OpenEnded is ISablierV2OpenEndedState {
///
/// Requirements:
/// - Must not be delegate called.
// - `streamId` must not reference a null stream.
/// - `streamId` must reference a canceled stream.
// - `streamId` must not reference a null stream or a canceled stream.
/// - `msg.sender` must be the stream's sender.
/// - `ratePerSecond` must be greater than zero.
///
Expand Down
1 change: 1 addition & 0 deletions test/integration/withdraw-multiple/withdrawMultiple.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
givenNotCanceled
whenWithdrawalTimeGreaterThanLastUpdate
whenWithdrawalTimeNotInTheFuture
givenBalanceNotZero
{
defaultDeposit();
defaultDeposit(defaultStreamIds[1]);
Expand Down
6 changes: 3 additions & 3 deletions test/integration/withdraw-multiple/withdrawMultiple.tree
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ withdrawMultiple.t.sol
β”œβ”€β”€ when some withdrawal times are in the future
β”‚ └── it should revert
└── when none withdrawal times are in the future
β”œβ”€β”€ when all balances are zero
β”œβ”€β”€ given all balances are zero
β”‚ └── it should revert
β”œβ”€β”€ when some balances are zero
β”œβ”€β”€ given some balances are zero
β”‚ └── it should revert
└── when all balances are greater than zero
└── given all balances are greater than zero
β”œβ”€β”€ it should make the withdrawals
β”œβ”€β”€ it should update the times
└── it should emit multiple {WithdrawFromOpenEndedStream} events
6 changes: 5 additions & 1 deletion test/integration/withdraw/withdraw.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ contract Withdraw_Integration_Test is Integration_Test {
openEnded.withdraw({ streamId: defaultStreamId, to: users.recipient, time: futureTime });
}

function test_RevertWhen_BalanceZero()
function test_RevertGiven_BalanceZero()
external
whenNotDelegateCalled
givenNotNull
Expand All @@ -147,6 +147,7 @@ contract Withdraw_Integration_Test is Integration_Test {
whenWithdrawalAddressIsRecipient
whenWithdrawalTimeGreaterThanLastUpdate
whenWithdrawalTimeNotInTheFuture
givenBalanceNotZero
{
openEnded.withdraw({ streamId: defaultStreamId, to: users.recipient, time: WITHDRAW_TIME });

Expand All @@ -168,6 +169,7 @@ contract Withdraw_Integration_Test is Integration_Test {
whenWithdrawalAddressIsRecipient
whenWithdrawalTimeGreaterThanLastUpdate
whenWithdrawalTimeNotInTheFuture
givenBalanceNotZero
{
address unknownCaller = address(0xCAFE);
resetPrank({ msgSender: unknownCaller });
Expand All @@ -192,6 +194,7 @@ contract Withdraw_Integration_Test is Integration_Test {
whenWithdrawalAddressIsRecipient
whenWithdrawalTimeGreaterThanLastUpdate
whenWithdrawalTimeNotInTheFuture
givenBalanceNotZero
whenCallerRecipient
{
// Set the timestamp to 1 month ago to create the stream with the same `lastTimeUpdate` as `defaultStreamId`.
Expand All @@ -212,6 +215,7 @@ contract Withdraw_Integration_Test is Integration_Test {
whenWithdrawalAddressIsRecipient
whenWithdrawalTimeGreaterThanLastUpdate
whenWithdrawalTimeNotInTheFuture
givenBalanceNotZero
whenCallerRecipient
{
_test_Withdraw(defaultStreamId, dai);
Expand Down
4 changes: 2 additions & 2 deletions test/integration/withdraw/withdraw.tree
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ withdraw.t.sol
β”œβ”€β”€ when the withdrawal time is in the future
β”‚ └── it should revert
└── when the withdrawal time is not in the future
β”œβ”€β”€ when the balance is zero
β”œβ”€β”€ given the balance is zero
β”‚ └── it should revert
└── when the balance is not zero
└── given the balance is not zero
β”œβ”€β”€ when the caller is not the recipient
β”‚ β”œβ”€β”€ when the caller is the sender
β”‚ β”‚ └── it should make the withdrawal
Expand Down
6 changes: 5 additions & 1 deletion test/utils/Modifiers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ abstract contract Modifiers {
WITHDRAW
//////////////////////////////////////////////////////////////////////////*/

modifier whenToNonZeroAddress() {
modifier givenBalanceNotZero() {
_;
}

modifier whenCallerRecipient() {
_;
}

modifier whenToNonZeroAddress() {
_;
}

modifier whenWithdrawalAddressIsRecipient() {
_;
}
Expand Down

0 comments on commit c7cc864

Please sign in to comment.