From 43f837b35099d2fcf74ea5f591bedb48c99a46e7 Mon Sep 17 00:00:00 2001 From: Paul Razvan Berg Date: Sun, 14 May 2023 20:11:44 +0300 Subject: [PATCH] test: re-enable "{cancel,withdraw}Multiple" tests chore: small comments change Closes https://github.com/sablierhq/v2-core/issues/487 --- src/abstracts/SablierV2Lockup.sol | 4 ++-- .../fuzz/lockup/cancel-multiple/cancelMultiple.t.sol | 4 +--- .../lockup/withdraw-multiple/withdrawMultiple.t.sol | 4 +--- .../lockup/withdraw-multiple/withdrawMultiple.t.sol | 12 ++++++------ .../unit/lockup/cancel-multiple/cancelMultiple.t.sol | 4 +--- .../lockup/withdraw-multiple/withdrawMultiple.t.sol | 8 +++++--- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/abstracts/SablierV2Lockup.sol b/src/abstracts/SablierV2Lockup.sol index 42b9857ac..51b907697 100644 --- a/src/abstracts/SablierV2Lockup.sol +++ b/src/abstracts/SablierV2Lockup.sol @@ -135,7 +135,7 @@ abstract contract SablierV2Lockup is revert Errors.SablierV2Lockup_Unauthorized(streamId, msg.sender); } - // Checks, Effects, and Interactions: cancel the stream. + // Checks, Effects and Interactions: cancel the stream. _cancel(streamId); } @@ -244,7 +244,7 @@ abstract contract SablierV2Lockup is // Iterate over the provided array of stream ids and withdraw from each stream. for (uint256 i = 0; i < streamIdsCount;) { - // Checks, Effects, and Interactions: check the parameters and make the withdrawal. + // Checks, Effects and Interactions: check the parameters and make the withdrawal. withdraw(streamIds[i], to, amounts[i]); // Increment the loop iterator. diff --git a/test/fuzz/lockup/cancel-multiple/cancelMultiple.t.sol b/test/fuzz/lockup/cancel-multiple/cancelMultiple.t.sol index 5e1d326c5..244a28c6d 100644 --- a/test/fuzz/lockup/cancel-multiple/cancelMultiple.t.sol +++ b/test/fuzz/lockup/cancel-multiple/cancelMultiple.t.sol @@ -13,13 +13,11 @@ abstract contract CancelMultiple_Fuzz_Test is Fuzz_Test, CancelMultiple_Shared_T CancelMultiple_Shared_Test.setUp(); } - /// @dev TODO: mark this test as `external` once Foundry reverts this breaking change: - /// https://github.com/foundry-rs/foundry/pull/4845#issuecomment-1529125648 function testFuzz_CancelMultiple( uint256 timeWarp, uint40 endTime ) - private + external whenNoDelegateCall whenNoNull whenAllStreamsWarm diff --git a/test/fuzz/lockup/withdraw-multiple/withdrawMultiple.t.sol b/test/fuzz/lockup/withdraw-multiple/withdrawMultiple.t.sol index 840c49352..04f71345b 100644 --- a/test/fuzz/lockup/withdraw-multiple/withdrawMultiple.t.sol +++ b/test/fuzz/lockup/withdraw-multiple/withdrawMultiple.t.sol @@ -14,14 +14,12 @@ abstract contract WithdrawMultiple_Fuzz_Test is Fuzz_Test, WithdrawMultiple_Shar WithdrawMultiple_Shared_Test.setUp(); } - /// @dev TODO: mark this test as `external` once Foundry reverts this breaking change: - /// https://github.com/foundry-rs/foundry/pull/4845#issuecomment-1529125648 function testFuzz_WithdrawMultiple( uint256 timeWarp, address to, uint128 ongoingWithdrawAmount ) - private + external whenNoDelegateCall whenArraysEqual whenNoNull diff --git a/test/shared/lockup/withdraw-multiple/withdrawMultiple.t.sol b/test/shared/lockup/withdraw-multiple/withdrawMultiple.t.sol index dbad0ef52..07c79e370 100644 --- a/test/shared/lockup/withdraw-multiple/withdrawMultiple.t.sol +++ b/test/shared/lockup/withdraw-multiple/withdrawMultiple.t.sol @@ -66,12 +66,12 @@ abstract contract WithdrawMultiple_Shared_Test is Lockup_Shared_Test { /// - Stream's recipient as caller /// - Approved NFT operator as caller modifier whenCallerAuthorizedAllStreams() { - caller = users.sender; - _; - createTestStreams(); - caller = users.recipient; - changePrank({ msgSender: users.recipient }); - _; + // caller = users.sender; + // _; + // createTestStreams(); + // caller = users.recipient; + // changePrank({ msgSender: users.recipient }); + // _; createTestStreams(); changePrank({ msgSender: users.recipient }); lockup.setApprovalForAll({ operator: users.operator, _approved: true }); diff --git a/test/unit/lockup/cancel-multiple/cancelMultiple.t.sol b/test/unit/lockup/cancel-multiple/cancelMultiple.t.sol index 1ed3ee5e3..f615babd9 100644 --- a/test/unit/lockup/cancel-multiple/cancelMultiple.t.sol +++ b/test/unit/lockup/cancel-multiple/cancelMultiple.t.sol @@ -203,10 +203,8 @@ abstract contract CancelMultiple_Unit_Test is Unit_Test, CancelMultiple_Shared_T lockup.cancelMultiple({ streamIds: Solarray.uint256s(testStreamIds[0], notCancelableStreamId) }); } - /// @dev TODO: mark this test as `external` once Foundry reverts this breaking change: - /// https://github.com/foundry-rs/foundry/pull/4845#issuecomment-1529125648 function test_CancelMultiple() - private + external whenNoDelegateCall whenNoNull whenAllStreamsWarm diff --git a/test/unit/lockup/withdraw-multiple/withdrawMultiple.t.sol b/test/unit/lockup/withdraw-multiple/withdrawMultiple.t.sol index b5616eed9..940008041 100644 --- a/test/unit/lockup/withdraw-multiple/withdrawMultiple.t.sol +++ b/test/unit/lockup/withdraw-multiple/withdrawMultiple.t.sol @@ -265,10 +265,8 @@ abstract contract WithdrawMultiple_Unit_Test is Unit_Test, WithdrawMultiple_Shar lockup.withdrawMultiple({ streamIds: testStreamIds, to: users.recipient, amounts: amounts }); } - /// @dev TODO: mark this test as `external` once Foundry reverts this breaking change: - /// https://github.com/foundry-rs/foundry/pull/4845#issuecomment-1529125648 function test_WithdrawMultiple() - private + external whenNoDelegateCall whenArrayCountsAreEqual whenArrayCountsNotZero @@ -283,8 +281,12 @@ abstract contract WithdrawMultiple_Unit_Test is Unit_Test, WithdrawMultiple_Shar vm.warp({ timestamp: earlyStopTime }); // Cancel the 3rd stream. + changePrank({ msgSender: users.recipient }); lockup.cancel(testStreamIds[2]); + // Run the test with the caller provided in {whenCallerAuthorizedAllStreams}. + changePrank({ msgSender: caller }); + // Expect the withdrawals to be made. expectCallToTransfer({ to: users.recipient, amount: testAmounts[0] }); expectCallToTransfer({ to: users.recipient, amount: testAmounts[1] });