Skip to content

Commit

Permalink
refactor: rename function to withdrawAtMultiple (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreivladbrg authored May 11, 2024
1 parent 968e8f4 commit 4405fdf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
9 changes: 8 additions & 1 deletion src/SablierV2OpenEnded.sol
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,14 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope
}

/// @inheritdoc ISablierV2OpenEnded
function withdrawMultiple(uint256[] calldata streamIds, uint40[] calldata times) external override noDelegateCall {
function withdrawAtMultiple(
uint256[] calldata streamIds,
uint40[] calldata times
)
external
override
noDelegateCall
{
// Check: there is an equal number of `streamIds` and `amounts`.
uint256 streamIdsCount = streamIds.length;
uint256 timesCount = times.length;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/ISablierV2OpenEnded.sol
Original file line number Diff line number Diff line change
Expand Up @@ -393,5 +393,5 @@ interface ISablierV2OpenEnded is ISablierV2OpenEndedState {
///
/// @param streamIds The IDs of the streams to withdraw from.
/// @param times The time references to calculate the streamed amount for each stream.
function withdrawMultiple(uint256[] calldata streamIds, uint40[] calldata times) external;
function withdrawAtMultiple(uint256[] calldata streamIds, uint40[] calldata times) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
}

function test_RevertWhen_DelegateCall() external {
bytes memory callData = abi.encodeCall(ISablierV2OpenEnded.withdrawMultiple, (defaultStreamIds, times));
bytes memory callData = abi.encodeCall(ISablierV2OpenEnded.withdrawAtMultiple, (defaultStreamIds, times));
expectRevertDueToDelegateCall(callData);
}

Expand All @@ -28,7 +28,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
vm.expectRevert(
abi.encodeWithSelector(Errors.SablierV2OpenEnded_WithdrawMultipleArrayCountsNotEqual.selector, 0, 1)
);
openEnded.withdrawMultiple(streamIds, _times);
openEnded.withdrawAtMultiple(streamIds, _times);
}

modifier whenArrayCountsAreEqual() {
Expand All @@ -38,7 +38,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
function test_WithdrawMultiple_ArrayCountsZero() external whenNotDelegateCalled whenArrayCountsAreEqual {
uint256[] memory streamIds = new uint256[](0);
uint40[] memory _times = new uint40[](0);
openEnded.withdrawMultiple(streamIds, _times);
openEnded.withdrawAtMultiple(streamIds, _times);
}

modifier whenArrayCountsNotZero() {
Expand All @@ -54,7 +54,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
defaultStreamIds[0] = nullStreamId;
defaultStreamIds[1] = nullStreamId;
vm.expectRevert(abi.encodeWithSelector(Errors.SablierV2OpenEnded_Null.selector, nullStreamId));
openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });
}

function test_RevertGiven_SomeNull()
Expand All @@ -65,7 +65,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
{
defaultStreamIds[0] = nullStreamId;
vm.expectRevert(abi.encodeWithSelector(Errors.SablierV2OpenEnded_Null.selector, nullStreamId));
openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });
}

function test_RevertGiven_OnlyCanceled()
Expand All @@ -77,7 +77,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
{
openEnded.cancel(defaultStreamIds[1]);
expectRevertCanceled();
openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });
}

function test_RevertGiven_SomeCanceled()
Expand All @@ -88,7 +88,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
givenNotNull
{
expectRevertCanceled();
openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });
}

function test_RevertWhen_OnlyWithdrawalTimesNotGreaterThanLastTimeUpdate()
Expand All @@ -109,7 +109,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
lastTimeUpdate
)
);
openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });
}

function test_RevertWhen_SomeWithdrawalTimesNotGreaterThanLastTimeUpdate()
Expand All @@ -131,7 +131,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
lastTimeUpdate
)
);
openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });
}

function test_RevertWhen_OnlyWithdrawalTimesInTheFuture()
Expand All @@ -152,7 +152,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
Errors.SablierV2OpenEnded_WithdrawalTimeInTheFuture.selector, futureTime, WARP_ONE_MONTH
)
);
openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });
}

function test_RevertWhen_SomeWithdrawalTimesInTheFuture()
Expand All @@ -174,7 +174,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
Errors.SablierV2OpenEnded_WithdrawalTimeInTheFuture.selector, futureTime, WARP_ONE_MONTH
)
);
openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });
}

function test_RevertGiven_OnlyZeroBalances()
Expand All @@ -190,7 +190,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
vm.expectRevert(
abi.encodeWithSelector(Errors.SablierV2OpenEnded_WithdrawBalanceZero.selector, defaultStreamIds[0])
);
openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });
}

function test_RevertGiven_SomeZeroBalances()
Expand All @@ -208,10 +208,10 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
vm.expectRevert(
abi.encodeWithSelector(Errors.SablierV2OpenEnded_WithdrawBalanceZero.selector, defaultStreamIds[1])
);
openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });
}

function test_WithdrawMultiple()
function test_withdrawAtMultiple()
external
whenNotDelegateCalled
whenArrayCountsAreEqual
Expand Down Expand Up @@ -247,7 +247,7 @@ contract WithdrawMultiple_Integration_Concrete_Test is Integration_Test {
withdrawAmount: WITHDRAW_AMOUNT
});

openEnded.withdrawMultiple({ streamIds: defaultStreamIds, times: times });
openEnded.withdrawAtMultiple({ streamIds: defaultStreamIds, times: times });

actualLastTimeUpdate = openEnded.getLastTimeUpdate(defaultStreamIds[0]);
expectedLastTimeUpdate = WITHDRAW_TIME;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
withdrawMultiple.t.sol
withdrawAtMultiple.t.sol
β”œβ”€β”€ when delegate called
β”‚ └── it should revert
└── when not delegate called
Expand Down

0 comments on commit 4405fdf

Please sign in to comment.