From 7a81bdc252e358c6bf22da28387af8cc3741410c Mon Sep 17 00:00:00 2001 From: Iaroslav Mazur Date: Sun, 9 Jul 2023 14:07:14 +0300 Subject: [PATCH 1/2] Changes in test/ resulting from the audit --- test/Base.t.sol | 40 +++++++------ test/fork/plugin/onStreamCanceled.t.sol | 2 +- test/fork/target/batchCancelMultiple.t.sol | 2 +- test/fork/target/batchCreate.t.sol | 6 +- test/integration/archive/list/list.t.sol | 3 + test/integration/archive/unlist/unlist.t.sol | 6 +- .../on-stream-canceled/onStreamCanceled.tree | 4 +- .../batchCancelMultiple.t.sol | 2 +- .../batchCreateWithRange.t.sol | 4 +- test/integration/target/burn/burn.t.sol | 8 +-- .../cancel-and-create/cancelAndCreate.t.sol | 8 +-- .../cancel-multiple/cancelMultiple.t.sol | 6 +- test/integration/target/cancel/cancel.t.sol | 8 +-- .../target/renounce/renounce.t.sol | 6 +- .../withdrawMaxAndTransfer.t.sol | 6 +- .../target/withdraw-max/withdrawMax.t.sol | 6 +- .../target/withdraw/withdraw.t.sol | 6 +- .../wrap-and-create/wrapAndCreate.t.sol | 8 +-- test/utils/BatchBuilder.sol | 56 +++++++++---------- test/utils/Defaults.sol | 8 +-- 20 files changed, 105 insertions(+), 90 deletions(-) diff --git a/test/Base.t.sol b/test/Base.t.sol index 52259bb3..5c1646d9 100644 --- a/test/Base.t.sol +++ b/test/Base.t.sol @@ -224,7 +224,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { vm.expectCall({ callee: asset_, data: abi.encodeCall(IERC20.transferFrom, (from, to, amount)) }); } - /// @dev Expects multiple similar calls to {ISablierV2LockupDynamic.createWithDeltas}, each with the specified + /// @dev Expects multiple calls to {ISablierV2LockupDynamic.createWithDeltas}, each with the specified /// `params`. function expectMultipleCallsToCreateWithDeltas( uint64 count, @@ -239,7 +239,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { }); } - /// @dev Expects multiple similar calls to {ISablierV2LockupDynamic.createWithDurations}, each with the specified + /// @dev Expects multiple calls to {ISablierV2LockupDynamic.createWithDurations}, each with the specified /// `params`. function expectMultipleCallsToCreateWithDurations( uint64 count, @@ -254,7 +254,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { }); } - /// @dev Expects multiple similar calls to {ISablierV2LockupDynamic.createWithMilestones}, each with the specified + /// @dev Expects multiple calls to {ISablierV2LockupDynamic.createWithMilestones}, each with the specified /// `params`. function expectMultipleCallsToCreateWithMilestones( uint64 count, @@ -269,7 +269,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { }); } - /// @dev Expects multiple similar calls to {ISablierV2LockupDynamic.createWithRange}, each with the specified + /// @dev Expects multiple calls to {ISablierV2LockupDynamic.createWithRange}, each with the specified /// `params`. function expectMultipleCallsToCreateWithRange(uint64 count, LockupLinear.CreateWithRange memory params) internal { vm.expectCall({ @@ -317,7 +317,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { ) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256[])); + return decodeAsUint256Array(response); } function batchCreateWithDurations() internal returns (uint256[] memory) { @@ -331,7 +331,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { ) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256[])); + return decodeAsUint256Array(response); } function batchCreateWithMilestones() internal returns (uint256[] memory) { @@ -345,7 +345,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { ) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256[])); + return decodeAsUint256Array(response); } function batchCreateWithMilestones(uint256 batchSize) internal returns (uint256[] memory) { @@ -360,7 +360,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { ) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256[])); + return decodeAsUint256Array(response); } function batchCreateWithRange() internal returns (uint256[] memory) { @@ -374,7 +374,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { ) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256[])); + return decodeAsUint256Array(response); } function batchCreateWithRange(uint256 batchSize) internal returns (uint256[] memory) { @@ -384,7 +384,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { (lockupLinear, asset, defaults.batchCreateWithRange(batchSize), defaults.permit2Params(totalTransferAmount)) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256[])); + return decodeAsUint256Array(response); } function createWithDeltas() internal returns (uint256) { @@ -393,7 +393,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { (lockupDynamic, defaults.createWithDeltas(), defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256)); + return decodeAsUint256(response); } function createWithDurations() internal returns (uint256) { @@ -402,7 +402,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { (lockupLinear, defaults.createWithDurations(), defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256)); + return decodeAsUint256(response); } function createWithMilestones() internal returns (uint256) { @@ -411,7 +411,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { (lockupDynamic, defaults.createWithMilestones(), defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256)); + return decodeAsUint256(response); } function createWithMilestones(LockupDynamic.CreateWithMilestones memory params) internal returns (uint256) { @@ -419,7 +419,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { target.createWithMilestones, (lockupDynamic, params, defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256)); + return decodeAsUint256(response); } function createWithRange() internal returns (uint256) { @@ -428,7 +428,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { (lockupLinear, defaults.createWithRange(), defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256)); + return decodeAsUint256(response); } function createWithRange(LockupLinear.CreateWithRange memory params) internal returns (uint256) { @@ -436,6 +436,14 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { target.createWithRange, (lockupLinear, params, defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return abi.decode(response, (uint256)); + return decodeAsUint256(response); + } + + function decodeAsUint256(bytes memory input) private pure returns (uint256) { + return abi.decode(input, (uint256)); + } + + function decodeAsUint256Array(bytes memory input) private pure returns (uint256[] memory) { + return abi.decode(input, (uint256[])); } } diff --git a/test/fork/plugin/onStreamCanceled.t.sol b/test/fork/plugin/onStreamCanceled.t.sol index dc7798b6..017f5ef9 100644 --- a/test/fork/plugin/onStreamCanceled.t.sol +++ b/test/fork/plugin/onStreamCanceled.t.sol @@ -9,7 +9,7 @@ import { Fork_Test } from "../Fork.t.sol"; import { Permit2Params } from "src/types/Permit2.sol"; -/// @dev Runs against multiple assets. +/// @dev Runs against the asset passed to its constructor. abstract contract OnStreamCanceled_Fork_Test is Fork_Test, PermitSignature { constructor(IERC20 asset_) Fork_Test(asset_) { } diff --git a/test/fork/target/batchCancelMultiple.t.sol b/test/fork/target/batchCancelMultiple.t.sol index a1175fd7..7d108277 100644 --- a/test/fork/target/batchCancelMultiple.t.sol +++ b/test/fork/target/batchCancelMultiple.t.sol @@ -8,7 +8,7 @@ import { Batch } from "src/types/DataTypes.sol"; import { Fork_Test } from "../Fork.t.sol"; -/// @dev Runs against multiple assets. +/// @dev Runs against the asset passed to its constructor. abstract contract BatchCancelMultiple_Fork_Test is Fork_Test { constructor(IERC20 asset_) Fork_Test(asset_) { } diff --git a/test/fork/target/batchCreate.t.sol b/test/fork/target/batchCreate.t.sol index f3647512..cae59f48 100644 --- a/test/fork/target/batchCreate.t.sol +++ b/test/fork/target/batchCreate.t.sol @@ -14,7 +14,7 @@ import { Fork_Test } from "../Fork.t.sol"; import { ArrayBuilder } from "../../utils/ArrayBuilder.sol"; import { BatchBuilder } from "../../utils/BatchBuilder.sol"; -/// @dev Runs against multiple assets. +/// @dev Runs against the asset passed to its constructor. abstract contract BatchCreate_Fork_Test is Fork_Test, PermitSignature { constructor(IERC20 asset_) Fork_Test(asset_) { } @@ -54,7 +54,7 @@ abstract contract BatchCreate_Fork_Test is Fork_Test, PermitSignature { range: params.range, totalAmount: params.perStreamAmount }); - Batch.CreateWithRange[] memory batch = BatchBuilder.fillBatch(createParams, params.batchSize); + Batch.CreateWithRange[] memory batch = BatchBuilder.generateBatchFromParams(createParams, params.batchSize); Permit2Params memory permit2Params = defaults.permit2Params({ user: user, spender: address(userProxy), @@ -129,7 +129,7 @@ abstract contract BatchCreate_Fork_Test is Fork_Test, PermitSignature { startTime: params.startTime, totalAmount: params.perStreamAmount }); - Batch.CreateWithMilestones[] memory batch = BatchBuilder.fillBatch(createWithMilestones, params.batchSize); + Batch.CreateWithMilestones[] memory batch = BatchBuilder.generateBatchFromParams(createWithMilestones, params.batchSize); Permit2Params memory permit2Params = defaults.permit2Params({ user: user, spender: address(userProxy), diff --git a/test/integration/archive/list/list.t.sol b/test/integration/archive/list/list.t.sol index 8eeae3b6..5757f8ab 100644 --- a/test/integration/archive/list/list.t.sol +++ b/test/integration/archive/list/list.t.sol @@ -29,7 +29,10 @@ contract List_Integration_Test is Integration_Test { } function test_List() external callerAdmin addressNotListed { + vm.expectEmit(); + emit List({ admin: users.admin.addr, addr: address(lockupLinear) }); archive.list(address(lockupLinear)); + bool isListed = archive.isListed(address(lockupLinear)); assertTrue(isListed, "isListed"); } diff --git a/test/integration/archive/unlist/unlist.t.sol b/test/integration/archive/unlist/unlist.t.sol index 0074fcf5..cec99d6f 100644 --- a/test/integration/archive/unlist/unlist.t.sol +++ b/test/integration/archive/unlist/unlist.t.sol @@ -18,17 +18,21 @@ contract Unlist_Integration_Test is Integration_Test { } function test_Unlist_AddressNotListed() external callerAdmin { + archive.unlist(address(lockupLinear)); bool isListed = archive.isListed(address(lockupLinear)); assertFalse(isListed, "isListed"); } modifier addressListed() { + archive.list(address(lockupLinear)); _; } function test_Unlist() external callerAdmin addressListed { - archive.list(address(lockupLinear)); + vm.expectEmit(); + emit Unlist({ admin: users.admin.addr, addr: address(lockupLinear) }); archive.unlist(address(lockupLinear)); + bool isListed = archive.isListed(address(lockupLinear)); assertFalse(isListed, "isListed"); } diff --git a/test/integration/plugin/on-stream-canceled/onStreamCanceled.tree b/test/integration/plugin/on-stream-canceled/onStreamCanceled.tree index 4d4fef5a..410cda21 100644 --- a/test/integration/plugin/on-stream-canceled/onStreamCanceled.tree +++ b/test/integration/plugin/on-stream-canceled/onStreamCanceled.tree @@ -2,7 +2,7 @@ onStreamCanceled.t.sol ├── when not delegate called │ └── it should revert └── when delegate called - ├── when the caller is not listed + ├── when the caller is not listed in the archive │ └── it should revert - └── when the caller is listed + └── when the caller is listed in the archive └── it should forward the assets to the proxy owner diff --git a/test/integration/target/batch-cancel-multiple/batchCancelMultiple.t.sol b/test/integration/target/batch-cancel-multiple/batchCancelMultiple.t.sol index b689a98a..09779480 100644 --- a/test/integration/target/batch-cancel-multiple/batchCancelMultiple.t.sol +++ b/test/integration/target/batch-cancel-multiple/batchCancelMultiple.t.sol @@ -33,7 +33,7 @@ contract BatchCancelMultiple_Integration_Test is Integration_Test { } function test_BatchCancelMultiple() external batchSizeNotZero whenDelegateCalled { - // Create two batches of streams due to be canceled. + // Create two batches of streams to be canceled. uint256[] memory dynamicStreamIds = batchCreateWithMilestones(); uint256[] memory linearStreamIds = batchCreateWithRange(); diff --git a/test/integration/target/batch-create-with-range/batchCreateWithRange.t.sol b/test/integration/target/batch-create-with-range/batchCreateWithRange.t.sol index f23587c5..99866419 100644 --- a/test/integration/target/batch-create-with-range/batchCreateWithRange.t.sol +++ b/test/integration/target/batch-create-with-range/batchCreateWithRange.t.sol @@ -9,10 +9,10 @@ import { Integration_Test } from "../../Integration.t.sol"; contract BatchCreateWithRange_Integration_Test is Integration_Test { function test_RevertWhen_NotDelegateCalled() external { - Batch.CreateWithDurations[] memory batch; + Batch.CreateWithRange[] memory batch; Permit2Params memory permit2Params; vm.expectRevert(Errors.CallNotDelegateCall.selector); - target.batchCreateWithDurations(lockupLinear, asset, batch, permit2Params); + target.batchCreateWithRange(lockupLinear, asset, batch, permit2Params); } modifier whenDelegateCalled() { diff --git a/test/integration/target/burn/burn.t.sol b/test/integration/target/burn/burn.t.sol index 8766ce4d..8ed29296 100644 --- a/test/integration/target/burn/burn.t.sol +++ b/test/integration/target/burn/burn.t.sol @@ -22,17 +22,17 @@ contract Burn_Integration_Test is Integration_Test { LockupDynamic.CreateWithMilestones memory params = defaults.createWithMilestones(); params.recipient = address(aliceProxy); uint256 streamId = createWithMilestones(params); - test_Burn(lockupDynamic, streamId); + burn(lockupDynamic, streamId); } function test_Burn_LockupLinear() external whenDelegateCalled { LockupLinear.CreateWithRange memory params = defaults.createWithRange(); params.recipient = address(aliceProxy); uint256 streamId = createWithRange(params); - test_Burn(lockupLinear, streamId); + burn(lockupLinear, streamId); } - function test_Burn(ISablierV2Lockup lockup, uint256 streamId) internal { + function burn(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.END_TIME()); @@ -44,7 +44,7 @@ contract Burn_Integration_Test is Integration_Test { data = abi.encodeCall(target.burn, (lockup, streamId)); aliceProxy.execute(address(target), data); - // Expect the NFT owner not to exist anymore. + // Expect the NFT owner to not exist anymore. vm.expectRevert("ERC721: invalid token ID"); lockup.getRecipient(streamId); } diff --git a/test/integration/target/cancel-and-create/cancelAndCreate.t.sol b/test/integration/target/cancel-and-create/cancelAndCreate.t.sol index 4560c9c7..6de820d9 100644 --- a/test/integration/target/cancel-and-create/cancelAndCreate.t.sol +++ b/test/integration/target/cancel-and-create/cancelAndCreate.t.sol @@ -61,7 +61,7 @@ contract CancelAndCreate_Integration_Test is Integration_Test { assertEq(actualNewStreamId, expectedNewStreamId, "new stream id mismatch"); } - function test_CancelAndCreateWithDeltas_AcrossSablierContracts() external { + function test_CancelAndCreateWithDeltas_AcrossSablierContracts() external whenDelegateCalled { // Create the stream due to be canceled. uint256 streamId = createWithRange(); @@ -130,7 +130,7 @@ contract CancelAndCreate_Integration_Test is Integration_Test { assertEq(actualNewStreamId, expectedNewStreamId, "new stream id mismatch"); } - function test_CancelAndCreateWithDurations_AcrossSablierContracts() external { + function test_CancelAndCreateWithDurations_AcrossSablierContracts() external whenDelegateCalled { // Create the stream due to be canceled. uint256 streamId = createWithMilestones(); @@ -199,7 +199,7 @@ contract CancelAndCreate_Integration_Test is Integration_Test { assertEq(actualNewStreamId, expectedNewStreamId, "new stream id mismatch"); } - function test_CancelAndCreateWithMilestones_AcrossSablierContracts() external { + function test_CancelAndCreateWithMilestones_AcrossSablierContracts() external whenDelegateCalled { // Create the stream due to be canceled. uint256 streamId = createWithRange(); @@ -268,7 +268,7 @@ contract CancelAndCreate_Integration_Test is Integration_Test { assertEq(actualNewStreamId, expectedNewStreamId, "new stream id mismatch"); } - function test_CancelAndCreateWithRange_AcrossSablierContracts() external { + function test_CancelAndCreateWithRange_AcrossSablierContracts() external whenDelegateCalled { // Create the stream due to be canceled. uint256 streamId = createWithMilestones(); diff --git a/test/integration/target/cancel-multiple/cancelMultiple.t.sol b/test/integration/target/cancel-multiple/cancelMultiple.t.sol index addf1d0c..0b54bef8 100644 --- a/test/integration/target/cancel-multiple/cancelMultiple.t.sol +++ b/test/integration/target/cancel-multiple/cancelMultiple.t.sol @@ -23,15 +23,15 @@ contract CancelMultiple_Integration_Test is Integration_Test { function test_CancelMultiple_LockupDynamic() external whenDelegateCalled { uint256[] memory streamIds = batchCreateWithMilestones(); - test_CancelMultiple(lockupDynamic, streamIds); + cancelMultiple(lockupDynamic, streamIds); } function test_CancelMultiple_LockupLinear() external whenDelegateCalled { uint256[] memory streamIds = batchCreateWithRange(); - test_CancelMultiple(lockupLinear, streamIds); + cancelMultiple(lockupLinear, streamIds); } - function test_CancelMultiple(ISablierV2Lockup lockup, uint256[] memory streamIds) internal { + function cancelMultiple(ISablierV2Lockup lockup, uint256[] memory streamIds) internal { // Simulate the passage of time. vm.warp(defaults.CLIFF_TIME()); diff --git a/test/integration/target/cancel/cancel.t.sol b/test/integration/target/cancel/cancel.t.sol index 96584857..e203e31b 100644 --- a/test/integration/target/cancel/cancel.t.sol +++ b/test/integration/target/cancel/cancel.t.sol @@ -20,19 +20,19 @@ contract Cancel_Integration_Test is Integration_Test { function test_Cancel_LockupDynamic() external whenDelegateCalled { uint256 streamId = createWithMilestones(); - test_Cancel(lockupDynamic, streamId); + cancel(lockupDynamic, streamId); } function test_Cancel_LockupLinear() external whenDelegateCalled { uint256 streamId = createWithRange(); - test_Cancel(lockupLinear, streamId); + cancel(lockupLinear, streamId); } - function test_Cancel(ISablierV2Lockup lockup, uint256 streamId) internal { + function cancel(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.CLIFF_TIME()); - // Asset flow: proxy owner → proxy → proxy owner + // Asset flow: Sablier → proxy → proxy owner expectCallToTransfer({ to: address(aliceProxy), amount: defaults.REFUND_AMOUNT() }); expectCallToTransfer({ to: users.alice.addr, amount: defaults.REFUND_AMOUNT() }); diff --git a/test/integration/target/renounce/renounce.t.sol b/test/integration/target/renounce/renounce.t.sol index bf78ee82..fe16df0a 100644 --- a/test/integration/target/renounce/renounce.t.sol +++ b/test/integration/target/renounce/renounce.t.sol @@ -19,15 +19,15 @@ contract Renounce_Integration_Test is Integration_Test { function test_Renounce_LockupDynamic() external whenDelegateCalled { uint256 streamId = createWithMilestones(); - test_Renounce(lockupDynamic, streamId); + renounce(lockupDynamic, streamId); } function test_Renounce_LockupLinear() external whenDelegateCalled { uint256 streamId = createWithRange(); - test_Renounce(lockupLinear, streamId); + renounce(lockupLinear, streamId); } - function test_Renounce(ISablierV2Lockup lockup, uint256 streamId) internal { + function renounce(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.CLIFF_TIME()); diff --git a/test/integration/target/withdraw-max-and-transfer/withdrawMaxAndTransfer.t.sol b/test/integration/target/withdraw-max-and-transfer/withdrawMaxAndTransfer.t.sol index 3e6b4473..306bc655 100644 --- a/test/integration/target/withdraw-max-and-transfer/withdrawMaxAndTransfer.t.sol +++ b/test/integration/target/withdraw-max-and-transfer/withdrawMaxAndTransfer.t.sol @@ -22,17 +22,17 @@ contract WithdrawMaxAndTransfer_Integration_Test is Integration_Test { LockupDynamic.CreateWithMilestones memory params = defaults.createWithMilestones(); params.recipient = address(aliceProxy); uint256 streamId = createWithMilestones(params); - test_WithdrawMaxAndTransfer(lockupDynamic, streamId); + withdrawMaxAndTransfer(lockupDynamic, streamId); } function test_WithdrawMaxAndTransfer_LockupLinear() external whenDelegateCalled { LockupLinear.CreateWithRange memory params = defaults.createWithRange(); params.recipient = address(aliceProxy); uint256 streamId = createWithRange(params); - test_WithdrawMaxAndTransfer(lockupLinear, streamId); + withdrawMaxAndTransfer(lockupLinear, streamId); } - function test_WithdrawMaxAndTransfer(ISablierV2Lockup lockup, uint256 streamId) internal { + function withdrawMaxAndTransfer(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.CLIFF_TIME()); diff --git a/test/integration/target/withdraw-max/withdrawMax.t.sol b/test/integration/target/withdraw-max/withdrawMax.t.sol index b59ac06b..27e7fbf4 100644 --- a/test/integration/target/withdraw-max/withdrawMax.t.sol +++ b/test/integration/target/withdraw-max/withdrawMax.t.sol @@ -19,15 +19,15 @@ contract WithdrawMax_Integration_Test is Integration_Test { function test_WithdrawMax_LockupDynamic() external whenDelegateCalled { uint256 streamId = createWithMilestones(); - test_WithdrawMax(lockupDynamic, streamId); + withdrawMax(lockupDynamic, streamId); } function test_WithdrawMax_Linear() external whenDelegateCalled { uint256 streamId = createWithRange(); - test_WithdrawMax(lockupLinear, streamId); + withdrawMax(lockupLinear, streamId); } - function test_WithdrawMax(ISablierV2Lockup lockup, uint256 streamId) internal { + function withdrawMax(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.END_TIME()); diff --git a/test/integration/target/withdraw/withdraw.t.sol b/test/integration/target/withdraw/withdraw.t.sol index c6ed2311..68717668 100644 --- a/test/integration/target/withdraw/withdraw.t.sol +++ b/test/integration/target/withdraw/withdraw.t.sol @@ -19,15 +19,15 @@ contract Withdraw_Integration_Test is Integration_Test { function test_Withdraw_LockupDynamic() external whenDelegateCalled { uint256 streamId = createWithMilestones(); - test_Withdraw(lockupDynamic, streamId); + withdraw(lockupDynamic, streamId); } function test_Withdraw_LockupLinear() external whenDelegateCalled { uint256 streamId = createWithRange(); - test_Withdraw(lockupLinear, streamId); + withdraw(lockupLinear, streamId); } - function test_Withdraw(ISablierV2Lockup lockup, uint256 streamId) internal { + function withdraw(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.CLIFF_TIME()); diff --git a/test/integration/target/wrap-and-create/wrapAndCreate.t.sol b/test/integration/target/wrap-and-create/wrapAndCreate.t.sol index 60117b8e..147f3810 100644 --- a/test/integration/target/wrap-and-create/wrapAndCreate.t.sol +++ b/test/integration/target/wrap-and-create/wrapAndCreate.t.sol @@ -9,10 +9,10 @@ import { Errors } from "src/libraries/Errors.sol"; import { Integration_Test } from "../../Integration.t.sol"; /// @dev This contracts tests the following functions: -/// - `wrapEtherAndCreateWithDeltas` -/// - `wrapEtherAndCreateWithDurations` -/// - `wrapEtherAndCreateWithMilestones` -/// - `wrapEtherAndCreateWithRange` +/// - `wrapAndCreateWithDeltas` +/// - `wrapAndCreateWithDurations` +/// - `wrapAndCreateWithMilestones` +/// - `wrapAndCreateWithRange` contract WrapAndCreate_Integration_Test is Integration_Test { modifier whenDelegateCalled() { _; diff --git a/test/utils/BatchBuilder.sol b/test/utils/BatchBuilder.sol index 6b3d2091..9282f807 100644 --- a/test/utils/BatchBuilder.sol +++ b/test/utils/BatchBuilder.sol @@ -6,9 +6,9 @@ import { LockupDynamic, LockupLinear } from "@sablier/v2-core/types/DataTypes.so import { Batch } from "../../src/types/DataTypes.sol"; library BatchBuilder { - /// @notice Generates an array of `batchSingle` with the specified `batchSize`. - function fillBatch( - Batch.CreateWithDeltas memory batchSingle, + /// @notice Generates an array containing `batchSize` copies of `sample`. + function generateBatchFromSample( + Batch.CreateWithDeltas memory sample, uint256 batchSize ) internal @@ -18,13 +18,13 @@ library BatchBuilder { batch = new Batch.CreateWithDeltas[](batchSize); unchecked { for (uint256 i = 0; i < batchSize; ++i) { - batch[i] = batchSingle; + batch[i] = sample; } } } /// @notice Turns the `params` into an array of `Batch.CreateWithDeltas` structs. - function fillBatch( + function generateBatchFromParams( LockupDynamic.CreateWithDeltas memory params, uint256 batchSize ) @@ -33,7 +33,7 @@ library BatchBuilder { returns (Batch.CreateWithDeltas[] memory batch) { batch = new Batch.CreateWithDeltas[](batchSize); - Batch.CreateWithDeltas memory batchSingle = Batch.CreateWithDeltas({ + Batch.CreateWithDeltas memory sample = Batch.CreateWithDeltas({ broker: params.broker, cancelable: params.cancelable, recipient: params.recipient, @@ -41,12 +41,12 @@ library BatchBuilder { sender: params.sender, totalAmount: params.totalAmount }); - batch = fillBatch(batchSingle, batchSize); + batch = generateBatchFromSample(sample, batchSize); } - /// @notice Generates an array of `batchSingle` with the specified `batchSize`. - function fillBatch( - Batch.CreateWithDurations memory batchSingle, + /// @notice Generates an array containing `batchSize` copies of `sample`. + function generateBatchFromSample( + Batch.CreateWithDurations memory sample, uint256 batchSize ) internal @@ -56,13 +56,13 @@ library BatchBuilder { batch = new Batch.CreateWithDurations[](batchSize); unchecked { for (uint256 i = 0; i < batchSize; ++i) { - batch[i] = batchSingle; + batch[i] = sample; } } } /// @notice Turns the `params` into an array of `Batch.CreateWithDurations` structs. - function fillBatch( + function generateBatchFromParams( LockupLinear.CreateWithDurations memory params, uint256 batchSize ) @@ -71,7 +71,7 @@ library BatchBuilder { returns (Batch.CreateWithDurations[] memory batch) { batch = new Batch.CreateWithDurations[](batchSize); - Batch.CreateWithDurations memory batchSingle = Batch.CreateWithDurations({ + Batch.CreateWithDurations memory sample = Batch.CreateWithDurations({ broker: params.broker, cancelable: params.cancelable, durations: params.durations, @@ -79,12 +79,12 @@ library BatchBuilder { sender: params.sender, totalAmount: params.totalAmount }); - batch = fillBatch(batchSingle, batchSize); + batch = generateBatchFromSample(sample, batchSize); } - /// @notice Generates an array of `batchSingle` with the specified `batchSize`. - function fillBatch( - Batch.CreateWithMilestones memory batchSingle, + /// @notice Generates an array containing `batchSize` copies of `sample`. + function generateBatchFromSample( + Batch.CreateWithMilestones memory sample, uint256 batchSize ) internal @@ -94,13 +94,13 @@ library BatchBuilder { batch = new Batch.CreateWithMilestones[](batchSize); unchecked { for (uint256 i = 0; i < batchSize; ++i) { - batch[i] = batchSingle; + batch[i] = sample; } } } /// @notice Turns the `params` into an array of `Batch.CreateWithMilestones` structs. - function fillBatch( + function generateBatchFromParams( LockupDynamic.CreateWithMilestones memory params, uint256 batchSize ) @@ -109,7 +109,7 @@ library BatchBuilder { returns (Batch.CreateWithMilestones[] memory batch) { batch = new Batch.CreateWithMilestones[](batchSize); - Batch.CreateWithMilestones memory batchSingle = Batch.CreateWithMilestones({ + Batch.CreateWithMilestones memory sample = Batch.CreateWithMilestones({ broker: params.broker, cancelable: params.cancelable, recipient: params.recipient, @@ -118,12 +118,12 @@ library BatchBuilder { startTime: params.startTime, totalAmount: params.totalAmount }); - batch = fillBatch(batchSingle, batchSize); + batch = generateBatchFromSample(sample, batchSize); } - /// @notice Generates an array of `batchSingle` with the specified `batchSize`. - function fillBatch( - Batch.CreateWithRange memory batchSingle, + /// @notice Generates an array containing `batchSize` copies of `sample`. + function generateBatchFromSample( + Batch.CreateWithRange memory sample, uint256 batchSize ) internal @@ -133,13 +133,13 @@ library BatchBuilder { batch = new Batch.CreateWithRange[](batchSize); unchecked { for (uint256 i = 0; i < batchSize; ++i) { - batch[i] = batchSingle; + batch[i] = sample; } } } /// @notice Turns the `params` into an array of `Batch.CreateWithRange` structs. - function fillBatch( + function generateBatchFromParams( LockupLinear.CreateWithRange memory params, uint256 batchSize ) @@ -148,7 +148,7 @@ library BatchBuilder { returns (Batch.CreateWithRange[] memory batch) { batch = new Batch.CreateWithRange[](batchSize); - Batch.CreateWithRange memory batchSingle = Batch.CreateWithRange({ + Batch.CreateWithRange memory sample = Batch.CreateWithRange({ broker: params.broker, cancelable: params.cancelable, range: params.range, @@ -156,6 +156,6 @@ library BatchBuilder { sender: params.sender, totalAmount: params.totalAmount }); - batch = fillBatch(batchSingle, batchSize); + batch = generateBatchFromSample(sample, batchSize); } } diff --git a/test/utils/Defaults.sol b/test/utils/Defaults.sol index 13b651b4..3f6b9261 100644 --- a/test/utils/Defaults.sol +++ b/test/utils/Defaults.sol @@ -246,12 +246,12 @@ contract Defaults is PermitSignature { /// @dev Returns a default-size batch of `Batch.CreateWithDeltas` parameters. function batchCreateWithDeltas() public view returns (Batch.CreateWithDeltas[] memory batch) { - batch = BatchBuilder.fillBatch(createWithDeltas(), BATCH_SIZE); + batch = BatchBuilder.generateBatchFromParams(createWithDeltas(), BATCH_SIZE); } /// @dev Returns a default-size batch of `Batch.CreateWithDurations` parameters. function batchCreateWithDurations() public view returns (Batch.CreateWithDurations[] memory batch) { - batch = BatchBuilder.fillBatch(createWithDurations(), BATCH_SIZE); + batch = BatchBuilder.generateBatchFromParams(createWithDurations(), BATCH_SIZE); } /// @dev Returns a default-size batch of `Batch.CreateWithMilestones` parameters. @@ -265,7 +265,7 @@ contract Defaults is PermitSignature { view returns (Batch.CreateWithMilestones[] memory batch) { - batch = BatchBuilder.fillBatch(createWithMilestones(), batchSize); + batch = BatchBuilder.generateBatchFromParams(createWithMilestones(), batchSize); } /// @dev Returns a default-size batch of `Batch.CreateWithRange` parameters. @@ -275,6 +275,6 @@ contract Defaults is PermitSignature { /// @dev Returns a batch of `Batch.CreateWithRange` parameters. function batchCreateWithRange(uint256 batchSize) public view returns (Batch.CreateWithRange[] memory batch) { - batch = BatchBuilder.fillBatch(createWithRange(), batchSize); + batch = BatchBuilder.generateBatchFromParams(createWithRange(), batchSize); } } From bb739fd1b49478e3616e075f519576c8bdb68fa9 Mon Sep 17 00:00:00 2001 From: Paul Razvan Berg Date: Mon, 10 Jul 2023 16:06:47 +0300 Subject: [PATCH 2/2] revert: undo nomenclature changes test: separate out event emit tests --- test/Base.t.sol | 32 ++++------- test/fork/plugin/onStreamCanceled.t.sol | 2 +- test/fork/target/batchCancelMultiple.t.sol | 2 +- test/fork/target/batchCreate.t.sol | 6 +- test/integration/archive/list/list.t.sol | 9 ++- test/integration/archive/unlist/unlist.t.sol | 9 ++- test/integration/target/burn/burn.t.sol | 6 +- .../cancel-multiple/cancelMultiple.t.sol | 6 +- test/integration/target/cancel/cancel.t.sol | 6 +- .../target/renounce/renounce.t.sol | 6 +- .../withdrawMaxAndTransfer.t.sol | 6 +- .../target/withdraw-max/withdrawMax.t.sol | 6 +- .../target/withdraw/withdraw.t.sol | 6 +- test/utils/BatchBuilder.sol | 56 +++++++++---------- test/utils/Defaults.sol | 8 +-- 15 files changed, 82 insertions(+), 84 deletions(-) diff --git a/test/Base.t.sol b/test/Base.t.sol index 5c1646d9..1d3e6244 100644 --- a/test/Base.t.sol +++ b/test/Base.t.sol @@ -317,7 +317,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { ) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256Array(response); + return abi.decode(response, (uint256[])); } function batchCreateWithDurations() internal returns (uint256[] memory) { @@ -331,7 +331,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { ) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256Array(response); + return abi.decode(response, (uint256[])); } function batchCreateWithMilestones() internal returns (uint256[] memory) { @@ -345,7 +345,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { ) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256Array(response); + return abi.decode(response, (uint256[])); } function batchCreateWithMilestones(uint256 batchSize) internal returns (uint256[] memory) { @@ -360,7 +360,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { ) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256Array(response); + return abi.decode(response, (uint256[])); } function batchCreateWithRange() internal returns (uint256[] memory) { @@ -374,7 +374,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { ) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256Array(response); + return abi.decode(response, (uint256[])); } function batchCreateWithRange(uint256 batchSize) internal returns (uint256[] memory) { @@ -384,7 +384,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { (lockupLinear, asset, defaults.batchCreateWithRange(batchSize), defaults.permit2Params(totalTransferAmount)) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256Array(response); + return abi.decode(response, (uint256[])); } function createWithDeltas() internal returns (uint256) { @@ -393,7 +393,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { (lockupDynamic, defaults.createWithDeltas(), defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256(response); + return abi.decode(response, (uint256)); } function createWithDurations() internal returns (uint256) { @@ -402,7 +402,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { (lockupLinear, defaults.createWithDurations(), defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256(response); + return abi.decode(response, (uint256)); } function createWithMilestones() internal returns (uint256) { @@ -411,7 +411,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { (lockupDynamic, defaults.createWithMilestones(), defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256(response); + return abi.decode(response, (uint256)); } function createWithMilestones(LockupDynamic.CreateWithMilestones memory params) internal returns (uint256) { @@ -419,7 +419,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { target.createWithMilestones, (lockupDynamic, params, defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256(response); + return abi.decode(response, (uint256)); } function createWithRange() internal returns (uint256) { @@ -428,7 +428,7 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { (lockupLinear, defaults.createWithRange(), defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256(response); + return abi.decode(response, (uint256)); } function createWithRange(LockupLinear.CreateWithRange memory params) internal returns (uint256) { @@ -436,14 +436,6 @@ abstract contract Base_Test is Assertions, Events, StdCheats, V2CoreUtils { target.createWithRange, (lockupLinear, params, defaults.permit2Params(defaults.PER_STREAM_AMOUNT())) ); bytes memory response = aliceProxy.execute(address(target), data); - return decodeAsUint256(response); - } - - function decodeAsUint256(bytes memory input) private pure returns (uint256) { - return abi.decode(input, (uint256)); - } - - function decodeAsUint256Array(bytes memory input) private pure returns (uint256[] memory) { - return abi.decode(input, (uint256[])); + return abi.decode(response, (uint256)); } } diff --git a/test/fork/plugin/onStreamCanceled.t.sol b/test/fork/plugin/onStreamCanceled.t.sol index 017f5ef9..297b468b 100644 --- a/test/fork/plugin/onStreamCanceled.t.sol +++ b/test/fork/plugin/onStreamCanceled.t.sol @@ -9,7 +9,7 @@ import { Fork_Test } from "../Fork.t.sol"; import { Permit2Params } from "src/types/Permit2.sol"; -/// @dev Runs against the asset passed to its constructor. +/// @dev Runs against multiple fork assets. abstract contract OnStreamCanceled_Fork_Test is Fork_Test, PermitSignature { constructor(IERC20 asset_) Fork_Test(asset_) { } diff --git a/test/fork/target/batchCancelMultiple.t.sol b/test/fork/target/batchCancelMultiple.t.sol index 7d108277..385b3fc5 100644 --- a/test/fork/target/batchCancelMultiple.t.sol +++ b/test/fork/target/batchCancelMultiple.t.sol @@ -8,7 +8,7 @@ import { Batch } from "src/types/DataTypes.sol"; import { Fork_Test } from "../Fork.t.sol"; -/// @dev Runs against the asset passed to its constructor. +/// @dev Runs against multiple fork assets. abstract contract BatchCancelMultiple_Fork_Test is Fork_Test { constructor(IERC20 asset_) Fork_Test(asset_) { } diff --git a/test/fork/target/batchCreate.t.sol b/test/fork/target/batchCreate.t.sol index cae59f48..7732918f 100644 --- a/test/fork/target/batchCreate.t.sol +++ b/test/fork/target/batchCreate.t.sol @@ -14,7 +14,7 @@ import { Fork_Test } from "../Fork.t.sol"; import { ArrayBuilder } from "../../utils/ArrayBuilder.sol"; import { BatchBuilder } from "../../utils/BatchBuilder.sol"; -/// @dev Runs against the asset passed to its constructor. +/// @dev Runs against multiple fork assets. abstract contract BatchCreate_Fork_Test is Fork_Test, PermitSignature { constructor(IERC20 asset_) Fork_Test(asset_) { } @@ -54,7 +54,7 @@ abstract contract BatchCreate_Fork_Test is Fork_Test, PermitSignature { range: params.range, totalAmount: params.perStreamAmount }); - Batch.CreateWithRange[] memory batch = BatchBuilder.generateBatchFromParams(createParams, params.batchSize); + Batch.CreateWithRange[] memory batch = BatchBuilder.fillBatch(createParams, params.batchSize); Permit2Params memory permit2Params = defaults.permit2Params({ user: user, spender: address(userProxy), @@ -129,7 +129,7 @@ abstract contract BatchCreate_Fork_Test is Fork_Test, PermitSignature { startTime: params.startTime, totalAmount: params.perStreamAmount }); - Batch.CreateWithMilestones[] memory batch = BatchBuilder.generateBatchFromParams(createWithMilestones, params.batchSize); + Batch.CreateWithMilestones[] memory batch = BatchBuilder.fillBatch(createWithMilestones, params.batchSize); Permit2Params memory permit2Params = defaults.permit2Params({ user: user, spender: address(userProxy), diff --git a/test/integration/archive/list/list.t.sol b/test/integration/archive/list/list.t.sol index 5757f8ab..b8979f3e 100644 --- a/test/integration/archive/list/list.t.sol +++ b/test/integration/archive/list/list.t.sol @@ -29,11 +29,14 @@ contract List_Integration_Test is Integration_Test { } function test_List() external callerAdmin addressNotListed { - vm.expectEmit(); - emit List({ admin: users.admin.addr, addr: address(lockupLinear) }); archive.list(address(lockupLinear)); - bool isListed = archive.isListed(address(lockupLinear)); assertTrue(isListed, "isListed"); } + + function test_List_Event() external callerAdmin addressNotListed { + vm.expectEmit(); + emit List({ admin: users.admin.addr, addr: address(lockupLinear) }); + archive.list(address(lockupLinear)); + } } diff --git a/test/integration/archive/unlist/unlist.t.sol b/test/integration/archive/unlist/unlist.t.sol index cec99d6f..90942913 100644 --- a/test/integration/archive/unlist/unlist.t.sol +++ b/test/integration/archive/unlist/unlist.t.sol @@ -29,11 +29,14 @@ contract Unlist_Integration_Test is Integration_Test { } function test_Unlist() external callerAdmin addressListed { - vm.expectEmit(); - emit Unlist({ admin: users.admin.addr, addr: address(lockupLinear) }); archive.unlist(address(lockupLinear)); - bool isListed = archive.isListed(address(lockupLinear)); assertFalse(isListed, "isListed"); } + + function test_Unlist_Event() external callerAdmin addressListed { + vm.expectEmit({ emitter: address(archive) }); + emit Unlist({ admin: users.admin.addr, addr: address(lockupLinear) }); + archive.unlist(address(lockupLinear)); + } } diff --git a/test/integration/target/burn/burn.t.sol b/test/integration/target/burn/burn.t.sol index 8ed29296..10a99dc4 100644 --- a/test/integration/target/burn/burn.t.sol +++ b/test/integration/target/burn/burn.t.sol @@ -22,17 +22,17 @@ contract Burn_Integration_Test is Integration_Test { LockupDynamic.CreateWithMilestones memory params = defaults.createWithMilestones(); params.recipient = address(aliceProxy); uint256 streamId = createWithMilestones(params); - burn(lockupDynamic, streamId); + test_Burn(lockupDynamic, streamId); } function test_Burn_LockupLinear() external whenDelegateCalled { LockupLinear.CreateWithRange memory params = defaults.createWithRange(); params.recipient = address(aliceProxy); uint256 streamId = createWithRange(params); - burn(lockupLinear, streamId); + test_Burn(lockupLinear, streamId); } - function burn(ISablierV2Lockup lockup, uint256 streamId) internal { + function test_Burn(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.END_TIME()); diff --git a/test/integration/target/cancel-multiple/cancelMultiple.t.sol b/test/integration/target/cancel-multiple/cancelMultiple.t.sol index 0b54bef8..addf1d0c 100644 --- a/test/integration/target/cancel-multiple/cancelMultiple.t.sol +++ b/test/integration/target/cancel-multiple/cancelMultiple.t.sol @@ -23,15 +23,15 @@ contract CancelMultiple_Integration_Test is Integration_Test { function test_CancelMultiple_LockupDynamic() external whenDelegateCalled { uint256[] memory streamIds = batchCreateWithMilestones(); - cancelMultiple(lockupDynamic, streamIds); + test_CancelMultiple(lockupDynamic, streamIds); } function test_CancelMultiple_LockupLinear() external whenDelegateCalled { uint256[] memory streamIds = batchCreateWithRange(); - cancelMultiple(lockupLinear, streamIds); + test_CancelMultiple(lockupLinear, streamIds); } - function cancelMultiple(ISablierV2Lockup lockup, uint256[] memory streamIds) internal { + function test_CancelMultiple(ISablierV2Lockup lockup, uint256[] memory streamIds) internal { // Simulate the passage of time. vm.warp(defaults.CLIFF_TIME()); diff --git a/test/integration/target/cancel/cancel.t.sol b/test/integration/target/cancel/cancel.t.sol index e203e31b..5e2cd5e2 100644 --- a/test/integration/target/cancel/cancel.t.sol +++ b/test/integration/target/cancel/cancel.t.sol @@ -20,15 +20,15 @@ contract Cancel_Integration_Test is Integration_Test { function test_Cancel_LockupDynamic() external whenDelegateCalled { uint256 streamId = createWithMilestones(); - cancel(lockupDynamic, streamId); + test_Cancel(lockupDynamic, streamId); } function test_Cancel_LockupLinear() external whenDelegateCalled { uint256 streamId = createWithRange(); - cancel(lockupLinear, streamId); + test_Cancel(lockupLinear, streamId); } - function cancel(ISablierV2Lockup lockup, uint256 streamId) internal { + function test_Cancel(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.CLIFF_TIME()); diff --git a/test/integration/target/renounce/renounce.t.sol b/test/integration/target/renounce/renounce.t.sol index fe16df0a..bf78ee82 100644 --- a/test/integration/target/renounce/renounce.t.sol +++ b/test/integration/target/renounce/renounce.t.sol @@ -19,15 +19,15 @@ contract Renounce_Integration_Test is Integration_Test { function test_Renounce_LockupDynamic() external whenDelegateCalled { uint256 streamId = createWithMilestones(); - renounce(lockupDynamic, streamId); + test_Renounce(lockupDynamic, streamId); } function test_Renounce_LockupLinear() external whenDelegateCalled { uint256 streamId = createWithRange(); - renounce(lockupLinear, streamId); + test_Renounce(lockupLinear, streamId); } - function renounce(ISablierV2Lockup lockup, uint256 streamId) internal { + function test_Renounce(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.CLIFF_TIME()); diff --git a/test/integration/target/withdraw-max-and-transfer/withdrawMaxAndTransfer.t.sol b/test/integration/target/withdraw-max-and-transfer/withdrawMaxAndTransfer.t.sol index 306bc655..3e6b4473 100644 --- a/test/integration/target/withdraw-max-and-transfer/withdrawMaxAndTransfer.t.sol +++ b/test/integration/target/withdraw-max-and-transfer/withdrawMaxAndTransfer.t.sol @@ -22,17 +22,17 @@ contract WithdrawMaxAndTransfer_Integration_Test is Integration_Test { LockupDynamic.CreateWithMilestones memory params = defaults.createWithMilestones(); params.recipient = address(aliceProxy); uint256 streamId = createWithMilestones(params); - withdrawMaxAndTransfer(lockupDynamic, streamId); + test_WithdrawMaxAndTransfer(lockupDynamic, streamId); } function test_WithdrawMaxAndTransfer_LockupLinear() external whenDelegateCalled { LockupLinear.CreateWithRange memory params = defaults.createWithRange(); params.recipient = address(aliceProxy); uint256 streamId = createWithRange(params); - withdrawMaxAndTransfer(lockupLinear, streamId); + test_WithdrawMaxAndTransfer(lockupLinear, streamId); } - function withdrawMaxAndTransfer(ISablierV2Lockup lockup, uint256 streamId) internal { + function test_WithdrawMaxAndTransfer(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.CLIFF_TIME()); diff --git a/test/integration/target/withdraw-max/withdrawMax.t.sol b/test/integration/target/withdraw-max/withdrawMax.t.sol index 27e7fbf4..b59ac06b 100644 --- a/test/integration/target/withdraw-max/withdrawMax.t.sol +++ b/test/integration/target/withdraw-max/withdrawMax.t.sol @@ -19,15 +19,15 @@ contract WithdrawMax_Integration_Test is Integration_Test { function test_WithdrawMax_LockupDynamic() external whenDelegateCalled { uint256 streamId = createWithMilestones(); - withdrawMax(lockupDynamic, streamId); + test_WithdrawMax(lockupDynamic, streamId); } function test_WithdrawMax_Linear() external whenDelegateCalled { uint256 streamId = createWithRange(); - withdrawMax(lockupLinear, streamId); + test_WithdrawMax(lockupLinear, streamId); } - function withdrawMax(ISablierV2Lockup lockup, uint256 streamId) internal { + function test_WithdrawMax(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.END_TIME()); diff --git a/test/integration/target/withdraw/withdraw.t.sol b/test/integration/target/withdraw/withdraw.t.sol index 68717668..c6ed2311 100644 --- a/test/integration/target/withdraw/withdraw.t.sol +++ b/test/integration/target/withdraw/withdraw.t.sol @@ -19,15 +19,15 @@ contract Withdraw_Integration_Test is Integration_Test { function test_Withdraw_LockupDynamic() external whenDelegateCalled { uint256 streamId = createWithMilestones(); - withdraw(lockupDynamic, streamId); + test_Withdraw(lockupDynamic, streamId); } function test_Withdraw_LockupLinear() external whenDelegateCalled { uint256 streamId = createWithRange(); - withdraw(lockupLinear, streamId); + test_Withdraw(lockupLinear, streamId); } - function withdraw(ISablierV2Lockup lockup, uint256 streamId) internal { + function test_Withdraw(ISablierV2Lockup lockup, uint256 streamId) internal { // Simulate the passage of time. vm.warp(defaults.CLIFF_TIME()); diff --git a/test/utils/BatchBuilder.sol b/test/utils/BatchBuilder.sol index 9282f807..9bbd0ed9 100644 --- a/test/utils/BatchBuilder.sol +++ b/test/utils/BatchBuilder.sol @@ -6,9 +6,9 @@ import { LockupDynamic, LockupLinear } from "@sablier/v2-core/types/DataTypes.so import { Batch } from "../../src/types/DataTypes.sol"; library BatchBuilder { - /// @notice Generates an array containing `batchSize` copies of `sample`. - function generateBatchFromSample( - Batch.CreateWithDeltas memory sample, + /// @notice Generates an array containing `batchSize` copies of `batchSingle`. + function fillBatch( + Batch.CreateWithDeltas memory batchSingle, uint256 batchSize ) internal @@ -18,13 +18,13 @@ library BatchBuilder { batch = new Batch.CreateWithDeltas[](batchSize); unchecked { for (uint256 i = 0; i < batchSize; ++i) { - batch[i] = sample; + batch[i] = batchSingle; } } } /// @notice Turns the `params` into an array of `Batch.CreateWithDeltas` structs. - function generateBatchFromParams( + function fillBatch( LockupDynamic.CreateWithDeltas memory params, uint256 batchSize ) @@ -33,7 +33,7 @@ library BatchBuilder { returns (Batch.CreateWithDeltas[] memory batch) { batch = new Batch.CreateWithDeltas[](batchSize); - Batch.CreateWithDeltas memory sample = Batch.CreateWithDeltas({ + Batch.CreateWithDeltas memory batchSingle = Batch.CreateWithDeltas({ broker: params.broker, cancelable: params.cancelable, recipient: params.recipient, @@ -41,12 +41,12 @@ library BatchBuilder { sender: params.sender, totalAmount: params.totalAmount }); - batch = generateBatchFromSample(sample, batchSize); + batch = fillBatch(batchSingle, batchSize); } - /// @notice Generates an array containing `batchSize` copies of `sample`. - function generateBatchFromSample( - Batch.CreateWithDurations memory sample, + /// @notice Generates an array containing `batchSize` copies of `batchSingle`. + function fillBatch( + Batch.CreateWithDurations memory batchSingle, uint256 batchSize ) internal @@ -56,13 +56,13 @@ library BatchBuilder { batch = new Batch.CreateWithDurations[](batchSize); unchecked { for (uint256 i = 0; i < batchSize; ++i) { - batch[i] = sample; + batch[i] = batchSingle; } } } /// @notice Turns the `params` into an array of `Batch.CreateWithDurations` structs. - function generateBatchFromParams( + function fillBatch( LockupLinear.CreateWithDurations memory params, uint256 batchSize ) @@ -71,7 +71,7 @@ library BatchBuilder { returns (Batch.CreateWithDurations[] memory batch) { batch = new Batch.CreateWithDurations[](batchSize); - Batch.CreateWithDurations memory sample = Batch.CreateWithDurations({ + Batch.CreateWithDurations memory batchSingle = Batch.CreateWithDurations({ broker: params.broker, cancelable: params.cancelable, durations: params.durations, @@ -79,12 +79,12 @@ library BatchBuilder { sender: params.sender, totalAmount: params.totalAmount }); - batch = generateBatchFromSample(sample, batchSize); + batch = fillBatch(batchSingle, batchSize); } - /// @notice Generates an array containing `batchSize` copies of `sample`. - function generateBatchFromSample( - Batch.CreateWithMilestones memory sample, + /// @notice Generates an array containing `batchSize` copies of `batchSingle`. + function fillBatch( + Batch.CreateWithMilestones memory batchSingle, uint256 batchSize ) internal @@ -94,13 +94,13 @@ library BatchBuilder { batch = new Batch.CreateWithMilestones[](batchSize); unchecked { for (uint256 i = 0; i < batchSize; ++i) { - batch[i] = sample; + batch[i] = batchSingle; } } } /// @notice Turns the `params` into an array of `Batch.CreateWithMilestones` structs. - function generateBatchFromParams( + function fillBatch( LockupDynamic.CreateWithMilestones memory params, uint256 batchSize ) @@ -109,7 +109,7 @@ library BatchBuilder { returns (Batch.CreateWithMilestones[] memory batch) { batch = new Batch.CreateWithMilestones[](batchSize); - Batch.CreateWithMilestones memory sample = Batch.CreateWithMilestones({ + Batch.CreateWithMilestones memory batchSingle = Batch.CreateWithMilestones({ broker: params.broker, cancelable: params.cancelable, recipient: params.recipient, @@ -118,12 +118,12 @@ library BatchBuilder { startTime: params.startTime, totalAmount: params.totalAmount }); - batch = generateBatchFromSample(sample, batchSize); + batch = fillBatch(batchSingle, batchSize); } - /// @notice Generates an array containing `batchSize` copies of `sample`. - function generateBatchFromSample( - Batch.CreateWithRange memory sample, + /// @notice Generates an array containing `batchSize` copies of `batchSingle`. + function fillBatch( + Batch.CreateWithRange memory batchSingle, uint256 batchSize ) internal @@ -133,13 +133,13 @@ library BatchBuilder { batch = new Batch.CreateWithRange[](batchSize); unchecked { for (uint256 i = 0; i < batchSize; ++i) { - batch[i] = sample; + batch[i] = batchSingle; } } } /// @notice Turns the `params` into an array of `Batch.CreateWithRange` structs. - function generateBatchFromParams( + function fillBatch( LockupLinear.CreateWithRange memory params, uint256 batchSize ) @@ -148,7 +148,7 @@ library BatchBuilder { returns (Batch.CreateWithRange[] memory batch) { batch = new Batch.CreateWithRange[](batchSize); - Batch.CreateWithRange memory sample = Batch.CreateWithRange({ + Batch.CreateWithRange memory batchSingle = Batch.CreateWithRange({ broker: params.broker, cancelable: params.cancelable, range: params.range, @@ -156,6 +156,6 @@ library BatchBuilder { sender: params.sender, totalAmount: params.totalAmount }); - batch = generateBatchFromSample(sample, batchSize); + batch = fillBatch(batchSingle, batchSize); } } diff --git a/test/utils/Defaults.sol b/test/utils/Defaults.sol index 3f6b9261..13b651b4 100644 --- a/test/utils/Defaults.sol +++ b/test/utils/Defaults.sol @@ -246,12 +246,12 @@ contract Defaults is PermitSignature { /// @dev Returns a default-size batch of `Batch.CreateWithDeltas` parameters. function batchCreateWithDeltas() public view returns (Batch.CreateWithDeltas[] memory batch) { - batch = BatchBuilder.generateBatchFromParams(createWithDeltas(), BATCH_SIZE); + batch = BatchBuilder.fillBatch(createWithDeltas(), BATCH_SIZE); } /// @dev Returns a default-size batch of `Batch.CreateWithDurations` parameters. function batchCreateWithDurations() public view returns (Batch.CreateWithDurations[] memory batch) { - batch = BatchBuilder.generateBatchFromParams(createWithDurations(), BATCH_SIZE); + batch = BatchBuilder.fillBatch(createWithDurations(), BATCH_SIZE); } /// @dev Returns a default-size batch of `Batch.CreateWithMilestones` parameters. @@ -265,7 +265,7 @@ contract Defaults is PermitSignature { view returns (Batch.CreateWithMilestones[] memory batch) { - batch = BatchBuilder.generateBatchFromParams(createWithMilestones(), batchSize); + batch = BatchBuilder.fillBatch(createWithMilestones(), batchSize); } /// @dev Returns a default-size batch of `Batch.CreateWithRange` parameters. @@ -275,6 +275,6 @@ contract Defaults is PermitSignature { /// @dev Returns a batch of `Batch.CreateWithRange` parameters. function batchCreateWithRange(uint256 batchSize) public view returns (Batch.CreateWithRange[] memory batch) { - batch = BatchBuilder.generateBatchFromParams(createWithRange(), batchSize); + batch = BatchBuilder.fillBatch(createWithRange(), batchSize); } }