From 6480244996e5654988a357ee061573e5bc1f4e7c Mon Sep 17 00:00:00 2001 From: Bence Haromi Date: Mon, 18 Sep 2023 12:54:56 +0100 Subject: [PATCH] lint(test): test files formatted/linted EVM-216 --- .../AllowList/AccessMode/DepositLimit.t.sol | 22 +- .../AllowList/AccessMode/SetAccessMode.t.sol | 36 +- .../AccessMode/SetBatchAccessMode.t.sol | 9 +- .../AccessMode/_AccessMode_Shared.t.sol | 4 +- .../Permission/SetBatchPermissionToCall.t.sol | 21 +- .../Permission/SetPermissionToCall.t.sol | 42 +- .../Permission/_Permission_Shared.t.sol | 4 +- .../AllowList/_AllowList_Shared.t.sol | 6 +- .../unit/concrete/DiamondCut/FacetCut.t.sol | 36 +- .../concrete/DiamondCut/Initialization.t.sol | 10 +- .../concrete/DiamondCut/UpgradeLogic.t.sol | 176 +++----- .../DiamondCut/_DiamondCut_Shared.t.sol | 4 +- .../concrete/Executor/Authorization.t.sol | 13 +- .../unit/concrete/Executor/Committing.t.sol | 405 +++++------------- .../unit/concrete/Executor/Executing.t.sol | 166 ++----- .../unit/concrete/Executor/Proving.t.sol | 54 +-- .../unit/concrete/Executor/Reverting.t.sol | 17 +- .../concrete/Executor/_Executor_Shared.t.sol | 59 +-- .../concrete/UnsafeBytes/UnsafeBytes.t.sol | 32 +- .../foundry/unit/concrete/Utils/Utils.t.sol | 5 +- 20 files changed, 294 insertions(+), 827 deletions(-) diff --git a/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/DepositLimit.t.sol b/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/DepositLimit.t.sol index 51320cd454..68551fce86 100644 --- a/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/DepositLimit.t.sol +++ b/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/DepositLimit.t.sol @@ -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")); @@ -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"); } } diff --git a/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/SetAccessMode.t.sol b/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/SetAccessMode.t.sol index 14831d82c6..9c008a77f8 100644 --- a/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/SetAccessMode.t.sol +++ b/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/SetAccessMode.t.sol @@ -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; @@ -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; @@ -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; diff --git a/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/SetBatchAccessMode.t.sol b/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/SetBatchAccessMode.t.sol index 45860490a3..93b6a43683 100644 --- a/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/SetBatchAccessMode.t.sol +++ b/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/SetBatchAccessMode.t.sol @@ -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; @@ -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; @@ -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; diff --git a/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/_AccessMode_Shared.t.sol b/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/_AccessMode_Shared.t.sol index 8623af75a3..6b097f4466 100644 --- a/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/_AccessMode_Shared.t.sol +++ b/ethereum/test/foundry/unit/concrete/AllowList/AccessMode/_AccessMode_Shared.t.sol @@ -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; } diff --git a/ethereum/test/foundry/unit/concrete/AllowList/Permission/SetBatchPermissionToCall.t.sol b/ethereum/test/foundry/unit/concrete/AllowList/Permission/SetBatchPermissionToCall.t.sol index 2db769455f..d3c0d7497d 100644 --- a/ethereum/test/foundry/unit/concrete/AllowList/Permission/SetBatchPermissionToCall.t.sol +++ b/ethereum/test/foundry/unit/concrete/AllowList/Permission/SetBatchPermissionToCall.t.sol @@ -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 { @@ -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 { @@ -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); } } diff --git a/ethereum/test/foundry/unit/concrete/AllowList/Permission/SetPermissionToCall.t.sol b/ethereum/test/foundry/unit/concrete/AllowList/Permission/SetPermissionToCall.t.sol index 435477a093..6395d93fb6 100644 --- a/ethereum/test/foundry/unit/concrete/AllowList/Permission/SetPermissionToCall.t.sol +++ b/ethereum/test/foundry/unit/concrete/AllowList/Permission/SetPermissionToCall.t.sol @@ -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; @@ -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; @@ -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"); } } diff --git a/ethereum/test/foundry/unit/concrete/AllowList/Permission/_Permission_Shared.t.sol b/ethereum/test/foundry/unit/concrete/AllowList/Permission/_Permission_Shared.t.sol index 4e6b7d3d2a..dcf03c46f7 100644 --- a/ethereum/test/foundry/unit/concrete/AllowList/Permission/_Permission_Shared.t.sol +++ b/ethereum/test/foundry/unit/concrete/AllowList/Permission/_Permission_Shared.t.sol @@ -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; } diff --git a/ethereum/test/foundry/unit/concrete/AllowList/_AllowList_Shared.t.sol b/ethereum/test/foundry/unit/concrete/AllowList/_AllowList_Shared.t.sol index b0bd1a3216..030319af2a 100644 --- a/ethereum/test/foundry/unit/concrete/AllowList/_AllowList_Shared.t.sol +++ b/ethereum/test/foundry/unit/concrete/AllowList/_AllowList_Shared.t.sol @@ -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); diff --git a/ethereum/test/foundry/unit/concrete/DiamondCut/FacetCut.t.sol b/ethereum/test/foundry/unit/concrete/DiamondCut/FacetCut.t.sol index e2541c8899..ad8ce1ec6e 100644 --- a/ethereum/test/foundry/unit/concrete/DiamondCut/FacetCut.t.sol +++ b/ethereum/test/foundry/unit/concrete/DiamondCut/FacetCut.t.sol @@ -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); @@ -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 { @@ -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({ @@ -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; @@ -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); diff --git a/ethereum/test/foundry/unit/concrete/DiamondCut/Initialization.t.sol b/ethereum/test/foundry/unit/concrete/DiamondCut/Initialization.t.sol index 59d5e5d421..3185896ef8 100644 --- a/ethereum/test/foundry/unit/concrete/DiamondCut/Initialization.t.sol +++ b/ethereum/test/foundry/unit/concrete/DiamondCut/Initialization.t.sol @@ -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"); @@ -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({ diff --git a/ethereum/test/foundry/unit/concrete/DiamondCut/UpgradeLogic.t.sol b/ethereum/test/foundry/unit/concrete/DiamondCut/UpgradeLogic.t.sol index 068901b03b..6925e053aa 100644 --- a/ethereum/test/foundry/unit/concrete/DiamondCut/UpgradeLogic.t.sol +++ b/ethereum/test/foundry/unit/concrete/DiamondCut/UpgradeLogic.t.sol @@ -7,13 +7,13 @@ import "../../../../../cache/solpp-generated-contracts/zksync/DiamondInit.sol"; import "../../../../../cache/solpp-generated-contracts/zksync/facets/DiamondCut.sol"; contract UpgradeLogicTest is DiamondCutTest { - DiamondProxy diamondProxy; - DiamondInit diamondInit; - DiamondCutFacet diamondCutFacet; - DiamondCutFacet proxyAsDiamondCut; - GettersFacet proxyAsGetters; - address governor; - address randomSigner; + DiamondProxy private diamondProxy; + DiamondInit private diamondInit; + DiamondCutFacet private diamondCutFacet; + DiamondCutFacet private proxyAsDiamondCut; + GettersFacet private proxyAsGetters; + address private governor; + address private randomSigner; function getDiamondCutSelectors() private view returns (bytes4[] memory) { bytes4[] memory dcSelectors = new bytes4[](8); @@ -106,9 +106,7 @@ contract UpgradeLogicTest is DiamondCutTest { proxyAsDiamondCut.unfreezeDiamond(); } - function test_RevertWhen_ExecutingUnapprovedProposalWHenDiamondStorageIsFrozen() - public - { + function test_RevertWhen_ExecutingUnapprovedProposalWHenDiamondStorageIsFrozen() public { vm.startPrank(governor); proxyAsDiamondCut.freezeDiamond(); @@ -133,9 +131,7 @@ contract UpgradeLogicTest is DiamondCutTest { proxyAsDiamondCut.executeUpgrade(diamondCutData, 0); } - function test_RevertWhen_ExecutingProposalWithDifferentInitAddress() - public - { + function test_RevertWhen_ExecutingProposalWithDifferentInitAddress() public { Diamond.FacetCut[] memory facetCuts = new Diamond.FacetCut[](1); facetCuts[0] = Diamond.FacetCut({ facet: address(gettersFacet), @@ -144,30 +140,23 @@ contract UpgradeLogicTest is DiamondCutTest { selectors: getGettersSelectors() }); - Diamond.DiamondCutData memory proposedDiamondCutData = Diamond - .DiamondCutData({ - facetCuts: facetCuts, - initAddress: address(0), - initCalldata: bytes("") - }); - - Diamond.DiamondCutData memory executedDiamondCutData = Diamond - .DiamondCutData({ - facetCuts: facetCuts, - initAddress: address(1), - initCalldata: bytes("") - }); - - uint40 nextProposalId = uint40( - proxyAsGetters.getCurrentProposalId() + 1 - ); + Diamond.DiamondCutData memory proposedDiamondCutData = Diamond.DiamondCutData({ + facetCuts: facetCuts, + initAddress: address(0), + initCalldata: bytes("") + }); + + Diamond.DiamondCutData memory executedDiamondCutData = Diamond.DiamondCutData({ + facetCuts: facetCuts, + initAddress: address(1), + initCalldata: bytes("") + }); + + uint40 nextProposalId = uint40(proxyAsGetters.getCurrentProposalId() + 1); vm.startPrank(governor); - proxyAsDiamondCut.proposeTransparentUpgrade( - proposedDiamondCutData, - nextProposalId - ); + proxyAsDiamondCut.proposeTransparentUpgrade(proposedDiamondCutData, nextProposalId); vm.expectRevert(abi.encodePacked("a4")); proxyAsDiamondCut.executeUpgrade(executedDiamondCutData, 0); @@ -196,22 +185,16 @@ contract UpgradeLogicTest is DiamondCutTest { initCalldata: bytes("") }); - Diamond.DiamondCutData memory invalidDiamondCutData = Diamond - .DiamondCutData({ - facetCuts: invalidFacetCuts, - initAddress: address(0), - initCalldata: bytes("") - }); + Diamond.DiamondCutData memory invalidDiamondCutData = Diamond.DiamondCutData({ + facetCuts: invalidFacetCuts, + initAddress: address(0), + initCalldata: bytes("") + }); - uint40 nextProposalId = uint40( - proxyAsGetters.getCurrentProposalId() + 1 - ); + uint40 nextProposalId = uint40(proxyAsGetters.getCurrentProposalId() + 1); vm.startPrank(governor); - proxyAsDiamondCut.proposeTransparentUpgrade( - diamondCutData, - nextProposalId - ); + proxyAsDiamondCut.proposeTransparentUpgrade(diamondCutData, nextProposalId); vm.expectRevert(abi.encodePacked("a4")); proxyAsDiamondCut.executeUpgrade(invalidDiamondCutData, 0); @@ -241,16 +224,11 @@ contract UpgradeLogicTest is DiamondCutTest { initCalldata: bytes("") }); - uint40 nextProposalId = uint40( - proxyAsGetters.getCurrentProposalId() + 1 - ); + uint40 nextProposalId = uint40(proxyAsGetters.getCurrentProposalId() + 1); vm.startPrank(governor); - proxyAsDiamondCut.proposeTransparentUpgrade( - diamondCutData, - nextProposalId - ); + proxyAsDiamondCut.proposeTransparentUpgrade(diamondCutData, nextProposalId); proxyAsDiamondCut.executeUpgrade(diamondCutData, 0); @@ -281,16 +259,11 @@ contract UpgradeLogicTest is DiamondCutTest { initCalldata: bytes("") }); - uint40 nextProposalId = uint40( - proxyAsGetters.getCurrentProposalId() + 1 - ); + uint40 nextProposalId = uint40(proxyAsGetters.getCurrentProposalId() + 1); vm.startPrank(governor); - proxyAsDiamondCut.proposeTransparentUpgrade( - diamondCutData, - nextProposalId - ); + proxyAsDiamondCut.proposeTransparentUpgrade(diamondCutData, nextProposalId); proxyAsDiamondCut.executeUpgrade(diamondCutData, 0); @@ -313,22 +286,14 @@ contract UpgradeLogicTest is DiamondCutTest { initCalldata: bytes("") }); - uint40 nextProposalId = uint40( - proxyAsGetters.getCurrentProposalId() + 1 - ); + uint40 nextProposalId = uint40(proxyAsGetters.getCurrentProposalId() + 1); vm.startPrank(governor); - proxyAsDiamondCut.proposeTransparentUpgrade( - diamondCutData, - nextProposalId - ); + proxyAsDiamondCut.proposeTransparentUpgrade(diamondCutData, nextProposalId); vm.expectRevert(abi.encodePacked("a8")); - proxyAsDiamondCut.proposeTransparentUpgrade( - diamondCutData, - nextProposalId - ); + proxyAsDiamondCut.proposeTransparentUpgrade(diamondCutData, nextProposalId); } function test_RevertWhen_ExecutingUnapprovedShadowUpgrade() public { @@ -346,48 +311,30 @@ contract UpgradeLogicTest is DiamondCutTest { initCalldata: bytes("") }); - uint40 nextProposalId = uint40( - proxyAsGetters.getCurrentProposalId() + 1 - ); + uint40 nextProposalId = uint40(proxyAsGetters.getCurrentProposalId() + 1); vm.startPrank(governor); - bytes32 executingProposalHash = proxyAsDiamondCut.upgradeProposalHash( - diamondCutData, - nextProposalId, - 0 - ); + bytes32 executingProposalHash = proxyAsDiamondCut.upgradeProposalHash(diamondCutData, nextProposalId, 0); - proxyAsDiamondCut.proposeShadowUpgrade( - executingProposalHash, - nextProposalId - ); + proxyAsDiamondCut.proposeShadowUpgrade(executingProposalHash, nextProposalId); vm.expectRevert(abi.encodePacked("av")); proxyAsDiamondCut.executeUpgrade(diamondCutData, 0); } - function test_RevertWhen_ProposingShadowUpgradeWithWrongProposalId() - public - { - uint40 nextProposalId = uint40( - proxyAsGetters.getCurrentProposalId() + 1 - ); + function test_RevertWhen_ProposingShadowUpgradeWithWrongProposalId() public { + uint40 nextProposalId = uint40(proxyAsGetters.getCurrentProposalId() + 1); vm.startPrank(governor); bytes32 porposalHash = Utils.randomBytes32("porposalHash"); vm.expectRevert(abi.encodePacked("ya")); - proxyAsDiamondCut.proposeShadowUpgrade( - porposalHash, - nextProposalId + 1 - ); + proxyAsDiamondCut.proposeShadowUpgrade(porposalHash, nextProposalId + 1); } - function test_RevertWhen_ProposingTransparentUpgradeWithWrongProposalId() - public - { + function test_RevertWhen_ProposingTransparentUpgradeWithWrongProposalId() public { Diamond.FacetCut[] memory facetCuts = new Diamond.FacetCut[](1); facetCuts[0] = Diamond.FacetCut({ facet: address(gettersFacet), @@ -402,17 +349,12 @@ contract UpgradeLogicTest is DiamondCutTest { initCalldata: bytes("") }); - uint40 currentProposalId = uint40( - proxyAsGetters.getCurrentProposalId() - ); + uint40 currentProposalId = uint40(proxyAsGetters.getCurrentProposalId()); vm.startPrank(governor); vm.expectRevert(abi.encodePacked("yb")); - proxyAsDiamondCut.proposeTransparentUpgrade( - diamondCutData, - currentProposalId - ); + proxyAsDiamondCut.proposeTransparentUpgrade(diamondCutData, currentProposalId); } function test_RevertWhen_CancellingUpgradeProposalWithWrongHash() public { @@ -430,28 +372,19 @@ contract UpgradeLogicTest is DiamondCutTest { initCalldata: bytes("") }); - uint40 nextProposalId = uint40( - proxyAsGetters.getCurrentProposalId() + 1 - ); + uint40 nextProposalId = uint40(proxyAsGetters.getCurrentProposalId() + 1); vm.startPrank(governor); - proxyAsDiamondCut.proposeTransparentUpgrade( - diamondCutData, - nextProposalId - ); + proxyAsDiamondCut.proposeTransparentUpgrade(diamondCutData, nextProposalId); - bytes32 proposedUpgradeHash = Utils.randomBytes32( - "proposedUpgradeHash" - ); + bytes32 proposedUpgradeHash = Utils.randomBytes32("proposedUpgradeHash"); vm.expectRevert(abi.encodePacked("rx")); proxyAsDiamondCut.cancelUpgradeProposal(proposedUpgradeHash); } - function test_RevertWhen_ExecutingTransparentUpgradeWithNonZeroSalt() - public - { + function test_RevertWhen_ExecutingTransparentUpgradeWithNonZeroSalt() public { Diamond.FacetCut[] memory facetCuts = new Diamond.FacetCut[](1); facetCuts[0] = Diamond.FacetCut({ facet: address(gettersFacet), @@ -466,16 +399,11 @@ contract UpgradeLogicTest is DiamondCutTest { initCalldata: bytes("") }); - uint40 nextProposalId = uint40( - proxyAsGetters.getCurrentProposalId() + 1 - ); + uint40 nextProposalId = uint40(proxyAsGetters.getCurrentProposalId() + 1); vm.startPrank(governor); - proxyAsDiamondCut.proposeTransparentUpgrade( - diamondCutData, - nextProposalId - ); + proxyAsDiamondCut.proposeTransparentUpgrade(diamondCutData, nextProposalId); bytes32 proposalSalt = Utils.randomBytes32("proposalSalt"); diff --git a/ethereum/test/foundry/unit/concrete/DiamondCut/_DiamondCut_Shared.t.sol b/ethereum/test/foundry/unit/concrete/DiamondCut/_DiamondCut_Shared.t.sol index 2f2b2320b4..422a852672 100644 --- a/ethereum/test/foundry/unit/concrete/DiamondCut/_DiamondCut_Shared.t.sol +++ b/ethereum/test/foundry/unit/concrete/DiamondCut/_DiamondCut_Shared.t.sol @@ -8,8 +8,8 @@ import "../../../../../cache/solpp-generated-contracts/dev-contracts/test/Diamon contract DiamondCutTest is Test { using Utils for *; - DiamondCutTestContract diamondCutTestContract; - GettersFacet gettersFacet; + DiamondCutTestContract internal diamondCutTestContract; + GettersFacet internal gettersFacet; function getGettersSelectors() public view returns (bytes4[] memory) { bytes4[] memory selectors = new bytes4[](32); diff --git a/ethereum/test/foundry/unit/concrete/Executor/Authorization.t.sol b/ethereum/test/foundry/unit/concrete/Executor/Authorization.t.sol index c2d844c897..e6923c6e36 100644 --- a/ethereum/test/foundry/unit/concrete/Executor/Authorization.t.sol +++ b/ethereum/test/foundry/unit/concrete/Executor/Authorization.t.sol @@ -4,8 +4,8 @@ pragma solidity ^0.8.13; import "./_Executor_Shared.t.sol"; contract AuthorizationTest is ExecutorTest { - IExecutor.StoredBlockInfo storedBlockInfo; - IExecutor.CommitBlockInfo commitBlockInfo; + IExecutor.StoredBlockInfo private storedBlockInfo; + IExecutor.CommitBlockInfo private commitBlockInfo; function setUp() public { storedBlockInfo = IExecutor.StoredBlockInfo({ @@ -36,8 +36,7 @@ contract AuthorizationTest is ExecutorTest { } function test_RevertWhen_CommitingByUnauthorisedAddress() public { - IExecutor.CommitBlockInfo[] - memory commitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); + IExecutor.CommitBlockInfo[] memory commitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); commitBlockInfoArray[0] = commitBlockInfo; vm.prank(randomSigner); @@ -47,8 +46,7 @@ contract AuthorizationTest is ExecutorTest { } function test_RevertWhen_ProvingByUnauthorisedAddress() public { - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = storedBlockInfo; vm.prank(owner); @@ -58,8 +56,7 @@ contract AuthorizationTest is ExecutorTest { } function test_RevertWhen_ExecutingByUnauthorizedAddress() public { - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = storedBlockInfo; vm.prank(randomSigner); diff --git a/ethereum/test/foundry/unit/concrete/Executor/Committing.t.sol b/ethereum/test/foundry/unit/concrete/Executor/Committing.t.sol index 54cbf7990d..214953a450 100644 --- a/ethereum/test/foundry/unit/concrete/Executor/Committing.t.sol +++ b/ethereum/test/foundry/unit/concrete/Executor/Committing.t.sol @@ -5,47 +5,33 @@ import "./_Executor_Shared.t.sol"; contract CommittingTest is ExecutorTest { function test_RevertWhen_ComittingWithWrongLastCommittedBlockData() public { - IExecutor.CommitBlockInfo[] - memory newCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); + IExecutor.CommitBlockInfo[] memory newCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); newCommitBlockInfoArray[0] = newCommitBlockInfo; - IExecutor.StoredBlockInfo - memory wrongGenesisStoredBlockInfo = genesisStoredBlockInfo; + IExecutor.StoredBlockInfo memory wrongGenesisStoredBlockInfo = genesisStoredBlockInfo; wrongGenesisStoredBlockInfo.timestamp = 1000; vm.prank(validator); vm.expectRevert(bytes.concat("i")); - executor.commitBlocks( - wrongGenesisStoredBlockInfo, - newCommitBlockInfoArray - ); + executor.commitBlocks(wrongGenesisStoredBlockInfo, newCommitBlockInfoArray); } function test_RevertWhen_ComittingWithWrongOrderOfBlocks() public { - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.blockNumber = 2; // wrong block number - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("f")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingWithWrongNewBlockTimestamp() public { - bytes32 wrongNewBlockTimestamp = Utils.randomBytes32( - "wrongNewBlockTimestamp" - ); + bytes32 wrongNewBlockTimestamp = Utils.randomBytes32("wrongNewBlockTimestamp"); bytes memory wrongL2Logs = abi.encodePacked( bytes4(0x00000001), bytes4(0x00000000), @@ -54,23 +40,16 @@ contract CommittingTest is ExecutorTest { bytes32("") ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("tb")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingWithTooSmallNewBlockTimestamp() public { @@ -82,24 +61,17 @@ contract CommittingTest is ExecutorTest { bytes32("") ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; wrongNewCommitBlockInfo.timestamp = 1; // too small - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("h1")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingTooBigLastL2BlockTimestamp() public { @@ -108,37 +80,25 @@ contract CommittingTest is ExecutorTest { bytes4(0x00000001), bytes4(0x00000000), address(L2_SYSTEM_CONTEXT_ADDRESS), - Utils.packBatchTimestampAndBlockTimestamp( - wrongL2BlockTimestamp, - wrongL2BlockTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(wrongL2BlockTimestamp, wrongL2BlockTimestamp), bytes32("") ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; wrongNewCommitBlockInfo.timestamp = wrongL2BlockTimestamp; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("h2")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingWithWrongPreviousBlockHash() public { - bytes32 wrongPreviousBlockHash = Utils.randomBytes32( - "wrongPreviousBlockHash" - ); + bytes32 wrongPreviousBlockHash = Utils.randomBytes32("wrongPreviousBlockHash"); bytes memory wrongL2Logs = abi.encodePacked( bytes4(0x00000001), bytes4(0x00000000), @@ -147,52 +107,34 @@ contract CommittingTest is ExecutorTest { wrongPreviousBlockHash ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("l")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } - function test_RevertWhen_CommittingWithoutProcessingSystemContextLog() - public - { + function test_RevertWhen_CommittingWithoutProcessingSystemContextLog() public { bytes memory wrongL2Logs = abi.encodePacked(bytes4(0x00000000)); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("by")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } - function test_RevertWhen_CommittingWithProcessingSystemContextLogTwice() - public - { + function test_RevertWhen_CommittingWithProcessingSystemContextLogTwice() public { bytes memory wrongL2Logs = abi.encodePacked( bytes4(0x00000002), bytes4(0x00000000), @@ -205,23 +147,16 @@ contract CommittingTest is ExecutorTest { bytes32("") ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("fx")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_UnexpectedL2ToL1Log() public { @@ -234,23 +169,16 @@ contract CommittingTest is ExecutorTest { bytes32("") ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("ne")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingWithWrongCanonicalTxHash() public { @@ -268,32 +196,21 @@ contract CommittingTest is ExecutorTest { uint256(1) ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("t")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingWithWrongNumberOfLayer1txs() public { - bytes32 arbitraryCanonicalTxHash = Utils.randomBytes32( - "arbitraryCanonicalTxHash" - ); - bytes32 chainedPriorityTxHash = keccak256( - bytes.concat(keccak256(""), arbitraryCanonicalTxHash) - ); + bytes32 arbitraryCanonicalTxHash = Utils.randomBytes32("arbitraryCanonicalTxHash"); + bytes32 chainedPriorityTxHash = keccak256(bytes.concat(keccak256(""), arbitraryCanonicalTxHash)); bytes memory wrongL2Logs = abi.encodePacked( bytes4(0x00000002), @@ -307,27 +224,18 @@ contract CommittingTest is ExecutorTest { uint256(1) ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; - wrongNewCommitBlockInfo.priorityOperationsHash = bytes32( - chainedPriorityTxHash - ); + wrongNewCommitBlockInfo.priorityOperationsHash = bytes32(chainedPriorityTxHash); wrongNewCommitBlockInfo.numberOfLayer1Txs = 2; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("ta")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingWithWrongFactoryDepsData() public { @@ -345,8 +253,7 @@ contract CommittingTest is ExecutorTest { randomFactoryDeps0 ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; bytes[] memory factoryDeps = new bytes[](1); @@ -354,31 +261,22 @@ contract CommittingTest is ExecutorTest { wrongNewCommitBlockInfo.factoryDeps = factoryDeps; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("k3")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } - function test_RevertWhen_CommittingWithWrongFactoryDepsArrayLength() - public - { + function test_RevertWhen_CommittingWithWrongFactoryDepsArrayLength() public { bytes32 arbitraryBytecode = Utils.randomBytes32("arbitraryBytecode"); bytes32 arbitraryBytecodeHash = sha256(bytes.concat(arbitraryBytecode)); - uint256 arbitraryBytecodeHashManipulated1 = uint256( - arbitraryBytecodeHash - ) & 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; + uint256 arbitraryBytecodeHashManipulated1 = uint256(arbitraryBytecodeHash) & + 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; uint256 arbitraryBytecodeHashManipulated2 = arbitraryBytecodeHashManipulated1 | - 0x0100000100000000000000000000000000000000000000000000000000000000; + 0x0100000100000000000000000000000000000000000000000000000000000000; bytes memory wrongL2Logs = abi.encodePacked( bytes4(0x00000002), @@ -391,8 +289,7 @@ contract CommittingTest is ExecutorTest { uint256(arbitraryBytecodeHashManipulated2) ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; bytes[] memory factoryDeps = new bytes[](2); @@ -401,19 +298,13 @@ contract CommittingTest is ExecutorTest { wrongNewCommitBlockInfo.factoryDeps = factoryDeps; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("ym")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_ComittingWithWrongHashedMessage() public { @@ -431,8 +322,7 @@ contract CommittingTest is ExecutorTest { randomL2LogValue ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; bytes32 randomL2Message = Utils.randomBytes32("randomL2Message"); @@ -440,22 +330,15 @@ contract CommittingTest is ExecutorTest { bytes[] memory l2ArbitraryLengthMessages = new bytes[](1); l2ArbitraryLengthMessages[0] = bytes.concat(randomL2Message); - wrongNewCommitBlockInfo - .l2ArbitraryLengthMessages = l2ArbitraryLengthMessages; + wrongNewCommitBlockInfo.l2ArbitraryLengthMessages = l2ArbitraryLengthMessages; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("k2")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingWithWrongNumberOfMessages() public { @@ -478,25 +361,17 @@ contract CommittingTest is ExecutorTest { l2ArbitraryLengthMessagesArray[0] = arbitraryMessage; l2ArbitraryLengthMessagesArray[1] = arbitraryMessage; - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; - wrongNewCommitBlockInfo - .l2ArbitraryLengthMessages = l2ArbitraryLengthMessagesArray; + wrongNewCommitBlockInfo.l2ArbitraryLengthMessages = l2ArbitraryLengthMessagesArray; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("pl")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingWithWrongBytecodeLength() public { @@ -518,29 +393,20 @@ contract CommittingTest is ExecutorTest { bytes[] memory factoryDeps = new bytes[](1); factoryDeps[0] = bytes.concat(randomFactoryDeps1); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; wrongNewCommitBlockInfo.factoryDeps = factoryDeps; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("bl")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } - function test_RevertWhen_CommittingWithWrongNumberOfWordsInBytecode() - public - { + function test_RevertWhen_CommittingWithWrongNumberOfWordsInBytecode() public { bytes32 randomFactoryDeps0 = Utils.randomBytes32("randomFactoryDeps0"); bytes memory wrongL2Logs = abi.encodePacked( @@ -554,32 +420,22 @@ contract CommittingTest is ExecutorTest { randomFactoryDeps0 ); - bytes memory randomFactoryDeps1 = bytes.concat( - randomFactoryDeps0, - randomFactoryDeps0 - ); + bytes memory randomFactoryDeps1 = bytes.concat(randomFactoryDeps0, randomFactoryDeps0); bytes[] memory factoryDeps = new bytes[](1); factoryDeps[0] = bytes.concat(randomFactoryDeps1); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; wrongNewCommitBlockInfo.factoryDeps = factoryDeps; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("pr")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingWithWrongRepeatedStorageWrites() public { @@ -587,85 +443,58 @@ contract CommittingTest is ExecutorTest { bytes4(0x00000001), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32("") ); - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; wrongNewCommitBlockInfo.indexRepeatedStorageChanges = 0; wrongNewCommitBlockInfo.initialStorageChanges = "0x00000001"; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("yq")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingWithTooLongL2Logs() public { // uint256 constant MAX_L2_TO_L1_LOGS_COMMITMENT_BYTES = 4 + L2_TO_L1_LOG_SERIALIZE_SIZE * 512; bytes memory arr1; - for (uint i = 0; i < 512; i++) { - arr1 = abi.encodePacked( - arr1, - bytes4(0x00000000), - L2_TO_L1_MESSENGER, - bytes32(""), - keccak256("") - ); + for (uint16 i = 0; i < 512; i++) { + arr1 = abi.encodePacked(arr1, bytes4(0x00000000), L2_TO_L1_MESSENGER, bytes32(""), keccak256("")); } bytes memory wrongL2Logs = abi.encodePacked( bytes4(0x00000001), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32(""), arr1 ); bytes[] memory l2ArbitraryLengthMessages = new bytes[](512); - for (uint i = 0; i < l2ArbitraryLengthMessages.length; i++) { + for (uint16 i = 0; i < l2ArbitraryLengthMessages.length; i++) { l2ArbitraryLengthMessages[i] = bytes(""); } - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = wrongL2Logs; - wrongNewCommitBlockInfo - .l2ArbitraryLengthMessages = l2ArbitraryLengthMessages; + wrongNewCommitBlockInfo.l2ArbitraryLengthMessages = l2ArbitraryLengthMessages; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("pu")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingTooLongRepeatedStorageChanges() public { @@ -673,10 +502,7 @@ contract CommittingTest is ExecutorTest { bytes4(0x00000001), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32("") ); @@ -684,9 +510,7 @@ contract CommittingTest is ExecutorTest { // which is longer than 302564 (MAX_REPEATED_STORAGE_CHANGES_COMMITMENT_BYTES = // 4 + REPEATED_STORAGE_CHANGE_SERIALIZE_SIZE * 7564) uint256 wrongRepeatedStorageChangesLen = 7565 * 40; - bytes memory wrongRepeatedStorageChanges = new bytes( - wrongRepeatedStorageChangesLen - ); + bytes memory wrongRepeatedStorageChanges = new bytes(wrongRepeatedStorageChangesLen); assembly { let ptr := add(wrongRepeatedStorageChanges, 32) @@ -697,33 +521,22 @@ contract CommittingTest is ExecutorTest { } lt(ptr, end) { } { - mstore( - ptr, - 0x0000000000000000000000000000000000000000000000000000000000000000 - ) + mstore(ptr, 0x0000000000000000000000000000000000000000000000000000000000000000) ptr := add(ptr, 40) } } - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = correctL2Logs; - wrongNewCommitBlockInfo - .repeatedStorageChanges = wrongRepeatedStorageChanges; + wrongNewCommitBlockInfo.repeatedStorageChanges = wrongRepeatedStorageChanges; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("py")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_RevertWhen_CommittingTooLongInitialStorageChanges() public { @@ -731,10 +544,7 @@ contract CommittingTest is ExecutorTest { bytes4(0x00000001), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32("") ); @@ -742,9 +552,7 @@ contract CommittingTest is ExecutorTest { // which is longer than 304964 (MAX_INITIAL_STORAGE_CHANGES_COMMITMENT_BYTES = // 4 + INITIAL_STORAGE_CHANGE_SERIALIZE_SIZE * 4765) uint256 wrongInitialStorageChangesLen = 4766 * 64; - bytes memory wrongInitialStorageChanges = new bytes( - wrongInitialStorageChangesLen - ); + bytes memory wrongInitialStorageChanges = new bytes(wrongInitialStorageChangesLen); assembly { let ptr := add(wrongInitialStorageChanges, 32) @@ -755,33 +563,22 @@ contract CommittingTest is ExecutorTest { } lt(ptr, end) { } { - mstore( - ptr, - 0x0000000000000000000000000000000000000000000000000000000000000000 - ) + mstore(ptr, 0x0000000000000000000000000000000000000000000000000000000000000000) ptr := add(ptr, 64) } } - IExecutor.CommitBlockInfo - memory wrongNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory wrongNewCommitBlockInfo = newCommitBlockInfo; wrongNewCommitBlockInfo.l2Logs = correctL2Logs; - wrongNewCommitBlockInfo - .initialStorageChanges = wrongInitialStorageChanges; + wrongNewCommitBlockInfo.initialStorageChanges = wrongInitialStorageChanges; - IExecutor.CommitBlockInfo[] - memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory wrongNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); wrongNewCommitBlockInfoArray[0] = wrongNewCommitBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("pf")); - executor.commitBlocks( - genesisStoredBlockInfo, - wrongNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, wrongNewCommitBlockInfoArray); } function test_SuccessfullyCommitBlock() public { @@ -789,19 +586,14 @@ contract CommittingTest is ExecutorTest { bytes4(0x00000001), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32("") ); - IExecutor.CommitBlockInfo - memory correctNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory correctNewCommitBlockInfo = newCommitBlockInfo; correctNewCommitBlockInfo.l2Logs = correctL2Logs; - IExecutor.CommitBlockInfo[] - memory commitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); + IExecutor.CommitBlockInfo[] memory commitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); commitBlockInfoArray[0] = correctNewCommitBlockInfo; vm.prank(validator); @@ -813,10 +605,7 @@ contract CommittingTest is ExecutorTest { Vm.Log[] memory entries = vm.getRecordedLogs(); assertEq(entries.length, 1); - assertEq( - entries[0].topics[0], - keccak256("BlockCommit(uint256,bytes32,bytes32)") - ); + assertEq(entries[0].topics[0], keccak256("BlockCommit(uint256,bytes32,bytes32)")); assertEq(entries[0].topics[1], bytes32(uint256(1))); // blockNumber uint256 totalBlocksCommitted = getters.getTotalBlocksCommitted(); diff --git a/ethereum/test/foundry/unit/concrete/Executor/Executing.t.sol b/ethereum/test/foundry/unit/concrete/Executor/Executing.t.sol index 88201ffe62..3596d5a36d 100644 --- a/ethereum/test/foundry/unit/concrete/Executor/Executing.t.sol +++ b/ethereum/test/foundry/unit/concrete/Executor/Executing.t.sol @@ -12,18 +12,14 @@ contract ExecutingTest is ExecutorTest { bytes4(0x00000001), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32("") ); newCommitBlockInfo.l2Logs = correctL2Logs; newCommitBlockInfo.timestamp = uint64(currentTimestamp); - IExecutor.CommitBlockInfo[] - memory commitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); + IExecutor.CommitBlockInfo[] memory commitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); commitBlockInfoArray[0] = newCommitBlockInfo; vm.prank(validator); @@ -42,25 +38,18 @@ contract ExecutingTest is ExecutorTest { commitment: entries[0].topics[3] }); - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = newStoredBlockInfo; vm.prank(validator); - executor.proveBlocks( - genesisStoredBlockInfo, - storedBlockInfoArray, - proofInput - ); + executor.proveBlocks(genesisStoredBlockInfo, storedBlockInfoArray, proofInput); } function test_RevertWhen_ExecutingBlockWithWrongBlockNumber() public { - IExecutor.StoredBlockInfo - memory wrongNewStoredBlockInfo = newStoredBlockInfo; + IExecutor.StoredBlockInfo memory wrongNewStoredBlockInfo = newStoredBlockInfo; wrongNewStoredBlockInfo.blockNumber = 10; // Correct is 1 - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = wrongNewStoredBlockInfo; vm.prank(validator); @@ -69,12 +58,10 @@ contract ExecutingTest is ExecutorTest { } function test_RevertWhen_ExecutingBlockWithWrongData() public { - IExecutor.StoredBlockInfo - memory wrongNewStoredBlockInfo = newStoredBlockInfo; + IExecutor.StoredBlockInfo memory wrongNewStoredBlockInfo = newStoredBlockInfo; wrongNewStoredBlockInfo.timestamp = 0; // incorrect timestamp - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = wrongNewStoredBlockInfo; vm.prank(validator); @@ -82,14 +69,11 @@ contract ExecutingTest is ExecutorTest { executor.executeBlocks(storedBlockInfoArray); } - function test_RevertWhen_ExecutingRevertedBlockWithoutCommittingAndProvingAgain() - public - { + function test_RevertWhen_ExecutingRevertedBlockWithoutCommittingAndProvingAgain() public { vm.prank(validator); executor.revertBlocks(0); - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = newStoredBlockInfo; vm.prank(validator); @@ -97,27 +81,18 @@ contract ExecutingTest is ExecutorTest { executor.executeBlocks(storedBlockInfoArray); } - function test_RevertWhen_ExecutingUnavailablePriorityOperationHash() - public - { + function test_RevertWhen_ExecutingUnavailablePriorityOperationHash() public { vm.prank(validator); executor.revertBlocks(0); - bytes32 arbitraryCanonicalTxHash = Utils.randomBytes32( - "arbitraryCanonicalTxHash" - ); - bytes32 chainedPriorityTxHash = keccak256( - bytes.concat(keccak256(""), arbitraryCanonicalTxHash) - ); + bytes32 arbitraryCanonicalTxHash = Utils.randomBytes32("arbitraryCanonicalTxHash"); + bytes32 chainedPriorityTxHash = keccak256(bytes.concat(keccak256(""), arbitraryCanonicalTxHash)); bytes memory correctL2Logs = abi.encodePacked( bytes4(0x00000002), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32(""), bytes4(0x00010000), L2_BOOTLOADER_ADDRESS, @@ -125,74 +100,48 @@ contract ExecutingTest is ExecutorTest { uint256(1) ); - IExecutor.CommitBlockInfo - memory correctNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory correctNewCommitBlockInfo = newCommitBlockInfo; correctNewCommitBlockInfo.l2Logs = correctL2Logs; - correctNewCommitBlockInfo - .priorityOperationsHash = chainedPriorityTxHash; + correctNewCommitBlockInfo.priorityOperationsHash = chainedPriorityTxHash; correctNewCommitBlockInfo.numberOfLayer1Txs = 1; - IExecutor.CommitBlockInfo[] - memory correctNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory correctNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); correctNewCommitBlockInfoArray[0] = correctNewCommitBlockInfo; vm.prank(validator); vm.recordLogs(); - executor.commitBlocks( - genesisStoredBlockInfo, - correctNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, correctNewCommitBlockInfoArray); Vm.Log[] memory entries = vm.getRecordedLogs(); - IExecutor.StoredBlockInfo - memory correctNewStoredBlockInfo = newStoredBlockInfo; + IExecutor.StoredBlockInfo memory correctNewStoredBlockInfo = newStoredBlockInfo; correctNewStoredBlockInfo.blockHash = entries[0].topics[2]; correctNewStoredBlockInfo.numberOfLayer1Txs = 1; - correctNewStoredBlockInfo - .priorityOperationsHash = chainedPriorityTxHash; + correctNewStoredBlockInfo.priorityOperationsHash = chainedPriorityTxHash; correctNewStoredBlockInfo.commitment = entries[0].topics[3]; - IExecutor.StoredBlockInfo[] - memory correctNewStoredBlockInfoArray = new IExecutor.StoredBlockInfo[]( - 1 - ); + IExecutor.StoredBlockInfo[] memory correctNewStoredBlockInfoArray = new IExecutor.StoredBlockInfo[](1); correctNewStoredBlockInfoArray[0] = correctNewStoredBlockInfo; vm.prank(validator); - executor.proveBlocks( - genesisStoredBlockInfo, - correctNewStoredBlockInfoArray, - proofInput - ); + executor.proveBlocks(genesisStoredBlockInfo, correctNewStoredBlockInfoArray, proofInput); vm.prank(validator); vm.expectRevert(bytes.concat("s")); executor.executeBlocks(correctNewStoredBlockInfoArray); } - function test_RevertWhen_ExecutingWithUnmatchedPriorityOperationHash() - public - { + function test_RevertWhen_ExecutingWithUnmatchedPriorityOperationHash() public { vm.prank(validator); executor.revertBlocks(0); - bytes32 arbitraryCanonicalTxHash = Utils.randomBytes32( - "arbitraryCanonicalTxHash" - ); - bytes32 chainedPriorityTxHash = keccak256( - bytes.concat(keccak256(""), arbitraryCanonicalTxHash) - ); + bytes32 arbitraryCanonicalTxHash = Utils.randomBytes32("arbitraryCanonicalTxHash"); + bytes32 chainedPriorityTxHash = keccak256(bytes.concat(keccak256(""), arbitraryCanonicalTxHash)); bytes memory correctL2Logs = abi.encodePacked( bytes4(0x00000002), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32(""), bytes4(0x00010000), L2_BOOTLOADER_ADDRESS, @@ -200,47 +149,30 @@ contract ExecutingTest is ExecutorTest { uint256(1) ); - IExecutor.CommitBlockInfo - memory correctNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory correctNewCommitBlockInfo = newCommitBlockInfo; correctNewCommitBlockInfo.l2Logs = correctL2Logs; - correctNewCommitBlockInfo - .priorityOperationsHash = chainedPriorityTxHash; + correctNewCommitBlockInfo.priorityOperationsHash = chainedPriorityTxHash; correctNewCommitBlockInfo.numberOfLayer1Txs = 1; - IExecutor.CommitBlockInfo[] - memory correctNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory correctNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); correctNewCommitBlockInfoArray[0] = correctNewCommitBlockInfo; vm.prank(validator); vm.recordLogs(); - executor.commitBlocks( - genesisStoredBlockInfo, - correctNewCommitBlockInfoArray - ); + executor.commitBlocks(genesisStoredBlockInfo, correctNewCommitBlockInfoArray); Vm.Log[] memory entries = vm.getRecordedLogs(); - IExecutor.StoredBlockInfo - memory correctNewStoredBlockInfo = newStoredBlockInfo; + IExecutor.StoredBlockInfo memory correctNewStoredBlockInfo = newStoredBlockInfo; correctNewStoredBlockInfo.blockHash = entries[0].topics[2]; correctNewStoredBlockInfo.numberOfLayer1Txs = 1; - correctNewStoredBlockInfo - .priorityOperationsHash = chainedPriorityTxHash; + correctNewStoredBlockInfo.priorityOperationsHash = chainedPriorityTxHash; correctNewStoredBlockInfo.commitment = entries[0].topics[3]; - IExecutor.StoredBlockInfo[] - memory correctNewStoredBlockInfoArray = new IExecutor.StoredBlockInfo[]( - 1 - ); + IExecutor.StoredBlockInfo[] memory correctNewStoredBlockInfoArray = new IExecutor.StoredBlockInfo[](1); correctNewStoredBlockInfoArray[0] = correctNewStoredBlockInfo; vm.prank(validator); - executor.proveBlocks( - genesisStoredBlockInfo, - correctNewStoredBlockInfoArray, - proofInput - ); + executor.proveBlocks(genesisStoredBlockInfo, correctNewStoredBlockInfoArray, proofInput); bytes32 randomFactoryDeps0 = Utils.randomBytes32("randomFactoryDeps0"); @@ -249,11 +181,7 @@ contract ExecutingTest is ExecutorTest { uint256 gasPrice = 1000000000; uint256 l2GasLimit = 1000000; - uint256 baseCost = mailbox.l2TransactionBaseCost( - gasPrice, - l2GasLimit, - REQUIRED_L2_GAS_PRICE_PER_PUBDATA - ); + uint256 baseCost = mailbox.l2TransactionBaseCost(gasPrice, l2GasLimit, REQUIRED_L2_GAS_PRICE_PER_PUBDATA); uint256 l2Value = 10 ether; uint256 totalCost = baseCost + l2Value; @@ -272,33 +200,22 @@ contract ExecutingTest is ExecutorTest { executor.executeBlocks(correctNewStoredBlockInfoArray); } - function test_RevertWhen_CommittingBlockWithWrongPreviousBlockHash() - public - { + function test_RevertWhen_CommittingBlockWithWrongPreviousBlockHash() public { bytes memory correctL2Logs = abi.encodePacked( bytes4(0x00000001), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32("") ); - IExecutor.CommitBlockInfo - memory correctNewCommitBlockInfo = newCommitBlockInfo; + IExecutor.CommitBlockInfo memory correctNewCommitBlockInfo = newCommitBlockInfo; correctNewCommitBlockInfo.l2Logs = correctL2Logs; - IExecutor.CommitBlockInfo[] - memory correctNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[]( - 1 - ); + IExecutor.CommitBlockInfo[] memory correctNewCommitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); correctNewCommitBlockInfoArray[0] = correctNewCommitBlockInfo; - bytes32 wrongPreviousBlockHash = Utils.randomBytes32( - "wrongPreviousBlockHash" - ); + bytes32 wrongPreviousBlockHash = Utils.randomBytes32("wrongPreviousBlockHash"); IExecutor.StoredBlockInfo memory genesisBlock = genesisStoredBlockInfo; genesisBlock.blockHash = wrongPreviousBlockHash; @@ -309,8 +226,7 @@ contract ExecutingTest is ExecutorTest { } function test_ShouldExecuteBlockSuccessfully() public { - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = newStoredBlockInfo; vm.prank(validator); diff --git a/ethereum/test/foundry/unit/concrete/Executor/Proving.t.sol b/ethereum/test/foundry/unit/concrete/Executor/Proving.t.sol index 2bd09b4a3c..29901e4488 100644 --- a/ethereum/test/foundry/unit/concrete/Executor/Proving.t.sol +++ b/ethereum/test/foundry/unit/concrete/Executor/Proving.t.sol @@ -12,18 +12,14 @@ contract ProvingTest is ExecutorTest { bytes4(0x00000001), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32("") ); newCommitBlockInfo.timestamp = uint64(currentTimestamp); newCommitBlockInfo.l2Logs = correctL2Logs; - IExecutor.CommitBlockInfo[] - memory commitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); + IExecutor.CommitBlockInfo[] memory commitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); commitBlockInfoArray[0] = newCommitBlockInfo; vm.prank(validator); @@ -44,75 +40,51 @@ contract ProvingTest is ExecutorTest { } function test_RevertWhen_ProvingWithWrongPreviousBlockData() public { - IExecutor.StoredBlockInfo - memory wrongPreviousStoredBlockInfo = genesisStoredBlockInfo; + IExecutor.StoredBlockInfo memory wrongPreviousStoredBlockInfo = genesisStoredBlockInfo; wrongPreviousStoredBlockInfo.blockNumber = 10; // Correct is 0 - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = newStoredBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("t1")); - executor.proveBlocks( - wrongPreviousStoredBlockInfo, - storedBlockInfoArray, - proofInput - ); + executor.proveBlocks(wrongPreviousStoredBlockInfo, storedBlockInfoArray, proofInput); } function test_RevertWhen_ProvingWithWrongCommittedBlock() public { - IExecutor.StoredBlockInfo - memory wrongNewStoredBlockInfo = newStoredBlockInfo; + IExecutor.StoredBlockInfo memory wrongNewStoredBlockInfo = newStoredBlockInfo; wrongNewStoredBlockInfo.blockNumber = 10; // Correct is 1 - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = wrongNewStoredBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("o1")); - executor.proveBlocks( - genesisStoredBlockInfo, - storedBlockInfoArray, - proofInput - ); + executor.proveBlocks(genesisStoredBlockInfo, storedBlockInfoArray, proofInput); } - function test_RevertWhen_ProvingRevertedBlockWithoutCommittingAgain() - public - { + function test_RevertWhen_ProvingRevertedBlockWithoutCommittingAgain() public { vm.prank(validator); executor.revertBlocks(0); - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = newStoredBlockInfo; vm.prank(validator); vm.expectRevert(bytes.concat("q")); - executor.proveBlocks( - genesisStoredBlockInfo, - storedBlockInfoArray, - proofInput - ); + executor.proveBlocks(genesisStoredBlockInfo, storedBlockInfoArray, proofInput); } function test_SuccessfulProve() public { - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = newStoredBlockInfo; vm.prank(validator); - executor.proveBlocks( - genesisStoredBlockInfo, - storedBlockInfoArray, - proofInput - ); + executor.proveBlocks(genesisStoredBlockInfo, storedBlockInfoArray, proofInput); uint256 totalBlocksVerified = getters.getTotalBlocksVerified(); assertEq(totalBlocksVerified, 1); diff --git a/ethereum/test/foundry/unit/concrete/Executor/Reverting.t.sol b/ethereum/test/foundry/unit/concrete/Executor/Reverting.t.sol index 4817672609..0561a1d730 100644 --- a/ethereum/test/foundry/unit/concrete/Executor/Reverting.t.sol +++ b/ethereum/test/foundry/unit/concrete/Executor/Reverting.t.sol @@ -12,18 +12,14 @@ contract RevertingTest is ExecutorTest { bytes4(0x00000001), bytes4(0x00000000), L2_SYSTEM_CONTEXT_ADDRESS, - Utils.packBatchTimestampAndBlockTimestamp( - currentTimestamp, - currentTimestamp - ), + Utils.packBatchTimestampAndBlockTimestamp(currentTimestamp, currentTimestamp), bytes32("") ); newCommitBlockInfo.timestamp = uint64(currentTimestamp); newCommitBlockInfo.l2Logs = correctL2Logs; - IExecutor.CommitBlockInfo[] - memory commitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); + IExecutor.CommitBlockInfo[] memory commitBlockInfoArray = new IExecutor.CommitBlockInfo[](1); commitBlockInfoArray[0] = newCommitBlockInfo; vm.prank(validator); @@ -42,17 +38,12 @@ contract RevertingTest is ExecutorTest { commitment: entries[0].topics[3] }); - IExecutor.StoredBlockInfo[] - memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); + IExecutor.StoredBlockInfo[] memory storedBlockInfoArray = new IExecutor.StoredBlockInfo[](1); storedBlockInfoArray[0] = newStoredBlockInfo; vm.prank(validator); - executor.proveBlocks( - genesisStoredBlockInfo, - storedBlockInfoArray, - proofInput - ); + executor.proveBlocks(genesisStoredBlockInfo, storedBlockInfoArray, proofInput); } function test_RevertWhen_RevertingMoreBlocksThanAlreadyCommitted() public { diff --git a/ethereum/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol b/ethereum/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol index 248b533382..8a89af1053 100644 --- a/ethereum/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol +++ b/ethereum/test/foundry/unit/concrete/Executor/_Executor_Shared.t.sol @@ -15,29 +15,26 @@ import "../../../../../cache/solpp-generated-contracts/zksync/DiamondProxy.sol"; contract ExecutorTest is Test { using Utils for *; - address constant L2_SYSTEM_CONTEXT_ADDRESS = - 0x000000000000000000000000000000000000800B; - address constant L2_KNOWN_CODE_STORAGE_ADDRESS = - 0x0000000000000000000000000000000000008004; - address constant L2_TO_L1_MESSENGER = - 0x0000000000000000000000000000000000008008; - - address owner; - address validator; - address randomSigner; - AllowList allowList; - GovernanceFacet governance; - ExecutorFacet executor; - GettersFacet getters; - MailboxFacet mailbox; - bytes32 newCommittedBlockBlockHash; - bytes32 newCommittedBlockCommitment; - uint256 currentTimestamp; - IExecutor.CommitBlockInfo newCommitBlockInfo; - IExecutor.StoredBlockInfo newStoredBlockInfo; - - IExecutor.StoredBlockInfo genesisStoredBlockInfo; - IExecutor.ProofInput proofInput; + address internal constant L2_SYSTEM_CONTEXT_ADDRESS = 0x000000000000000000000000000000000000800B; + address internal constant L2_KNOWN_CODE_STORAGE_ADDRESS = 0x0000000000000000000000000000000000008004; + address internal constant L2_TO_L1_MESSENGER = 0x0000000000000000000000000000000000008008; + + address internal owner; + address internal validator; + address internal randomSigner; + AllowList internal allowList; + GovernanceFacet internal governance; + ExecutorFacet internal executor; + GettersFacet internal getters; + MailboxFacet internal mailbox; + bytes32 internal newCommittedBlockBlockHash; + bytes32 internal newCommittedBlockCommitment; + uint256 internal currentTimestamp; + IExecutor.CommitBlockInfo internal newCommitBlockInfo; + IExecutor.StoredBlockInfo internal newStoredBlockInfo; + + IExecutor.StoredBlockInfo internal genesisStoredBlockInfo; + IExecutor.ProofInput internal proofInput; function getGovernanceSelectors() private view returns (bytes4[] memory) { bytes4[] memory selectors = new bytes4[](5); @@ -129,11 +126,7 @@ contract ExecutorTest is Test { 0, 0, allowList, - VerifierParams({ - recursionNodeLevelVkHash: 0, - recursionLeafLevelVkHash: 0, - recursionCircuitsSetVksHash: 0 - }), + VerifierParams({recursionNodeLevelVkHash: 0, recursionLeafLevelVkHash: 0, recursionCircuitsSetVksHash: 0}), false, dummyHash, dummyHash, @@ -176,10 +169,7 @@ contract ExecutorTest is Test { DiamondProxy diamondProxy = new DiamondProxy(chainId, diamondCutData); vm.prank(owner); - allowList.setAccessMode( - address(diamondProxy), - IAllowList.AccessMode.Public - ); + allowList.setAccessMode(address(diamondProxy), IAllowList.AccessMode.Public); executor = ExecutorFacet(address(diamondProxy)); getters = GettersFacet(address(diamondProxy)); @@ -191,10 +181,7 @@ contract ExecutorTest is Test { uint256[] memory recursiveAggregationInput; uint256[] memory serializedProof; - proofInput = IExecutor.ProofInput( - recursiveAggregationInput, - serializedProof - ); + proofInput = IExecutor.ProofInput(recursiveAggregationInput, serializedProof); genesisStoredBlockInfo = IExecutor.StoredBlockInfo({ blockNumber: 0, diff --git a/ethereum/test/foundry/unit/concrete/UnsafeBytes/UnsafeBytes.t.sol b/ethereum/test/foundry/unit/concrete/UnsafeBytes/UnsafeBytes.t.sol index 92dde95179..792930c27b 100644 --- a/ethereum/test/foundry/unit/concrete/UnsafeBytes/UnsafeBytes.t.sol +++ b/ethereum/test/foundry/unit/concrete/UnsafeBytes/UnsafeBytes.t.sol @@ -6,31 +6,21 @@ import "forge-std/Test.sol"; import "../../../../../cache/solpp-generated-contracts/dev-contracts/test/UnsafeBytesTest.sol"; contract UnsafeBytesTestTest is Test { - UnsafeBytesTest unsafeBytesTest; - bytes bytesData; - address addr0 = 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045; - address addr1 = 0x7aFd58312784ACf80E2ba97Dd84Ff2bADeA9e4A2; - uint256 u256 = 0x15; - uint32 u321 = 0xffffffff; - uint32 u322 = 0x16; - address addr2 = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; - bytes32 b32 = - 0x4845bfb858e60647a4f22f02d3712a20fa6b557288dbe97b6ae719390482ef4b; - address addr3 = 0xaBEA9132b05A70803a4E85094fD0e1800777fBEF; + UnsafeBytesTest private unsafeBytesTest; + bytes private bytesData; + address private addr0 = 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045; + address private addr1 = 0x7aFd58312784ACf80E2ba97Dd84Ff2bADeA9e4A2; + uint256 private u256 = 0x15; + uint32 private u321 = 0xffffffff; + uint32 private u322 = 0x16; + address private addr2 = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; + bytes32 private b32 = 0x4845bfb858e60647a4f22f02d3712a20fa6b557288dbe97b6ae719390482ef4b; + address private addr3 = 0xaBEA9132b05A70803a4E85094fD0e1800777fBEF; function setUp() public { unsafeBytesTest = new UnsafeBytesTest(); - bytesData = abi.encodePacked( - addr0, - addr1, - u256, - u321, - u322, - addr2, - b32, - addr3 - ); + bytesData = abi.encodePacked(addr0, addr1, u256, u321, u322, addr2, b32, addr3); } function test() public { diff --git a/ethereum/test/foundry/unit/concrete/Utils/Utils.t.sol b/ethereum/test/foundry/unit/concrete/Utils/Utils.t.sol index a9a96113a2..9b248be4f0 100644 --- a/ethereum/test/foundry/unit/concrete/Utils/Utils.t.sol +++ b/ethereum/test/foundry/unit/concrete/Utils/Utils.t.sol @@ -11,10 +11,7 @@ contract UtilsTest is Test { function test_PackBatchTimestampAndBlockTimestamp() public { uint64 batchTimestamp = 0x12345678; uint64 blockTimestamp = 0x87654321; - bytes32 packedBytes = Utils.packBatchTimestampAndBlockTimestamp( - batchTimestamp, - blockTimestamp - ); + bytes32 packedBytes = Utils.packBatchTimestampAndBlockTimestamp(batchTimestamp, blockTimestamp); assertEq( packedBytes,