From d9e3182f7bc8f1028337fe05e87e5b80efde54d1 Mon Sep 17 00:00:00 2001 From: josojo Date: Wed, 22 Nov 2023 10:20:31 +0100 Subject: [PATCH] Improve ChainIdManager test by removing second chainID (#95) --- test/ChainIdManager.t.sol | 2 +- test/ForkingManager.t.sol | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/test/ChainIdManager.t.sol b/test/ChainIdManager.t.sol index 19771f01..3ffea08c 100644 --- a/test/ChainIdManager.t.sol +++ b/test/ChainIdManager.t.sol @@ -75,7 +75,7 @@ contract ChainIdManagerTest is Test { ); } - function testCheckGasBurn() public { + function testCheckGasBurn() view public { uint256 initialGasLeft = gasleft(); chainIdManager.burnGas(); uint256 finalGasLeft = gasleft(); diff --git a/test/ForkingManager.t.sol b/test/ForkingManager.t.sol index c68da20e..57c1d524 100644 --- a/test/ForkingManager.t.sol +++ b/test/ForkingManager.t.sol @@ -29,7 +29,7 @@ contract ForkingManagerTest is Test { address public zkevmImplementation; address public forkonomicTokenImplementation; address public globalExitRootImplementation; - address public chainIdManager; + address public chainIdManagerAddress; bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; @@ -43,7 +43,6 @@ contract ForkingManagerTest is Test { ); uint64 public forkID = 3; uint64 public newForkID = 4; - uint64 public chainID = 4; uint32 public networkID = 10; uint64 public pendingStateTimeout = 123; uint64 public trustedAggregatorTimeout = 124235; @@ -59,8 +58,8 @@ contract ForkingManagerTest is Test { bytes32[32] public depositTree; address public admin = address(0xad); uint64 public initialChainId = 1; - uint64 public firstChainId = 1; - uint64 public secondChainId = 2; + uint64 public firstChainId = initialChainId+1; + uint64 public secondChainId = initialChainId+2; // Setup new implementations for the fork address public newBridgeImplementation = address(new ForkableBridge()); @@ -131,8 +130,8 @@ contract ForkingManagerTest is Test { ) ) ); - - chainIdManager = address(new ChainIdManager(initialChainId)); + ChainIdManager chainIdManager= new ChainIdManager(initialChainId); + chainIdManagerAddress = address(chainIdManager); globalExitRoot.initialize( address(forkmanager), address(0x0), @@ -160,7 +159,7 @@ contract ForkingManagerTest is Test { pendingStateTimeout: pendingStateTimeout, trustedAggregator: trustedAggregator, trustedAggregatorTimeout: trustedAggregatorTimeout, - chainID: chainID, + chainID: chainIdManager.getNextUsableChainId(), forkID: forkID }); zkevm.initialize( @@ -183,7 +182,7 @@ contract ForkingManagerTest is Test { address(0x0), address(globalExitRoot), arbitrationFee, - chainIdManager + chainIdManagerAddress ); forkonomicToken.initialize( address(forkmanager), @@ -389,11 +388,11 @@ contract ForkingManagerTest is Test { } { assertEq( - chainIdManager, + chainIdManagerAddress, ForkingManager(childForkmanager1).chainIdManager() ); assertEq( - chainIdManager, + chainIdManagerAddress, ForkingManager(childForkmanager2).chainIdManager() ); }