Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/contracts-bedrock/test/L1/L1StandardBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Predeploys } from "src/libraries/Predeploys.sol";
import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
import { Features } from "src/libraries/Features.sol";
import { DevFeatures } from "src/libraries/DevFeatures.sol";

// Interfaces
import { ICrossDomainMessenger } from "interfaces/universal/ICrossDomainMessenger.sol";
Expand Down Expand Up @@ -332,6 +333,7 @@ contract L1StandardBridge_Paused_Test is CommonTest {
contract L1StandardBridge_Receive_Test is CommonTest {
/// @notice Tests receive bridges ETH successfully.
function test_receive_succeeds() external {
skipIfDevFeatureEnabled(DevFeatures.CUSTOM_GAS_TOKEN);
uint256 portalBalanceBefore = address(optimismPortal2).balance;
uint256 ethLockboxBalanceBefore = address(ethLockbox).balance;

Expand Down Expand Up @@ -386,6 +388,7 @@ contract L1StandardBridge_DepositETH_Test is L1StandardBridge_TestInit {
/// Only EOA can call depositETH.
/// ETH ends up in the optimismPortal.
function test_depositETH_fromEOA_succeeds() external {
skipIfDevFeatureEnabled(DevFeatures.CUSTOM_GAS_TOKEN);
_preBridgeETH({ isLegacy: true, value: 500 });
uint256 portalBalanceBefore = address(optimismPortal2).balance;
uint256 ethLockboxBalanceBefore = address(ethLockbox).balance;
Expand All @@ -401,6 +404,7 @@ contract L1StandardBridge_DepositETH_Test is L1StandardBridge_TestInit {

/// @notice Tests that depositing ETH succeeds for an EOA using 7702 delegation.
function test_depositETH_fromEOA7702_succeeds() external {
skipIfDevFeatureEnabled(DevFeatures.CUSTOM_GAS_TOKEN);
// Set alice to have 7702 code.
vm.etch(alice, abi.encodePacked(hex"EF0100", address(0)));

Expand Down Expand Up @@ -435,6 +439,7 @@ contract L1StandardBridge_DepositETHTo_Test is L1StandardBridge_TestInit {
/// EOA or contract can call depositETHTo.
/// ETH ends up in the optimismPortal.
function test_depositETHTo_succeeds() external {
skipIfDevFeatureEnabled(DevFeatures.CUSTOM_GAS_TOKEN);
_preBridgeETHTo({ isLegacy: true, value: 600 });
uint256 portalBalanceBefore = address(optimismPortal2).balance;
uint256 ethLockboxBalanceBefore = address(ethLockbox).balance;
Expand All @@ -452,6 +457,7 @@ contract L1StandardBridge_DepositETHTo_Test is L1StandardBridge_TestInit {
/// @param _to Random recipient address
/// @param _amount Random ETH amount to deposit
function testFuzz_depositETHTo_randomRecipient_succeeds(address _to, uint256 _amount) external {
skipIfDevFeatureEnabled(DevFeatures.CUSTOM_GAS_TOKEN);
vm.assume(_to != address(0));
_amount = bound(_amount, 1, 10 ether);

Expand Down Expand Up @@ -780,6 +786,7 @@ contract L1StandardBridge_Uncategorized_Test is L1StandardBridge_TestInit {
/// Only EOA can call bridgeETH.
/// ETH ends up in the optimismPortal.
function test_bridgeETH_succeeds() external {
skipIfDevFeatureEnabled(DevFeatures.CUSTOM_GAS_TOKEN);
_preBridgeETH({ isLegacy: false, value: 500 });
uint256 portalBalanceBefore = address(optimismPortal2).balance;
uint256 ethLockboxBalanceBefore = address(ethLockbox).balance;
Expand All @@ -799,6 +806,7 @@ contract L1StandardBridge_Uncategorized_Test is L1StandardBridge_TestInit {
/// Only EOA can call bridgeETHTo.
/// ETH ends up in the optimismPortal.
function test_bridgeETHTo_succeeds() external {
skipIfDevFeatureEnabled(DevFeatures.CUSTOM_GAS_TOKEN);
_preBridgeETHTo({ isLegacy: false, value: 600 });
uint256 portalBalanceBefore = address(optimismPortal2).balance;
uint256 ethLockboxBalanceBefore = address(ethLockbox).balance;
Expand Down
12 changes: 12 additions & 0 deletions packages/contracts-bedrock/test/invariants/OptimismPortal2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ResourceMetering } from "src/L1/ResourceMetering.sol";
// Libraries
import { Constants } from "src/libraries/Constants.sol";
import { Types } from "src/libraries/Types.sol";
import { Features } from "src/libraries/Features.sol";
import "src/dispute/lib/Types.sol";

// Interfaces
Expand Down Expand Up @@ -67,6 +68,11 @@ contract OptimismPortal2_Depositor is StdUtils, ResourceMetering {
uint256 preDepositBalance = address(this).balance;
uint256 value = bound(preDepositvalue, 0, preDepositBalance);

// If custom gas token is enabled, set deposit value to 0
if (portal.systemConfig().isFeatureEnabled(Features.CUSTOM_GAS_TOKEN)) {
value = 0;
}

(, uint64 cachedPrevBoughtGas,) = ResourceMetering(address(portal)).params();
ResourceMetering.ResourceConfig memory rcfg = resourceConfig();
uint256 maxResourceLimit = uint64(rcfg.maxResourceLimit);
Expand Down Expand Up @@ -106,6 +112,12 @@ contract OptimismPortal2_Invariant_Harness is DisputeGameFactory_TestInit {
gasLimit: 100_000,
data: hex""
});

// If custom gas token is enabled, set deposit value to 0
if (systemConfig.isFeatureEnabled(Features.CUSTOM_GAS_TOKEN)) {
_defaultTx.value = 0;
}

// Get withdrawal proof data we can use for testing.
(_stateRoot, _storageRoot, _outputRoot, _withdrawalHash, _withdrawalProof) =
ffi.getProveWithdrawalTransactionInputs(_defaultTx);
Expand Down