Skip to content

Commit

Permalink
Update forge-std to v1.8.1 (#865)
Browse files Browse the repository at this point in the history
* build: update forge-std to v1.8.1
build: remove @prb/test dep
test: rename `timestamp` to `newTimestamp` in `vm.warp`
test: declare some functions as `pure` and `view`
test: rename `assumeNoPrecompiles` to `assumeNotPrecompile`
test: use StdAssertions log events
test: define BaseVm contract
test: define MAX_UINT256 in Constants

* test: Use  from forge-std

* test(refactor): rename log names in Assertions

* build: update prb math peer dep version

* chore: address pr feedback

* chore: update bun.lockb file

* test: use CommonBase for vm

* test: deprecate changePrank in favor of resetPrank

---------

Co-authored-by: andreivladbrg <andreivladbrg@gmail.com>
Co-authored-by: Paul Razvan Berg <paul.razvan.berg@gmail.com>
  • Loading branch information
3 people committed Jul 3, 2024
1 parent 4033d95 commit 0bdb88d
Show file tree
Hide file tree
Showing 106 changed files with 355 additions and 375 deletions.
Binary file modified bun.lockb
Binary file not shown.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
},
"dependencies": {
"@openzeppelin/contracts": "5.0.0",
"@prb/math": "4.0.2"
"@prb/math": "github:PaulRBerg/prb-math#a111d11"
},
"devDependencies": {
"@prb/test": "0.6.4",
"@sphinx-labs/plugins": "^0.30.6",
"forge-std": "github:foundry-rs/forge-std#v1.5.6",
"forge-std": "github:foundry-rs/forge-std#v1.8.1",
"prettier": "^2.8.8",
"solady": "0.0.129",
"solarray": "github:evmcheb/solarray#a547630",
Expand Down
1 change: 0 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/
@prb/math/=node_modules/@prb/math/
@prb/test/=node_modules/@prb/test/
@sphinx-labs/contracts/=node_modules/@sphinx-labs/contracts/contracts/foundry
forge-std/=node_modules/forge-std/
solady/=node_modules/solady/
Expand Down
1 change: 0 additions & 1 deletion slither.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"solc_remaps": [
"@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
"@prb/math/=node_modules/@prb-math/",
"@prb/test/=node_modules/@prb/test/",
"forge-std/=node_modules/forge-std/",
"solady/=node_modules/solady/",
"solarray/=node_modules/solarray/"
Expand Down
6 changes: 3 additions & 3 deletions test/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ abstract contract Base_Test is Assertions, Calculations, Constants, DeployOptimi

defaults.setUsers(users);

// Warp to May 1, 2023 at 00:00 GMT to provide a more realistic testing environment.
vm.warp({ timestamp: MAY_1_2023 });
// Warp to May 1, 2024 at 00:00 GMT to provide a more realistic testing environment.
vm.warp({ newTimestamp: MAY_1_2024 });
}

/*//////////////////////////////////////////////////////////////////////////
Expand All @@ -99,7 +99,7 @@ abstract contract Base_Test is Assertions, Calculations, Constants, DeployOptimi

/// @dev Approves all V2 Core contracts to spend assets from the address passed.
function approveProtocol(address from) internal {
changePrank({ msgSender: from });
resetPrank({ msgSender: from });
dai.approve({ spender: address(lockupLinear), value: MAX_UINT256 });
dai.approve({ spender: address(lockupDynamic), value: MAX_UINT256 });
dai.approve({ spender: address(lockupTranched), value: MAX_UINT256 });
Expand Down
2 changes: 1 addition & 1 deletion test/fork/Fork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract contract Fork_Test is Base_Test {
labelContracts();

// Make the ASSET HOLDER the caller in this test suite.
changePrank({ msgSender: HOLDER });
resetPrank({ msgSender: HOLDER });

// Query the initial balance of the ASSET HOLDER.
initialHolderBalance = ASSET.balanceOf(HOLDER);
Expand Down
8 changes: 4 additions & 4 deletions test/fork/LockupDynamic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ abstract contract LockupDynamic_Fork_Test is Fork_Test {
});

// Make the holder the caller.
changePrank(HOLDER);
resetPrank(HOLDER);

/*//////////////////////////////////////////////////////////////////////////
CREATE
Expand Down Expand Up @@ -243,7 +243,7 @@ abstract contract LockupDynamic_Fork_Test is Fork_Test {

// Simulate the passage of time.
params.warpTimestamp = boundUint40(params.warpTimestamp, vars.range.start, vars.range.end + 100 seconds);
vm.warp({ timestamp: params.warpTimestamp });
vm.warp({ newTimestamp: params.warpTimestamp });

// Bound the withdraw amount.
vars.withdrawableAmount = lockupDynamic.withdrawableAmountOf(vars.streamId);
Expand Down Expand Up @@ -272,7 +272,7 @@ abstract contract LockupDynamic_Fork_Test is Fork_Test {
emit MetadataUpdate({ _tokenId: vars.streamId });

// Make the withdrawal.
changePrank({ msgSender: params.recipient });
resetPrank({ msgSender: params.recipient });
lockupDynamic.withdraw({ streamId: vars.streamId, to: params.recipient, amount: params.withdrawAmount });

// Assert that the stream's status is correct.
Expand Down Expand Up @@ -335,7 +335,7 @@ abstract contract LockupDynamic_Fork_Test is Fork_Test {
emit MetadataUpdate({ _tokenId: vars.streamId });

// Cancel the stream.
changePrank({ msgSender: params.sender });
resetPrank({ msgSender: params.sender });
lockupDynamic.cancel(vars.streamId);

// Assert that the stream's status is correct.
Expand Down
8 changes: 4 additions & 4 deletions test/fork/LockupLinear.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ abstract contract LockupLinear_Fork_Test is Fork_Test {
);

// Make the holder the caller.
changePrank(HOLDER);
resetPrank(HOLDER);

/*//////////////////////////////////////////////////////////////////////////
CREATE
Expand Down Expand Up @@ -231,7 +231,7 @@ abstract contract LockupLinear_Fork_Test is Fork_Test {

// Simulate the passage of time.
params.warpTimestamp = boundUint40(params.warpTimestamp, params.range.cliff, params.range.end + 100 seconds);
vm.warp({ timestamp: params.warpTimestamp });
vm.warp({ newTimestamp: params.warpTimestamp });

// Bound the withdraw amount.
vars.withdrawableAmount = lockupLinear.withdrawableAmountOf(vars.streamId);
Expand Down Expand Up @@ -260,7 +260,7 @@ abstract contract LockupLinear_Fork_Test is Fork_Test {
emit MetadataUpdate({ _tokenId: vars.streamId });

// Make the withdrawal.
changePrank({ msgSender: params.recipient });
resetPrank({ msgSender: params.recipient });
lockupLinear.withdraw({ streamId: vars.streamId, to: params.recipient, amount: params.withdrawAmount });

// Assert that the stream's status is correct.
Expand Down Expand Up @@ -321,7 +321,7 @@ abstract contract LockupLinear_Fork_Test is Fork_Test {
emit MetadataUpdate({ _tokenId: vars.streamId });

// Cancel the stream.
changePrank({ msgSender: params.sender });
resetPrank({ msgSender: params.sender });
lockupLinear.cancel(vars.streamId);

// Assert that the stream's status is correct.
Expand Down
8 changes: 4 additions & 4 deletions test/fork/LockupTranched.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ abstract contract LockupTranched_Fork_Test is Fork_Test {
});

// Make the holder the caller.
changePrank(HOLDER);
resetPrank(HOLDER);

/*//////////////////////////////////////////////////////////////////////////
CREATE
Expand Down Expand Up @@ -245,7 +245,7 @@ abstract contract LockupTranched_Fork_Test is Fork_Test {

// Simulate the passage of time.
params.warpTimestamp = boundUint40(params.warpTimestamp, vars.range.start, vars.range.end + 100 seconds);
vm.warp({ timestamp: params.warpTimestamp });
vm.warp({ newTimestamp: params.warpTimestamp });

// Bound the withdraw amount.
vars.withdrawableAmount = lockupTranched.withdrawableAmountOf(vars.streamId);
Expand Down Expand Up @@ -274,7 +274,7 @@ abstract contract LockupTranched_Fork_Test is Fork_Test {
emit MetadataUpdate({ _tokenId: vars.streamId });

// Make the withdrawal.
changePrank({ msgSender: params.recipient });
resetPrank({ msgSender: params.recipient });
lockupTranched.withdraw({ streamId: vars.streamId, to: params.recipient, amount: params.withdrawAmount });

// Assert that the stream's status is correct.
Expand Down Expand Up @@ -337,7 +337,7 @@ abstract contract LockupTranched_Fork_Test is Fork_Test {
emit MetadataUpdate({ _tokenId: vars.streamId });

// Cancel the stream.
changePrank({ msgSender: params.sender });
resetPrank({ msgSender: params.sender });
lockupTranched.cancel(vars.streamId);

// Assert that the stream's status is correct.
Expand Down
4 changes: 2 additions & 2 deletions test/integration/Integration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract contract Integration_Test is Base_Test {
labelContracts();

// Make the Admin the default caller in this test suite.
changePrank({ msgSender: users.admin });
resetPrank({ msgSender: users.admin });
}

/*//////////////////////////////////////////////////////////////////////////
Expand All @@ -51,7 +51,7 @@ abstract contract Integration_Test is Base_Test {
//////////////////////////////////////////////////////////////////////////*/

/// @dev Expects a delegate call error.
function expectRevertDueToDelegateCall(bool success, bytes memory returnData) internal {
function expectRevertDueToDelegateCall(bool success, bytes memory returnData) internal pure {
assertFalse(success, "delegatecall success");
assertEq(returnData, abi.encodeWithSelector(Errors.DelegateCall.selector), "delegatecall return data");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ contract CreateWithTimestamps_LockupDynamic_Integration_Concrete_Test is
whenSegmentTimestampsOrdered
{
uint40 endTime = defaults.END_TIME();
vm.warp({ timestamp: endTime });
vm.warp({ newTimestamp: endTime });
vm.expectRevert(abi.encodeWithSelector(Errors.SablierV2Lockup_EndTimeNotInTheFuture.selector, endTime, endTime));
createDefaultStream();
}
Expand All @@ -218,7 +218,7 @@ contract CreateWithTimestamps_LockupDynamic_Integration_Concrete_Test is
whenEndTimeInTheFuture
{
UD60x18 brokerFee = ZERO;
changePrank({ msgSender: users.sender });
resetPrank({ msgSender: users.sender });

// Adjust the default deposit amount.
uint128 defaultDepositAmount = defaults.DEPOSIT_AMOUNT();
Expand Down Expand Up @@ -280,7 +280,7 @@ contract CreateWithTimestamps_LockupDynamic_Integration_Concrete_Test is
{
address nonContract = address(8128);

changePrank({ msgSender: users.sender });
resetPrank({ msgSender: users.sender });

// Run the test.
vm.expectRevert(abi.encodeWithSelector(Address.AddressEmptyCode.selector, nonContract));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract GetStream_LockupDynamic_Integration_Concrete_Test is LockupDynamic_Inte
}

function test_GetStream_StatusSettled() external givenNotNull {
vm.warp({ timestamp: defaults.END_TIME() });
vm.warp({ newTimestamp: defaults.END_TIME() });
LockupDynamic.StreamLD memory actualStream = lockupDynamic.getStream(defaultStreamId);
LockupDynamic.StreamLD memory expectedStream = defaults.lockupDynamicStream();
expectedStream.isCancelable = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract StreamedAmountOf_LockupDynamic_Integration_Concrete_Test is
givenStreamHasNotBeenCanceled
givenStatusStreaming
{
vm.warp({ timestamp: 0 });
vm.warp({ newTimestamp: 0 });
uint128 actualStreamedAmount = lockupDynamic.streamedAmountOf(defaultStreamId);
uint128 expectedStreamedAmount = 0;
assertEq(actualStreamedAmount, expectedStreamedAmount, "streamedAmount");
Expand All @@ -37,7 +37,7 @@ contract StreamedAmountOf_LockupDynamic_Integration_Concrete_Test is
givenStreamHasNotBeenCanceled
givenStatusStreaming
{
vm.warp({ timestamp: defaults.START_TIME() });
vm.warp({ newTimestamp: defaults.START_TIME() });
uint128 actualStreamedAmount = lockupDynamic.streamedAmountOf(defaultStreamId);
uint128 expectedStreamedAmount = 0;
assertEq(actualStreamedAmount, expectedStreamedAmount, "streamedAmount");
Expand All @@ -51,7 +51,7 @@ contract StreamedAmountOf_LockupDynamic_Integration_Concrete_Test is
whenStartTimeInThePast
{
// Simulate the passage of time.
vm.warp({ timestamp: defaults.START_TIME() + 2000 seconds });
vm.warp({ newTimestamp: defaults.START_TIME() + 2000 seconds });

// Create an array with one segment.
LockupDynamic.Segment[] memory segments = new LockupDynamic.Segment[](1);
Expand Down Expand Up @@ -83,7 +83,7 @@ contract StreamedAmountOf_LockupDynamic_Integration_Concrete_Test is
whenStartTimeInThePast
{
// Warp 1 second to the future.
vm.warp({ timestamp: defaults.START_TIME() + 1 seconds });
vm.warp({ newTimestamp: defaults.START_TIME() + 1 seconds });

// Run the test.
uint128 actualStreamedAmount = lockupDynamic.streamedAmountOf(defaultStreamId);
Expand All @@ -105,7 +105,7 @@ contract StreamedAmountOf_LockupDynamic_Integration_Concrete_Test is
givenCurrentTimestampNot1st
{
// Simulate the passage of time. 750 seconds is ~10% of the way in the second segment.
vm.warp({ timestamp: defaults.START_TIME() + defaults.CLIFF_DURATION() + 750 seconds });
vm.warp({ newTimestamp: defaults.START_TIME() + defaults.CLIFF_DURATION() + 750 seconds });

// Run the test.
uint128 actualStreamedAmount = lockupDynamic.streamedAmountOf(defaultStreamId);
Expand Down
Loading

0 comments on commit 0bdb88d

Please sign in to comment.