Skip to content

Commit

Permalink
test: use equality in the withdraw multiple test
Browse files Browse the repository at this point in the history
test: use only withdrawMax
  • Loading branch information
andreivladbrg committed Oct 24, 2024
1 parent b01cc2d commit e41a469
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions tests/integration/fuzz/withdrawMultiple.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ contract WithdrawMultiple_Delay_Fuzz_Test is Shared_Integration_Fuzz_Test {
)
external
{
_test_WithdrawMultiple(rps, withdrawCount, timeJump, decimals, ISablierFlow.withdrawMax.selector, 0);
_test_WithdrawMultiple(rps, withdrawCount, timeJump, decimals, 0);
}

/// @dev Checklist:
Expand All @@ -103,7 +103,7 @@ contract WithdrawMultiple_Delay_Fuzz_Test is Shared_Integration_Fuzz_Test {
)
external
{
_test_WithdrawMultiple(rps, withdrawCount, timeJump, decimals, ISablierFlow.withdraw.selector, withdrawAmount);
_test_WithdrawMultiple(rps, withdrawCount, timeJump, decimals, withdrawAmount);
}

// Private helper function.
Expand All @@ -112,7 +112,6 @@ contract WithdrawMultiple_Delay_Fuzz_Test is Shared_Integration_Fuzz_Test {
uint256 withdrawCount,
uint40 timeJump,
uint8 decimals,
bytes4 selector,
uint128 withdrawAmount
)
private
Expand Down Expand Up @@ -147,16 +146,7 @@ contract WithdrawMultiple_Delay_Fuzz_Test is Shared_Integration_Fuzz_Test {
timeJump = boundUint40(timeJump, 1 hours, 1 days);
vm.warp({ newTimestamp: getBlockTimestamp() + timeJump });

// Withdraw the tokens based on the selector value.
// ISablierFlow.withdraw
if (selector == ISablierFlow.withdraw.selector) {
withdrawAmount = boundUint128(withdrawAmount, 1, flow.withdrawableAmountOf(streamId));
flow.withdraw(streamId, users.recipient, withdrawAmount);
}
// ISablierFlow.withdrawMax
else if (selector == ISablierFlow.withdrawMax.selector) {
(withdrawAmount,) = flow.withdrawMax(streamId, users.recipient);
}
(withdrawAmount,) = flow.withdrawMax(streamId, users.recipient);

// Update the actual total amount withdrawn.
actualTotalWithdrawnAmount += withdrawAmount;
Expand All @@ -166,6 +156,6 @@ contract WithdrawMultiple_Delay_Fuzz_Test is Shared_Integration_Fuzz_Test {
uint256 desiredTotalWithdrawnAmount = getDescaledAmount(rps * totalStreamPeriod, decimals);

// Assert that actual withdrawn amount is always less than the desired amount.
assertLe(actualTotalWithdrawnAmount, desiredTotalWithdrawnAmount);
assertEq(actualTotalWithdrawnAmount, desiredTotalWithdrawnAmount);
}
}

0 comments on commit e41a469

Please sign in to comment.