Skip to content

Commit

Permalink
lint(test): test files formatted/linted EVM-216
Browse files Browse the repository at this point in the history
  • Loading branch information
benceharomi committed Sep 18, 2023
1 parent b4f1579 commit 6480244
Show file tree
Hide file tree
Showing 20 changed files with 294 additions and 827 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.13;
import "./_AccessMode_Shared.t.sol";

contract DepositLimitTest is AllowListTest {
address l1token = makeAddr("l1token");
address private l1token = makeAddr("l1token");

function test_RevertWhen_NonOwner() public {
vm.expectRevert(abi.encodePacked("Ownable: caller is not the owner"));
Expand All @@ -17,29 +17,17 @@ contract DepositLimitTest is AllowListTest {
vm.prank(owner);
allowList.setDepositLimit(l1token, true, 1000);

IAllowList.Deposit memory deposit = allowList.getTokenDepositLimitData(
l1token
);
assertEq(
deposit.depositLimitation,
true,
"depositLimitation should be true"
);
IAllowList.Deposit memory deposit = allowList.getTokenDepositLimitData(l1token);
assertEq(deposit.depositLimitation, true, "depositLimitation should be true");
assertEq(deposit.depositCap, 1000, "depositCap should be 1000");
}

function test_UnlimitedToken() public {
address unlimitedToken = makeAddr("unlimitedToken");

IAllowList.Deposit memory deposit = allowList.getTokenDepositLimitData(
unlimitedToken
);
IAllowList.Deposit memory deposit = allowList.getTokenDepositLimitData(unlimitedToken);

assertEq(
deposit.depositLimitation,
false,
"depositLimitation should be false"
);
assertEq(deposit.depositLimitation, false, "depositLimitation should be false");
assertEq(deposit.depositCap, 0, "depositCap should be 0");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@ contract SetAccessModeTest is AccessModeTest {
}

function test_AccessModeBefore() public {
bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(
owner,
target,
functionSig
);
assertEq(
hasSpecialAccessToCall,
false,
"hasSpecialAccessToCall should be false"
);
bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(owner, target, functionSig);
assertEq(hasSpecialAccessToCall, false, "hasSpecialAccessToCall should be false");

IAllowList.AccessMode accessMode = allowList.getAccessMode(target);
bool isClosed = accessMode == IAllowList.AccessMode.Closed;
Expand All @@ -48,16 +40,8 @@ contract SetAccessModeTest is AccessModeTest {
vm.prank(owner);
allowList.setAccessMode(target, IAllowList.AccessMode.Public);

bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(
owner,
target,
functionSig
);
assertEq(
hasSpecialAccessToCall,
false,
"hasSpecialAccessToCall should be false"
);
bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(owner, target, functionSig);
assertEq(hasSpecialAccessToCall, false, "hasSpecialAccessToCall should be false");

IAllowList.AccessMode accessMode = allowList.getAccessMode(target);
bool isPublic = accessMode == IAllowList.AccessMode.Public;
Expand All @@ -74,16 +58,8 @@ contract SetAccessModeTest is AccessModeTest {
vm.prank(owner);
allowList.setAccessMode(target, IAllowList.AccessMode.Public);

bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(
owner,
target,
functionSig
);
assertEq(
hasSpecialAccessToCall,
false,
"hasSpecialAccessToCall should be false"
);
bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(owner, target, functionSig);
assertEq(hasSpecialAccessToCall, false, "hasSpecialAccessToCall should be false");

IAllowList.AccessMode accessMode = allowList.getAccessMode(target);
bool isPublic = accessMode == IAllowList.AccessMode.Public;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ contract SetBatchAccessModeTest is AccessModeTest {
targets[0] = target;
targets[1] = target;

IAllowList.AccessMode[]
memory accessModes = new IAllowList.AccessMode[](2);
IAllowList.AccessMode[] memory accessModes = new IAllowList.AccessMode[](2);
accessModes[0] = IAllowList.AccessMode.Public;
accessModes[1] = IAllowList.AccessMode.Public;

Expand All @@ -25,8 +24,7 @@ contract SetBatchAccessModeTest is AccessModeTest {
targets[0] = target;
targets[1] = target;

IAllowList.AccessMode[]
memory accessModes = new IAllowList.AccessMode[](2);
IAllowList.AccessMode[] memory accessModes = new IAllowList.AccessMode[](2);
accessModes[0] = IAllowList.AccessMode.Public;
accessModes[1] = IAllowList.AccessMode.Public;

Expand All @@ -38,8 +36,7 @@ contract SetBatchAccessModeTest is AccessModeTest {
address[] memory targets = new address[](1);
targets[0] = target;

IAllowList.AccessMode[]
memory accessModes = new IAllowList.AccessMode[](2);
IAllowList.AccessMode[] memory accessModes = new IAllowList.AccessMode[](2);
accessModes[0] = IAllowList.AccessMode.Public;
accessModes[1] = IAllowList.AccessMode.Public;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ pragma solidity ^0.8.13;
import "../_AllowList_Shared.t.sol";

contract AccessModeTest is AllowListTest {
address target = 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045;
bytes4 functionSig = 0xdeadbeaf;
address internal target = 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045;
bytes4 internal functionSig = 0xdeadbeaf;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ contract SetBatchPermissionToCall is PermissionTest {

vm.expectRevert("Ownable: caller is not the owner");
vm.prank(randomSigner);
allowList.setBatchPermissionToCall(
callers,
targets,
functionSigs,
enables
);
allowList.setBatchPermissionToCall(callers, targets, functionSigs, enables);
}

function test_Owner() public {
Expand All @@ -50,12 +45,7 @@ contract SetBatchPermissionToCall is PermissionTest {
enables[1] = true;

vm.prank(owner);
allowList.setBatchPermissionToCall(
callers,
targets,
functionSigs,
enables
);
allowList.setBatchPermissionToCall(callers, targets, functionSigs, enables);
}

function test_RevertWhen_ArrayLengthNotEqual() public {
Expand All @@ -76,11 +66,6 @@ contract SetBatchPermissionToCall is PermissionTest {

vm.expectRevert(abi.encodePacked("yw"));
vm.prank(owner);
allowList.setBatchPermissionToCall(
callers,
targets,
functionSigs,
enables
);
allowList.setBatchPermissionToCall(callers, targets, functionSigs, enables);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@ contract SetPermissionToCallTest is PermissionTest {
}

function test_PermissionBefore() public {
bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(
randomSigner,
target,
functionSig
);
assertEq(
hasSpecialAccessToCall,
false,
"hasSpecialAccessToCall should be false"
);
bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(randomSigner, target, functionSig);
assertEq(hasSpecialAccessToCall, false, "hasSpecialAccessToCall should be false");

IAllowList.AccessMode accessMode = allowList.getAccessMode(target);
bool isClosed = accessMode == IAllowList.AccessMode.Closed;
Expand All @@ -47,16 +39,8 @@ contract SetPermissionToCallTest is PermissionTest {
function test_PermissionAfter() public {
vm.prank(owner);
allowList.setPermissionToCall(randomSigner, target, functionSig, true);
bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(
randomSigner,
target,
functionSig
);
assertEq(
hasSpecialAccessToCall,
true,
"hasSpecialAccessToCall should be true"
);
bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(randomSigner, target, functionSig);
assertEq(hasSpecialAccessToCall, true, "hasSpecialAccessToCall should be true");

IAllowList.AccessMode accessMode = allowList.getAccessMode(target);
bool isClosed = accessMode == IAllowList.AccessMode.Closed;
Expand All @@ -69,25 +53,13 @@ contract SetPermissionToCallTest is PermissionTest {
function test_RemovePermission() public {
vm.prank(owner);
allowList.setPermissionToCall(randomSigner, target, functionSig, true);
bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(
randomSigner,
target,
functionSig
);
bool hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(randomSigner, target, functionSig);
assertEq(hasSpecialAccessToCall, true, "should be true");

vm.prank(owner);
allowList.setPermissionToCall(randomSigner, target, functionSig, false);

hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(
randomSigner,
target,
functionSig
);
assertEq(
hasSpecialAccessToCall,
false,
"hasSpecialAccessToCall should be false"
);
hasSpecialAccessToCall = allowList.hasSpecialAccessToCall(randomSigner, target, functionSig);
assertEq(hasSpecialAccessToCall, false, "hasSpecialAccessToCall should be false");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ pragma solidity ^0.8.13;
import "../_AllowList_Shared.t.sol";

contract PermissionTest is AllowListTest {
address target = 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045;
bytes4 functionSig = 0x1626ba7e;
address internal target = 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045;
bytes4 internal functionSig = 0x1626ba7e;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import "../../../../../cache/solpp-generated-contracts/common/AllowList.sol";
import "../../../../../cache/solpp-generated-contracts/common/interfaces/IAllowList.sol";

contract AllowListTest is Test {
AllowList allowList;
address owner = makeAddr("owner");
address randomSigner = makeAddr("randomSigner");
AllowList internal allowList;
address internal owner = makeAddr("owner");
address internal randomSigner = makeAddr("randomSigner");

function setUp() public {
allowList = new AllowList(owner);
Expand Down
36 changes: 10 additions & 26 deletions ethereum/test/foundry/unit/concrete/DiamondCut/FacetCut.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import "../../../../../cache/solpp-generated-contracts/zksync/facets/Mailbox.sol
import "../../../../../cache/solpp-generated-contracts/zksync/facets/Executor.sol";

contract FacetCutTest is DiamondCutTest {
MailboxFacet mailboxFacet;
ExecutorFacet executorFacet1;
ExecutorFacet executorFacet2;
MailboxFacet private mailboxFacet;
ExecutorFacet private executorFacet1;
ExecutorFacet private executorFacet2;

function getMailboxSelectors() private view returns (bytes4[] memory) {
bytes4[] memory selectors = new bytes4[](6);
Expand Down Expand Up @@ -65,21 +65,13 @@ contract FacetCutTest is DiamondCutTest {
initCalldata: bytes("")
});

uint256 numOfFacetsBefore = diamondCutTestContract
.facetAddresses()
.length;
uint256 numOfFacetsBefore = diamondCutTestContract.facetAddresses().length;

diamondCutTestContract.diamondCut(diamondCutData);

uint256 numOfFacetsAfter = diamondCutTestContract
.facetAddresses()
.length;
uint256 numOfFacetsAfter = diamondCutTestContract.facetAddresses().length;

assertEq(
numOfFacetsBefore + facetCuts.length,
numOfFacetsAfter,
"wrong number of facets added"
);
assertEq(numOfFacetsBefore + facetCuts.length, numOfFacetsAfter, "wrong number of facets added");
}

function test_RevertWhen_AddingFacetToOccupiedSelector() public {
Expand Down Expand Up @@ -258,9 +250,7 @@ contract FacetCutTest is DiamondCutTest {

diamondCutTestContract.diamondCut(diamondCutData1);

uint256 numOfFacetsAfterAdd = diamondCutTestContract
.facetAddresses()
.length;
uint256 numOfFacetsAfterAdd = diamondCutTestContract.facetAddresses().length;

Diamond.FacetCut[] memory facetCuts2 = new Diamond.FacetCut[](1);
facetCuts2[0] = Diamond.FacetCut({
Expand All @@ -278,16 +268,12 @@ contract FacetCutTest is DiamondCutTest {

diamondCutTestContract.diamondCut(diamondCutData2);

uint256 numOfFacetsAfterReplace = diamondCutTestContract
.facetAddresses()
.length;
uint256 numOfFacetsAfterReplace = diamondCutTestContract.facetAddresses().length;

assertEq(numOfFacetsAfterAdd, numOfFacetsAfterReplace);
}

function test_RevertWhen_AddingFacetWithDifferentFreezabilityThanExistingFacets()
public
{
function test_RevertWhen_AddingFacetWithDifferentFreezabilityThanExistingFacets() public {
bytes4[] memory selectors1 = new bytes4[](1);
selectors1[0] = 0x00000001;

Expand Down Expand Up @@ -318,9 +304,7 @@ contract FacetCutTest is DiamondCutTest {
diamondCutTestContract.diamondCut(diamondCutData);
}

function test_RevertWhen_ReplacingFacetWithDifferentFreezabilityThanExistingFacets()
public
{
function test_RevertWhen_ReplacingFacetWithDifferentFreezabilityThanExistingFacets() public {
bytes4[] memory selectors1 = new bytes4[](1);
selectors1[0] = 0x00000001;
bytes4[] memory selectors2 = new bytes4[](1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import "../../../../../cache/solpp-generated-contracts/dev-contracts/RevertFallb
import "../../../../../cache/solpp-generated-contracts/dev-contracts/ReturnSomething.sol";

contract InitializationTest is DiamondCutTest {
address revertFallbackAddress;
address returnSomethingAddress;
address signerAddress; // EOA
address private revertFallbackAddress;
address private returnSomethingAddress;
address private signerAddress; // EOA

function setUp() public {
signerAddress = makeAddr("signer");
Expand Down Expand Up @@ -43,9 +43,7 @@ contract InitializationTest is DiamondCutTest {
diamondCutTestContract.diamondCut(diamondCutData);
}

function test_RevertWhen_InitializingDiamondCutWithZeroAddressAndNonZeroData()
public
{
function test_RevertWhen_InitializingDiamondCutWithZeroAddressAndNonZeroData() public {
Diamond.FacetCut[] memory facetCuts = new Diamond.FacetCut[](0);

Diamond.DiamondCutData memory diamondCutData = Diamond.DiamondCutData({
Expand Down
Loading

0 comments on commit 6480244

Please sign in to comment.