Commit 6ea4e40b authored by Michael Amadi's avatar Michael Amadi Committed by GitHub

merge bridge initializer into common test (#12795)

* merge bridge initializer into common test

* gas snapshot

* remove duplicate import
parent 04d79720
......@@ -5,7 +5,7 @@ GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_b
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531)
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369280)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967420)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967465)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564398)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076613)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467098)
......@@ -14,4 +14,4 @@ GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (g
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68422)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68986)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155610)
\ No newline at end of file
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155565)
\ No newline at end of file
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing utilities
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { Reverter } from "test/mocks/Callers.sol";
// Libraries
......@@ -17,7 +17,7 @@ import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol";
import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol";
contract L1CrossDomainMessenger_Test is Bridge_Initializer {
contract L1CrossDomainMessenger_Test is CommonTest {
/// @dev The receiver address
address recipient = address(0xabbaacdc);
......@@ -742,7 +742,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
/// @dev A regression test against a reentrancy vulnerability in the CrossDomainMessenger contract, which
/// was possible by intercepting and sandwhiching a signed Safe Transaction to upgrade it.
contract L1CrossDomainMessenger_ReinitReentryTest is Bridge_Initializer {
contract L1CrossDomainMessenger_ReinitReentryTest is CommonTest {
bool attacked;
// Common values used across functions
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Contracts
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
......@@ -25,7 +25,7 @@ contract TestERC721 is ERC721 {
}
}
contract L1ERC721Bridge_Test is Bridge_Initializer {
contract L1ERC721Bridge_Test is CommonTest {
TestERC721 internal localToken;
TestERC721 internal remoteToken;
uint256 internal constant tokenId = 1;
......@@ -315,7 +315,7 @@ contract L1ERC721Bridge_Test is Bridge_Initializer {
}
}
contract L1ERC721Bridge_Pause_Test is Bridge_Initializer {
contract L1ERC721Bridge_Pause_Test is CommonTest {
/// @dev Verifies that the `paused` accessor returns the same value as the `paused` function of the
/// `superchainConfig`.
function test_paused_succeeds() external view {
......@@ -343,7 +343,7 @@ contract L1ERC721Bridge_Pause_Test is Bridge_Initializer {
}
}
contract L1ERC721Bridge_Pause_TestFail is Bridge_Initializer {
contract L1ERC721Bridge_Pause_TestFail is CommonTest {
/// @dev Sets up the test by pausing the bridge, giving ether to the bridge and mocking
/// the calls to the xDomainMessageSender so that it returns the correct value.
function setUp() public override {
......
......@@ -3,7 +3,7 @@ pragma solidity 0.8.15;
// Testing
import { stdStorage, StdStorage } from "forge-std/Test.sol";
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Contracts
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
......@@ -19,7 +19,7 @@ import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol";
import { IL1StandardBridge } from "src/L1/interfaces/IL1StandardBridge.sol";
contract L1StandardBridge_Getter_Test is Bridge_Initializer {
contract L1StandardBridge_Getter_Test is CommonTest {
/// @dev Test that the accessors return the correct initialized values.
function test_getters_succeeds() external view {
assert(l1StandardBridge.l2TokenBridge() == address(l2StandardBridge));
......@@ -31,7 +31,7 @@ contract L1StandardBridge_Getter_Test is Bridge_Initializer {
}
}
contract L1StandardBridge_Initialize_Test is Bridge_Initializer {
contract L1StandardBridge_Initialize_Test is CommonTest {
/// @dev Test that the constructor sets the correct values.
/// @notice Marked virtual to be overridden in
/// test/kontrol/deployment/DeploymentSummary.t.sol
......@@ -58,7 +58,7 @@ contract L1StandardBridge_Initialize_Test is Bridge_Initializer {
}
}
contract L1StandardBridge_Pause_Test is Bridge_Initializer {
contract L1StandardBridge_Pause_Test is CommonTest {
/// @dev Verifies that the `paused` accessor returns the same value as the `paused` function of the
/// `superchainConfig`.
function test_paused_succeeds() external view {
......@@ -86,7 +86,7 @@ contract L1StandardBridge_Pause_Test is Bridge_Initializer {
}
}
contract L1StandardBridge_Pause_TestFail is Bridge_Initializer {
contract L1StandardBridge_Pause_TestFail is CommonTest {
/// @dev Sets up the test by pausing the bridge, giving ether to the bridge and mocking
/// the calls to the xDomainMessageSender so that it returns the correct value.
function setUp() public override {
......@@ -157,9 +157,9 @@ contract L1StandardBridge_Pause_TestFail is Bridge_Initializer {
}
}
contract L1StandardBridge_Initialize_TestFail is Bridge_Initializer { }
contract L1StandardBridge_Initialize_TestFail is CommonTest { }
contract L1StandardBridge_Receive_Test is Bridge_Initializer {
contract L1StandardBridge_Receive_Test is CommonTest {
/// @dev Tests receive bridges ETH successfully.
function test_receive_succeeds() external {
assertEq(address(optimismPortal).balance, 0);
......@@ -190,7 +190,7 @@ contract L1StandardBridge_Receive_Test is Bridge_Initializer {
}
}
contract L1StandardBridge_Receive_TestFail is Bridge_Initializer {
contract L1StandardBridge_Receive_TestFail is CommonTest {
/// @dev Tests receive function reverts with custom gas token.
function testFuzz_receive_customGasToken_reverts(uint256 _value) external {
vm.prank(alice, alice);
......@@ -207,7 +207,7 @@ contract L1StandardBridge_Receive_TestFail is Bridge_Initializer {
}
}
contract PreBridgeETH is Bridge_Initializer {
contract PreBridgeETH is CommonTest {
/// @dev Asserts the expected calls and events for bridging ETH depending
/// on whether the bridge call is legacy or not.
function _preBridgeETH(bool isLegacy, uint256 value) internal {
......@@ -285,7 +285,7 @@ contract L1StandardBridge_DepositETH_Test is PreBridgeETH {
}
}
contract L1StandardBridge_DepositETH_TestFail is Bridge_Initializer {
contract L1StandardBridge_DepositETH_TestFail is CommonTest {
/// @dev Tests that depositing ETH reverts if the call is not from an EOA.
function test_depositETH_notEoa_reverts() external {
vm.etch(alice, address(L1Token).code);
......@@ -331,7 +331,7 @@ contract L1StandardBridge_BridgeETH_TestFail is PreBridgeETH {
}
}
contract PreBridgeETHTo is Bridge_Initializer {
contract PreBridgeETHTo is CommonTest {
/// @dev Asserts the expected calls and events for bridging ETH to a different
/// address depending on whether the bridge call is legacy or not.
function _preBridgeETHTo(bool isLegacy, uint256 value) internal {
......@@ -411,7 +411,7 @@ contract L1StandardBridge_DepositETHTo_Test is PreBridgeETHTo {
}
}
contract L1StandardBridge_DepositETHTo_TestFail is Bridge_Initializer {
contract L1StandardBridge_DepositETHTo_TestFail is CommonTest {
/// @dev Tests that depositETHTo reverts with custom gas token.
function testFuzz_depositETHTo_customGasToken_reverts(
uint256 _value,
......@@ -463,7 +463,7 @@ contract L1StandardBridge_BridgeETHTo_TestFail is PreBridgeETHTo {
}
}
contract L1StandardBridge_DepositERC20_Test is Bridge_Initializer {
contract L1StandardBridge_DepositERC20_Test is CommonTest {
using stdStorage for StdStorage;
// depositERC20
......@@ -540,7 +540,7 @@ contract L1StandardBridge_DepositERC20_Test is Bridge_Initializer {
}
}
contract L1StandardBridge_DepositERC20_TestFail is Bridge_Initializer {
contract L1StandardBridge_DepositERC20_TestFail is CommonTest {
/// @dev Tests that depositing an ERC20 to the bridge reverts
/// if the caller is not an EOA.
function test_depositERC20_notEoa_reverts() external {
......@@ -553,7 +553,7 @@ contract L1StandardBridge_DepositERC20_TestFail is Bridge_Initializer {
}
}
contract L1StandardBridge_DepositERC20To_Test is Bridge_Initializer {
contract L1StandardBridge_DepositERC20To_Test is CommonTest {
/// @dev Tests that depositing ERC20 to the bridge succeeds when
/// sent to a different address.
/// Bridge deposits are updated.
......@@ -622,7 +622,7 @@ contract L1StandardBridge_DepositERC20To_Test is Bridge_Initializer {
}
}
contract L1StandardBridge_FinalizeETHWithdrawal_Test is Bridge_Initializer {
contract L1StandardBridge_FinalizeETHWithdrawal_Test is CommonTest {
using stdStorage for StdStorage;
/// @dev Tests that finalizing an ETH withdrawal succeeds.
......@@ -654,7 +654,7 @@ contract L1StandardBridge_FinalizeETHWithdrawal_Test is Bridge_Initializer {
}
}
contract L1StandardBridge_FinalizeETHWithdrawal_TestFail is Bridge_Initializer {
contract L1StandardBridge_FinalizeETHWithdrawal_TestFail is CommonTest {
/// @dev Tests that finalizeETHWithdrawal reverts with custom gas token.
function testFuzz_finalizeETHWithdrawal_customGasToken_reverts(
uint256 _value,
......@@ -678,7 +678,7 @@ contract L1StandardBridge_FinalizeETHWithdrawal_TestFail is Bridge_Initializer {
}
}
contract L1StandardBridge_FinalizeERC20Withdrawal_Test is Bridge_Initializer {
contract L1StandardBridge_FinalizeERC20Withdrawal_Test is CommonTest {
using stdStorage for StdStorage;
/// @dev Tests that finalizing an ERC20 withdrawal succeeds.
......@@ -717,7 +717,7 @@ contract L1StandardBridge_FinalizeERC20Withdrawal_Test is Bridge_Initializer {
}
}
contract L1StandardBridge_FinalizeERC20Withdrawal_TestFail is Bridge_Initializer {
contract L1StandardBridge_FinalizeERC20Withdrawal_TestFail is CommonTest {
/// @dev Tests that finalizing an ERC20 withdrawal reverts if the caller is not the L2 bridge.
function test_finalizeERC20Withdrawal_notMessenger_reverts() external {
vm.mockCall(
......@@ -743,7 +743,7 @@ contract L1StandardBridge_FinalizeERC20Withdrawal_TestFail is Bridge_Initializer
}
}
contract L1StandardBridge_FinalizeBridgeETH_Test is Bridge_Initializer {
contract L1StandardBridge_FinalizeBridgeETH_Test is CommonTest {
/// @dev Tests that finalizing bridged ETH succeeds.
function test_finalizeBridgeETH_succeeds() external {
address messenger = address(l1StandardBridge.messenger());
......@@ -762,7 +762,7 @@ contract L1StandardBridge_FinalizeBridgeETH_Test is Bridge_Initializer {
}
}
contract L1StandardBridge_FinalizeBridgeETH_TestFail is Bridge_Initializer {
contract L1StandardBridge_FinalizeBridgeETH_TestFail is CommonTest {
/// @dev Tests that finalizing bridged reverts with custom gas token.
function testFuzz_finalizeBridgeETH_customGasToken_reverts(uint256 _value, bytes calldata _extraData) external {
vm.mockCall(
......
......@@ -2,13 +2,13 @@
pragma solidity 0.8.15;
// Testing utilities
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Libraries
import { Types } from "src/libraries/Types.sol";
// Test the implementations of the FeeVault
contract FeeVault_Test is Bridge_Initializer {
contract FeeVault_Test is CommonTest {
/// @dev Tests that the constructor sets the correct values.
function test_constructor_baseFeeVault_succeeds() external view {
assertEq(baseFeeVault.RECIPIENT(), deploy.cfg().baseFeeVaultRecipient());
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing utilities
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Libraries
import { Hashing } from "src/libraries/Hashing.sol";
......@@ -23,7 +23,7 @@ contract XDomainSetter2 is CrossDomainOwnable2 {
}
}
contract CrossDomainOwnable2_Test is Bridge_Initializer {
contract CrossDomainOwnable2_Test is CommonTest {
XDomainSetter2 setter;
/// @dev Sets up the test suite.
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing utilities
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Libraries
import { Hashing } from "src/libraries/Hashing.sol";
......@@ -23,7 +23,7 @@ contract XDomainSetter3 is CrossDomainOwnable3 {
}
}
contract CrossDomainOwnable3_Test is Bridge_Initializer {
contract CrossDomainOwnable3_Test is CommonTest {
XDomainSetter3 setter;
/// @dev CrossDomainOwnable3.sol transferOwnership event
......
......@@ -2,13 +2,13 @@
pragma solidity 0.8.15;
// Testing utilities
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Libraries
import { Types } from "src/libraries/Types.sol";
// Test the implementations of the FeeVault
contract FeeVault_Test is Bridge_Initializer {
contract FeeVault_Test is CommonTest {
/// @dev Tests that the constructor sets the correct values.
function test_constructor_l1FeeVault_succeeds() external view {
assertEq(l1FeeVault.RECIPIENT(), deploy.cfg().l1FeeVaultRecipient());
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { Reverter } from "test/mocks/Callers.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
......@@ -16,7 +16,7 @@ import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol";
import { IL2CrossDomainMessenger } from "src/L2/interfaces/IL2CrossDomainMessenger.sol";
import { IL2ToL1MessagePasser } from "src/L2/interfaces/IL2ToL1MessagePasser.sol";
contract L2CrossDomainMessenger_Test is Bridge_Initializer {
contract L2CrossDomainMessenger_Test is CommonTest {
/// @dev Receiver address for testing
address recipient = address(0xabbaacdc);
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Contracts
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
......@@ -33,7 +33,7 @@ contract TestMintableERC721 is OptimismMintableERC721 {
}
}
contract L2ERC721Bridge_Test is Bridge_Initializer {
contract L2ERC721Bridge_Test is CommonTest {
TestMintableERC721 internal localToken;
TestERC721 internal remoteToken;
uint256 internal constant tokenId = 1;
......
......@@ -4,7 +4,7 @@ pragma solidity 0.8.15;
// Testing
import { stdStorage, StdStorage } from "forge-std/Test.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Contracts
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
......@@ -21,7 +21,7 @@ import { IStandardBridge } from "src/universal/interfaces/IStandardBridge.sol";
import { IL2ToL1MessagePasser } from "src/L2/interfaces/IL2ToL1MessagePasser.sol";
import { IL2StandardBridge } from "src/L2/interfaces/IL2StandardBridge.sol";
contract L2StandardBridge_Test is Bridge_Initializer {
contract L2StandardBridge_Test is CommonTest {
using stdStorage for StdStorage;
/// @dev Test that the bridge's constructor sets the correct values.
......@@ -275,7 +275,7 @@ contract L2StandardBridge_Test is Bridge_Initializer {
}
}
contract PreBridgeERC20 is Bridge_Initializer {
contract PreBridgeERC20 is CommonTest {
/// @dev Sets up expected calls and emits for a successful ERC20 withdrawal.
function _preBridgeERC20(bool _isLegacy, address _l2Token) internal {
// Alice has 100 L2Token
......@@ -401,7 +401,7 @@ contract L2StandardBridge_BridgeERC20_Test is PreBridgeERC20 {
}
}
contract PreBridgeERC20To is Bridge_Initializer {
contract PreBridgeERC20To is CommonTest {
// withdrawTo and BridgeERC20To should behave the same when transferring ERC20 tokens
// so they should share the same setup and expectEmit calls
function _preBridgeERC20To(bool _isLegacy, address _l2Token) internal {
......@@ -501,7 +501,7 @@ contract L2StandardBridge_BridgeERC20To_Test is PreBridgeERC20To {
}
}
contract L2StandardBridge_Bridge_Test is Bridge_Initializer {
contract L2StandardBridge_Bridge_Test is CommonTest {
/// @dev Tests that `finalizeBridgeETH` reverts if the recipient is the other bridge.
function test_finalizeBridgeETH_sendToSelf_reverts() external {
vm.mockCall(
......@@ -622,7 +622,7 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer {
}
}
contract L2StandardBridge_FinalizeBridgeETH_Test is Bridge_Initializer {
contract L2StandardBridge_FinalizeBridgeETH_Test is CommonTest {
/// @dev Tests that `finalizeBridgeETH` succeeds.
function test_finalizeBridgeETH_succeeds() external {
address messenger = address(l2StandardBridge.messenger());
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Interfaces
import { IMintableAndBurnableERC20 } from "src/L2/interfaces/IMintableAndBurnableERC20.sol";
......@@ -13,7 +13,7 @@ import { IOptimismMintableERC20 } from "src/universal/interfaces/IOptimismMintab
import { ILegacyMintableERC20 } from "src/universal/OptimismMintableERC20.sol";
import { IOptimismERC20Factory } from "src/L2/interfaces/IOptimismERC20Factory.sol";
contract L2StandardBridgeInterop_Test is Bridge_Initializer {
contract L2StandardBridgeInterop_Test is CommonTest {
/// @notice Emitted when a conversion is made.
event Converted(address indexed from, address indexed to, address indexed caller, uint256 amount);
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing utilities
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Libraries
import { Predeploys } from "src/libraries/Predeploys.sol";
......@@ -10,7 +10,7 @@ import { IBeacon } from "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
/// @title OptimismSuperchainERC20BeaconTest
/// @notice Contract for testing the OptimismSuperchainERC20Beacon contract.
contract OptimismSuperchainERC20BeaconTest is Bridge_Initializer {
contract OptimismSuperchainERC20BeaconTest is CommonTest {
/// @notice Sets up the test suite.
function setUp() public override {
super.enableInterop();
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing utilities
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Libraries
import { CREATE3, Bytes32AddressLib } from "@rari-capital/solmate/src/utils/CREATE3.sol";
......@@ -13,7 +13,7 @@ import { IERC20Metadata } from "@openzeppelin/contracts/interfaces/IERC20Metadat
/// @title OptimismSuperchainERC20FactoryTest
/// @notice Contract for testing the OptimismSuperchainERC20Factory contract.
contract OptimismSuperchainERC20FactoryTest is Bridge_Initializer {
contract OptimismSuperchainERC20FactoryTest is CommonTest {
using Bytes32AddressLib for bytes32;
event OptimismSuperchainERC20Created(
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing utilities
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Libraries
import { Predeploys } from "src/libraries/Predeploys.sol";
......@@ -17,7 +17,7 @@ import { IERC7802 } from "src/L2/interfaces/IERC7802.sol";
/// @title SuperchainTokenBridgeTest
/// @notice Contract for testing the SuperchainTokenBridge contract.
contract SuperchainTokenBridgeTest is Bridge_Initializer {
contract SuperchainTokenBridgeTest is CommonTest {
address internal constant ZERO_ADDRESS = address(0);
string internal constant NAME = "SuperchainERC20";
string internal constant SYMBOL = "OSE";
......
......@@ -5,12 +5,11 @@ import { StdUtils } from "forge-std/StdUtils.sol";
import { Vm } from "forge-std/Vm.sol";
import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol";
import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMessenger.sol";
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
import { Constants } from "src/libraries/Constants.sol";
import { Encoding } from "src/libraries/Encoding.sol";
import { Hashing } from "src/libraries/Hashing.sol";
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
contract RelayActor is StdUtils {
// Storage slot of the l2Sender
......@@ -88,7 +87,7 @@ contract RelayActor is StdUtils {
}
}
contract XDM_MinGasLimits is Bridge_Initializer {
contract XDM_MinGasLimits is CommonTest {
RelayActor actor;
function init(bool doFail) public virtual {
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { CommonTest } from "test/setup/CommonTest.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { OptimismMintableERC20 } from "src/universal/OptimismMintableERC20.sol";
import { LegacyMintableERC20 } from "src/legacy/LegacyMintableERC20.sol";
/// @title Bridge_Initializer
/// @dev This contract extends the CommonTest contract with token deployments
/// meant to be used with the bridge contracts.
contract Bridge_Initializer is CommonTest {
ERC20 L1Token;
ERC20 BadL1Token;
OptimismMintableERC20 L2Token;
LegacyMintableERC20 LegacyL2Token;
ERC20 NativeL2Token;
ERC20 BadL2Token;
OptimismMintableERC20 RemoteL1Token;
function setUp() public virtual override {
super.setUp();
L1Token = new ERC20("Native L1 Token", "L1T");
LegacyL2Token = new LegacyMintableERC20({
_l2Bridge: address(l2StandardBridge),
_l1Token: address(L1Token),
_name: string.concat("LegacyL2-", L1Token.name()),
_symbol: string.concat("LegacyL2-", L1Token.symbol())
});
vm.label(address(LegacyL2Token), "LegacyMintableERC20");
// Deploy the L2 ERC20 now
L2Token = OptimismMintableERC20(
l2OptimismMintableERC20Factory.createStandardL2Token(
address(L1Token),
string(abi.encodePacked("L2-", L1Token.name())),
string(abi.encodePacked("L2-", L1Token.symbol()))
)
);
BadL2Token = OptimismMintableERC20(
l2OptimismMintableERC20Factory.createStandardL2Token(
address(1),
string(abi.encodePacked("L2-", L1Token.name())),
string(abi.encodePacked("L2-", L1Token.symbol()))
)
);
NativeL2Token = new ERC20("Native L2 Token", "L2T");
RemoteL1Token = OptimismMintableERC20(
l1OptimismMintableERC20Factory.createStandardL2Token(
address(NativeL2Token),
string(abi.encodePacked("L1-", NativeL2Token.name())),
string(abi.encodePacked("L1-", NativeL2Token.symbol()))
)
);
BadL1Token = OptimismMintableERC20(
l1OptimismMintableERC20Factory.createStandardL2Token(
address(1),
string(abi.encodePacked("L1-", NativeL2Token.name())),
string(abi.encodePacked("L1-", NativeL2Token.symbol()))
)
);
}
}
......@@ -6,7 +6,9 @@ import { Setup } from "test/setup/Setup.sol";
import { Events } from "test/setup/Events.sol";
import { FFIInterface } from "test/setup/FFIInterface.sol";
import { Constants } from "src/libraries/Constants.sol";
import "scripts/deploy/DeployConfig.s.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { OptimismMintableERC20 } from "src/universal/OptimismMintableERC20.sol";
import { LegacyMintableERC20 } from "src/legacy/LegacyMintableERC20.sol";
/// @title CommonTest
/// @dev An extenstion to `Test` that sets up the optimism smart contracts.
......@@ -23,6 +25,14 @@ contract CommonTest is Test, Setup, Events {
address customGasToken;
bool useInteropOverride;
ERC20 L1Token;
ERC20 BadL1Token;
OptimismMintableERC20 L2Token;
LegacyMintableERC20 LegacyL2Token;
ERC20 NativeL2Token;
ERC20 BadL2Token;
OptimismMintableERC20 RemoteL1Token;
function setUp() public virtual override {
alice = makeAddr("alice");
bob = makeAddr("bob");
......@@ -65,6 +75,56 @@ contract CommonTest is Test, Setup, Events {
Setup.L1();
// Deploy L2
Setup.L2();
// Call bridge initializer setup function
bridgeInitializerSetUp();
}
function bridgeInitializerSetUp() public {
L1Token = new ERC20("Native L1 Token", "L1T");
LegacyL2Token = new LegacyMintableERC20({
_l2Bridge: address(l2StandardBridge),
_l1Token: address(L1Token),
_name: string.concat("LegacyL2-", L1Token.name()),
_symbol: string.concat("LegacyL2-", L1Token.symbol())
});
vm.label(address(LegacyL2Token), "LegacyMintableERC20");
// Deploy the L2 ERC20 now
L2Token = OptimismMintableERC20(
l2OptimismMintableERC20Factory.createStandardL2Token(
address(L1Token),
string(abi.encodePacked("L2-", L1Token.name())),
string(abi.encodePacked("L2-", L1Token.symbol()))
)
);
BadL2Token = OptimismMintableERC20(
l2OptimismMintableERC20Factory.createStandardL2Token(
address(1),
string(abi.encodePacked("L2-", L1Token.name())),
string(abi.encodePacked("L2-", L1Token.symbol()))
)
);
NativeL2Token = new ERC20("Native L2 Token", "L2T");
RemoteL1Token = OptimismMintableERC20(
l1OptimismMintableERC20Factory.createStandardL2Token(
address(NativeL2Token),
string(abi.encodePacked("L1-", NativeL2Token.name())),
string(abi.encodePacked("L1-", NativeL2Token.symbol()))
)
);
BadL1Token = OptimismMintableERC20(
l1OptimismMintableERC20Factory.createStandardL2Token(
address(1),
string(abi.encodePacked("L1-", NativeL2Token.name())),
string(abi.encodePacked("L1-", NativeL2Token.symbol()))
)
);
}
/// @dev Helper function that wraps `TransactionDeposited` event.
......
......@@ -5,7 +5,6 @@ pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { Vm } from "forge-std/Vm.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
// Libraries
import { Types } from "src/libraries/Types.sol";
......@@ -110,7 +109,7 @@ contract GasBenchMark_OptimismPortal is CommonTest {
}
}
contract GasBenchMark_L1CrossDomainMessenger is Bridge_Initializer {
contract GasBenchMark_L1CrossDomainMessenger is CommonTest {
function test_sendMessage_benchmark_0() external {
vm.pauseGasMetering();
setPrevBaseFee(vm, address(optimismPortal), 1 gwei);
......@@ -132,7 +131,7 @@ contract GasBenchMark_L1CrossDomainMessenger is Bridge_Initializer {
}
}
contract GasBenchMark_L1StandardBridge_Deposit is Bridge_Initializer {
contract GasBenchMark_L1StandardBridge_Deposit is CommonTest {
function setUp() public virtual override {
super.setUp();
deal(address(L1Token), alice, 100000, true);
......@@ -181,7 +180,7 @@ contract GasBenchMark_L1StandardBridge_Deposit is Bridge_Initializer {
}
}
contract GasBenchMark_L1StandardBridge_Finalize is Bridge_Initializer {
contract GasBenchMark_L1StandardBridge_Finalize is CommonTest {
function setUp() public virtual override {
super.setUp();
deal(address(L1Token), address(l1StandardBridge), 100, true);
......
......@@ -3,7 +3,7 @@ pragma solidity 0.8.15;
// Testing utilities
import { Test } from "forge-std/Test.sol";
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Libraries
import { Predeploys } from "src/libraries/Predeploys.sol";
......@@ -14,7 +14,7 @@ import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMesseng
// CrossDomainMessenger_Test is for testing functionality which is common to both the L1 and L2
// CrossDomainMessenger contracts. For simplicity, we use the L1 Messenger as the test contract.
contract CrossDomainMessenger_BaseGas_Test is Bridge_Initializer {
contract CrossDomainMessenger_BaseGas_Test is CommonTest {
/// @dev Ensure that baseGas passes for the max value of _minGasLimit,
/// this is about 4 Billion.
function test_baseGas_succeeds() external view {
......@@ -110,7 +110,7 @@ contract ExternalRelay is Test {
/// @title CrossDomainMessenger_RelayMessage_Test
/// @notice Fuzz tests re-entrancy into the CrossDomainMessenger relayMessage function.
contract CrossDomainMessenger_RelayMessage_Test is Bridge_Initializer {
contract CrossDomainMessenger_RelayMessage_Test is CommonTest {
// Storage slot of the l2Sender
uint256 constant senderSlotIndex = 50;
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { IOptimismMintableERC20 } from "src/universal/interfaces/IOptimismMintableERC20.sol";
import { ILegacyMintableERC20 } from "src/universal/interfaces/ILegacyMintableERC20.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
contract OptimismMintableERC20_Test is Bridge_Initializer {
contract OptimismMintableERC20_Test is CommonTest {
event Mint(address indexed account, uint256 amount);
event Burn(address indexed account, uint256 amount);
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { NextImpl } from "test/mocks/NextImpl.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
......@@ -14,7 +14,7 @@ import { OptimismMintableERC20Factory } from "src/universal/OptimismMintableERC2
import { IProxy } from "src/universal/interfaces/IProxy.sol";
import { IOptimismMintableERC20Factory } from "src/universal/interfaces/IOptimismMintableERC20Factory.sol";
contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
contract OptimismMintableTokenFactory_Test is CommonTest {
event StandardL2TokenCreated(address indexed remoteToken, address indexed localToken);
event OptimismMintableERC20Created(address indexed localToken, address indexed remoteToken, address deployer);
......
......@@ -5,10 +5,10 @@ import { ERC721, IERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol
import { IERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { OptimismMintableERC721, IOptimismMintableERC721 } from "src/universal/OptimismMintableERC721.sol";
contract OptimismMintableERC721_Test is Bridge_Initializer {
contract OptimismMintableERC721_Test is CommonTest {
ERC721 internal L1NFT;
OptimismMintableERC721 internal L2NFT;
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { OptimismMintableERC721 } from "src/universal/OptimismMintableERC721.sol";
import { OptimismMintableERC721Factory } from "src/universal/OptimismMintableERC721Factory.sol";
contract OptimismMintableERC721Factory_Test is Bridge_Initializer {
contract OptimismMintableERC721Factory_Test is CommonTest {
event OptimismMintableERC721Created(address indexed localToken, address indexed remoteToken, address deployer);
function test_constructor_succeeds() external view {
......
......@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
// Testing
import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
// Scripts
import { ForgeArtifacts } from "scripts/libraries/ForgeArtifacts.sol";
......@@ -11,8 +11,7 @@ import { Process } from "scripts/libraries/Process.sol";
// Libraries
import { LibString } from "@solady/utils/LibString.sol";
import { Constants } from "src/libraries/Constants.sol";
import "src/dispute/lib/Types.sol";
import "scripts/deploy/Deployer.sol";
import { GameType } from "src/dispute/lib/Types.sol";
// Interfaces
import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol";
......@@ -26,7 +25,7 @@ import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistr
/// once. This contract inherits from `ERC721Bridge_Initializer` because it is the
/// deepest contract in the inheritance chain for setting up the system contracts.
/// For each L1 contract both the implementation and the proxy are tested.
contract Initializer_Test is Bridge_Initializer {
contract Initializer_Test is CommonTest {
/// @notice Contains the address of an `Initializable` contract and the calldata
/// used to initialize it.
struct InitializeableContract {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment