Skip to content

Commit

Permalink
Adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Dec 19, 2023
1 parent 7ca2343 commit 9ebe8b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 56 deletions.
48 changes: 0 additions & 48 deletions test-foundry/L1AtomicTokenBridgeCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -422,54 +422,6 @@ contract L1AtomicTokenBridgeCreatorTest is Test {
l1Creator.createTokenBridge(address(inbox), deployer, 100, 200);
}

function test_createTokenBridge_revert_AlreadyCreated() public {
// prepare
_setTemplates();
(RollupProxy rollup, Inbox inbox,, UpgradeExecutor upgExecutor) = _createRollup();

// mocks
vm.mockCall(
address(rollup), abi.encodeWithSignature("owner()"), abi.encode(address(upgExecutor))
);
vm.mockCall(
address(upgExecutor),
abi.encodeWithSignature(
"hasRole(bytes32,address)", upgExecutor.EXECUTOR_ROLE(), deployer
),
abi.encode(true)
);
uint256 mockChainId = 2000;
vm.mockCall(address(rollup), abi.encodeWithSignature("chainId()"), abi.encode(mockChainId));

/// do 1st deployment
vm.deal(deployer, 10 ether);
vm.prank(deployer);
l1Creator.createTokenBridge{value: 1 ether}(address(inbox), deployer, 100, 200);

/// mock again
vm.mockCall(
address(rollup), abi.encodeWithSignature("owner()"), abi.encode(address(upgExecutor))
);
vm.mockCall(
address(upgExecutor),
abi.encodeWithSignature(
"hasRole(bytes32,address)", upgExecutor.EXECUTOR_ROLE(), deployer
),
abi.encode(true)
);
vm.mockCall(address(rollup), abi.encodeWithSignature("chainId()"), abi.encode(mockChainId));

// 2nd deployment reverts
vm.expectRevert(
abi.encodeWithSelector(
L1AtomicTokenBridgeCreator.L1AtomicTokenBridgeCreator_AlreadyCreated.selector
)
);

vm.prank(deployer);
l1Creator.createTokenBridge{value: 1 ether}(address(inbox), deployer, 100, 200);
}

function test_getRouter_NonExistent() public {
assertEq(l1Creator.getRouter(makeAddr("non-existent")), address(0), "Should be empty");
}
Expand Down
18 changes: 10 additions & 8 deletions test-foundry/L2AtomicTokenBridgeFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ contract L2AtomicTokenBridgeFactoryTest is Test {

// logic
address expectedL2RouterLogicAddress = Create2.computeAddress(
bytes32(0),
keccak256(abi.encodePacked(bytes("L2R"), block.chainid, address(this))),
keccak256(CreationCodeHelper.getCreationCodeFor(runtimeCode.router)),
address(l2Factory)
);
Expand Down Expand Up @@ -165,10 +165,12 @@ contract L2AtomicTokenBridgeFactoryTest is Test {
"Wrong beaconProxyFactory"
);
address expectedStandardArbERC20Address = Create2.computeAddress(
bytes32(0), keccak256(type(StandardArbERC20).creationCode), address(l2Factory)
keccak256(abi.encodePacked(bytes("L2BPF"), block.chainid, address(this))),
keccak256(type(StandardArbERC20).creationCode),
address(l2Factory)
);
address expectedBeaconAddress = Create2.computeAddress(
bytes32(0),
keccak256(abi.encodePacked(bytes("L2BPF"), block.chainid, address(this))),
keccak256(
abi.encodePacked(
type(UpgradeableBeacon).creationCode,
Expand Down Expand Up @@ -207,7 +209,7 @@ contract L2AtomicTokenBridgeFactoryTest is Test {

// logic
address expectedL2StandardGwLogicAddress = Create2.computeAddress(
bytes32(0),
keccak256(abi.encodePacked(bytes("L2SGW"), block.chainid, address(this))),
keccak256(CreationCodeHelper.getCreationCodeFor(runtimeCode.standardGateway)),
address(l2Factory)
);
Expand Down Expand Up @@ -259,7 +261,7 @@ contract L2AtomicTokenBridgeFactoryTest is Test {

// logic
address expectedL2CustomGwLogicAddress = Create2.computeAddress(
bytes32(0),
keccak256(abi.encodePacked(bytes("L2CGW"), block.chainid, address(this))),
keccak256(CreationCodeHelper.getCreationCodeFor(runtimeCode.customGateway)),
address(l2Factory)
);
Expand Down Expand Up @@ -315,7 +317,7 @@ contract L2AtomicTokenBridgeFactoryTest is Test {

// wethgateway logic
address expectedL2WethGwLogicAddress = Create2.computeAddress(
bytes32(0),
keccak256(abi.encodePacked(bytes("L2WGW"), block.chainid, address(this))),
keccak256(CreationCodeHelper.getCreationCodeFor(runtimeCode.wethGateway)),
address(l2Factory)
);
Expand Down Expand Up @@ -350,7 +352,7 @@ contract L2AtomicTokenBridgeFactoryTest is Test {

// weth logic
address expectedL2WethLogicAddress = Create2.computeAddress(
bytes32(0),
keccak256(abi.encodePacked(bytes("L2W"), block.chainid, address(this))),
keccak256(CreationCodeHelper.getCreationCodeFor(runtimeCode.aeWeth)),
address(l2Factory)
);
Expand Down Expand Up @@ -402,7 +404,7 @@ contract L2AtomicTokenBridgeFactoryTest is Test {

// logic
address expectedL2UpgExecutorLogicAddress = Create2.computeAddress(
bytes32(0),
keccak256(abi.encodePacked(bytes("L2E"), block.chainid, address(this))),
keccak256(CreationCodeHelper.getCreationCodeFor(runtimeCode.upgradeExecutor)),
address(l2Factory)
);
Expand Down

0 comments on commit 9ebe8b2

Please sign in to comment.