Skip to content

Commit

Permalink
test: rename "_storage" contract to "store"
Browse files Browse the repository at this point in the history
test: improve wording in comments
  • Loading branch information
andreivladbrg committed Feb 6, 2023
1 parent 06fa329 commit eb54856
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions test/invariant/Invariant.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ abstract contract Invariant_Test is Base_Test, ForgeInvariantTest {
// Target only the comptroller handler for invariant testing (to avoid getting reverts).
targetContract(address(comptrollerHandler));

// Exclude the comptroller, linear and pro for being the `msg.sender`.
// Exclude the comptroller, linear and pro from being the `msg.sender`.
excludeSender(address(comptroller));
excludeSender(address(linear));
excludeSender(address(pro));

// Exclude the comptroller handler for being the `msg.sender`.
// Exclude the comptroller handler from being the `msg.sender`.
excludeSender(address(comptrollerHandler));

// Label the comptroller handler.
Expand Down
24 changes: 12 additions & 12 deletions test/invariant/handlers/LockupHandler.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract contract LockupHandler is BaseHandler {

IERC20 public asset;
ISablierV2Lockup public lockup;
LockupHandlerStorage public _storage;
LockupHandlerStorage public store;

/*//////////////////////////////////////////////////////////////////////////
PRIVATE TEST VARIABLES
Expand All @@ -32,10 +32,10 @@ abstract contract LockupHandler is BaseHandler {
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////*/

constructor(IERC20 asset_, ISablierV2Lockup lockup_, LockupHandlerStorage _storage_) {
constructor(IERC20 asset_, ISablierV2Lockup lockup_, LockupHandlerStorage store_) {
asset = asset_;
lockup = lockup_;
_storage = _storage_;
store = store_;
}

/*//////////////////////////////////////////////////////////////////////////
Expand All @@ -50,24 +50,24 @@ abstract contract LockupHandler is BaseHandler {
}

modifier useFuzzedStreamRecipient(uint256 streamIndexSeed) {
uint256 lastStreamId = _storage.lastStreamId();
uint256 lastStreamId = store.lastStreamId();
if (lastStreamId == 0) {
return;
}
currentStreamId = _storage.streamIds(bound(streamIndexSeed, 0, lastStreamId - 1));
currentRecipient = _storage.streamIdsToRecipients(currentStreamId);
currentStreamId = store.streamIds(bound(streamIndexSeed, 0, lastStreamId - 1));
currentRecipient = store.streamIdsToRecipients(currentStreamId);
vm.startPrank(currentRecipient);
_;
vm.stopPrank();
}

modifier useFuzzedStreamSender(uint256 streamIndexSeed) {
uint256 lastStreamId = _storage.lastStreamId();
uint256 lastStreamId = store.lastStreamId();
if (lastStreamId == 0) {
return;
}
currentStreamId = _storage.streamIds(bound(streamIndexSeed, 0, lastStreamId - 1));
currentSender = _storage.streamIdsToSenders(currentStreamId);
currentStreamId = store.streamIds(bound(streamIndexSeed, 0, lastStreamId - 1));
currentSender = store.streamIdsToSenders(currentStreamId);
vm.startPrank(currentSender);
_;
vm.stopPrank();
Expand All @@ -93,7 +93,7 @@ abstract contract LockupHandler is BaseHandler {
lockup.burn(currentStreamId);

// Set the recipient associated with this stream to the zero address.
_storage.updateRecipient(currentStreamId, address(0));
store.updateRecipient(currentStreamId, address(0));
}

function cancel(uint256 streamIndexSeed) external instrument("cancel") useFuzzedStreamSender(streamIndexSeed) {
Expand All @@ -106,7 +106,7 @@ abstract contract LockupHandler is BaseHandler {
// Record the returned amount by adding it to the ghost variable `returnedAmountsSum`. This is needed to
// check invariants against the contract's balance.
uint128 returnedAmount = lockup.returnableAmountOf(currentStreamId);
_storage.addReturnedAmount(returnedAmount);
store.addReturnedAmount(returnedAmount);

// Cancel the stream.
lockup.cancel(currentStreamId);
Expand Down Expand Up @@ -210,6 +210,6 @@ abstract contract LockupHandler is BaseHandler {
lockup.transferFrom({ from: currentRecipient, to: newRecipient, tokenId: currentStreamId });

// Update the recipient associated with this stream id.
_storage.updateRecipient(currentStreamId, newRecipient);
store.updateRecipient(currentStreamId, newRecipient);
}
}
14 changes: 7 additions & 7 deletions test/invariant/handlers/LockupLinearCreateHandler.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ contract LockupLinearCreateHandler is BaseHandler {
//////////////////////////////////////////////////////////////////////////*/

IERC20 public asset;
LockupHandlerStorage public _storage;
LockupHandlerStorage public store;

/*//////////////////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////*/

constructor(IERC20 asset_, ISablierV2LockupLinear linear_, LockupHandlerStorage _storage_) {
constructor(IERC20 asset_, ISablierV2LockupLinear linear_, LockupHandlerStorage store_) {
asset = asset_;
linear = linear_;
_storage = _storage_;
store = store_;
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -68,7 +68,7 @@ contract LockupLinearCreateHandler is BaseHandler {
params.totalAmount = boundUint128(params.totalAmount, 1, 1_000_000_000e18);

// We don't want to fuzz more than a certain number of streams.
if (_storage.lastStreamId() >= MAX_STREAM_COUNT) {
if (store.lastStreamId() >= MAX_STREAM_COUNT) {
return;
}

Expand All @@ -95,7 +95,7 @@ contract LockupLinearCreateHandler is BaseHandler {
});

// Store the stream id.
_storage.pushStreamId(streamId, params.sender, params.recipient);
store.pushStreamId(streamId, params.sender, params.recipient);
}

struct CreateWithRangeParams {
Expand All @@ -117,7 +117,7 @@ contract LockupLinearCreateHandler is BaseHandler {
params.totalAmount = boundUint128(params.totalAmount, 1, 1_000_000_000e18);

// We don't want to fuzz more than a certain number of streams.
if (_storage.lastStreamId() >= MAX_STREAM_COUNT) {
if (store.lastStreamId() >= MAX_STREAM_COUNT) {
return;
}

Expand All @@ -144,6 +144,6 @@ contract LockupLinearCreateHandler is BaseHandler {
});

// Store the stream id.
_storage.pushStreamId(streamId, params.sender, params.recipient);
store.pushStreamId(streamId, params.sender, params.recipient);
}
}
4 changes: 2 additions & 2 deletions test/invariant/handlers/LockupLinearHandler.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ contract LockupLinearHandler is LockupHandler {
constructor(
IERC20 asset_,
ISablierV2LockupLinear linear_,
LockupHandlerStorage _storage_
) LockupHandler(asset_, linear_, _storage_) {}
LockupHandlerStorage store_
) LockupHandler(asset_, linear_, store_) {}
}
14 changes: 7 additions & 7 deletions test/invariant/handlers/LockupProCreateHandler.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract LockupProCreateHandler is BaseHandler {
//////////////////////////////////////////////////////////////////////////*/

IERC20 public asset;
LockupHandlerStorage public _storage;
LockupHandlerStorage public store;

/*//////////////////////////////////////////////////////////////////////////
CONSTRUCTOR
Expand All @@ -37,12 +37,12 @@ contract LockupProCreateHandler is BaseHandler {
IERC20 asset_,
ISablierV2Comptroller comptroller_,
ISablierV2LockupPro pro_,
LockupHandlerStorage _storage_
LockupHandlerStorage store_
) {
asset = asset_;
comptroller = comptroller_;
pro = pro_;
_storage = _storage_;
store = store_;
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -86,7 +86,7 @@ contract LockupProCreateHandler is BaseHandler {
params.totalAmount = boundUint128(params.totalAmount, 1, 1_000_000_000e18);

// We don't want to fuzz more than a certain number of streams.
if (_storage.lastStreamId() > MAX_STREAM_COUNT) {
if (store.lastStreamId() > MAX_STREAM_COUNT) {
return;
}

Expand Down Expand Up @@ -129,7 +129,7 @@ contract LockupProCreateHandler is BaseHandler {
});

// Store the stream id.
_storage.pushStreamId(vars.streamId, params.sender, params.recipient);
store.pushStreamId(vars.streamId, params.sender, params.recipient);
}

struct CreateWithMilestonesParams {
Expand All @@ -156,7 +156,7 @@ contract LockupProCreateHandler is BaseHandler {
params.totalAmount = boundUint128(params.totalAmount, 1, 1_000_000_000e18);

// We don't want to fuzz more than a certain number of streams.
if (_storage.lastStreamId() >= MAX_STREAM_COUNT) {
if (store.lastStreamId() >= MAX_STREAM_COUNT) {
return;
}

Expand Down Expand Up @@ -195,6 +195,6 @@ contract LockupProCreateHandler is BaseHandler {
});

// Store the stream id.
_storage.pushStreamId(vars.streamId, params.sender, params.recipient);
store.pushStreamId(vars.streamId, params.sender, params.recipient);
}
}
4 changes: 2 additions & 2 deletions test/invariant/handlers/LockupProHandler.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ contract LockupProHandler is LockupHandler {
constructor(
IERC20 asset_,
ISablierV2LockupPro pro_,
LockupHandlerStorage _storage_
) LockupHandler(asset_, pro_, _storage_) {}
LockupHandlerStorage store_
) LockupHandler(asset_, pro_, store_) {}
}
2 changes: 1 addition & 1 deletion test/invariant/lockup/Lockup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract contract Lockup_Invariant_Test is Invariant_Test {
// Deploy the lockupHandlerStorage.
lockupHandlerStorage = new LockupHandlerStorage();

// Exclude the lockup handler store for being the `msg.sender`.
// Exclude the lockup handler store from being the `msg.sender`.
excludeSender(address(lockupHandlerStorage));
}

Expand Down
6 changes: 3 additions & 3 deletions test/invariant/lockup/linear/Linear.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ contract Linear_Invariant_Test is Lockup_Invariant_Test {
linearHandler = new LockupLinearHandler({
asset_: DEFAULT_ASSET,
linear_: linear,
_storage_: lockupHandlerStorage
store_: lockupHandlerStorage
});
linearCreateHandler = new LockupLinearCreateHandler({
asset_: DEFAULT_ASSET,
linear_: linear,
_storage_: lockupHandlerStorage
store_: lockupHandlerStorage
});

// Cast the linear contract as {SablierV2Lockup} and the linear handler as {LockupHandler}.
Expand All @@ -58,7 +58,7 @@ contract Linear_Invariant_Test is Lockup_Invariant_Test {
targetContract(address(linearHandler));
targetContract(address(linearCreateHandler));

// Exclude the linear handlers for being the `msg.sender`.
// Exclude the linear handlers from being the `msg.sender`.
excludeSender(address(flashLoanHandler));
excludeSender(address(linearHandler));
excludeSender(address(linearCreateHandler));
Expand Down
6 changes: 3 additions & 3 deletions test/invariant/lockup/pro/Pro.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ contract Pro_Invariant_Test is Lockup_Invariant_Test {
Lockup_Invariant_Test.setUp();

// Deploy the pro contract handlers.
proHandler = new LockupProHandler({ asset_: DEFAULT_ASSET, pro_: pro, _storage_: lockupHandlerStorage });
proHandler = new LockupProHandler({ asset_: DEFAULT_ASSET, pro_: pro, store_: lockupHandlerStorage });
proCreateHandler = new LockupProCreateHandler({
asset_: DEFAULT_ASSET,
comptroller_: comptroller,
pro_: pro,
_storage_: lockupHandlerStorage
store_: lockupHandlerStorage
});

// Cast the pro contract as {SablierV2Lockup} and the pro handler as {LockupHandler}.
Expand All @@ -55,7 +55,7 @@ contract Pro_Invariant_Test is Lockup_Invariant_Test {
targetContract(address(proHandler));
targetContract(address(proCreateHandler));

// Exclude the pro handlers for being the `msg.sender`.
// Exclude the pro handlers from being the `msg.sender`.
excludeSender(address(flashLoanHandler));
excludeSender(address(proHandler));
excludeSender(address(proCreateHandler));
Expand Down

0 comments on commit eb54856

Please sign in to comment.