@@ -15,7 +15,6 @@ import { Predeploys } from "src/libraries/Predeploys.sol";
1515import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol " ;
1616import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol " ;
1717import { Features } from "src/libraries/Features.sol " ;
18- import { DevFeatures } from "src/libraries/DevFeatures.sol " ;
1918
2019// Interfaces
2120import { ICrossDomainMessenger } from "interfaces/universal/ICrossDomainMessenger.sol " ;
@@ -333,7 +332,7 @@ contract L1StandardBridge_Paused_Test is CommonTest {
333332contract L1StandardBridge_Receive_Test is CommonTest {
334333 /// @notice Tests receive bridges ETH successfully.
335334 function test_receive_succeeds () external {
336- skipIfDevFeatureEnabled (DevFeatures .CUSTOM_GAS_TOKEN);
335+ skipIfSysFeatureEnabled (Features .CUSTOM_GAS_TOKEN);
337336 uint256 portalBalanceBefore = address (optimismPortal2).balance;
338337 uint256 ethLockboxBalanceBefore = address (ethLockbox).balance;
339338
@@ -377,6 +376,20 @@ contract L1StandardBridge_Receive_Test is CommonTest {
377376 (bool revertsAsExpected ,) = address (l1StandardBridge).call { value: 100 }(hex "" );
378377 assertTrue (revertsAsExpected, "expectRevert: call did not revert " );
379378 }
379+
380+ /// @notice Tests that receive reverts when custom gas token is enabled and value is sent.
381+ function testFuzz_receive_withCustomGasToken_reverts (uint256 _value ) external {
382+ skipIfSysFeatureDisabled (Features.CUSTOM_GAS_TOKEN);
383+
384+ _value = bound (_value, 1 , type (uint128 ).max);
385+ vm.deal (alice, _value);
386+
387+ vm.prank (alice, alice);
388+ vm.expectRevert (IOptimismPortal2.OptimismPortal_NotAllowedOnCGTMode.selector );
389+
390+ (bool revertsAsExpected ,) = address (l1StandardBridge).call { value: _value }(hex "" );
391+ assertTrue (revertsAsExpected, "expectRevert: call did not revert " );
392+ }
380393}
381394
382395/// @title L1StandardBridge_DepositETH_Test
@@ -388,7 +401,7 @@ contract L1StandardBridge_DepositETH_Test is L1StandardBridge_TestInit {
388401 /// Only EOA can call depositETH.
389402 /// ETH ends up in the optimismPortal.
390403 function test_depositETH_fromEOA_succeeds () external {
391- skipIfDevFeatureEnabled (DevFeatures .CUSTOM_GAS_TOKEN);
404+ skipIfSysFeatureEnabled (Features .CUSTOM_GAS_TOKEN);
392405 _preBridgeETH ({ isLegacy: true , value: 500 });
393406 uint256 portalBalanceBefore = address (optimismPortal2).balance;
394407 uint256 ethLockboxBalanceBefore = address (ethLockbox).balance;
@@ -404,7 +417,7 @@ contract L1StandardBridge_DepositETH_Test is L1StandardBridge_TestInit {
404417
405418 /// @notice Tests that depositing ETH succeeds for an EOA using 7702 delegation.
406419 function test_depositETH_fromEOA7702_succeeds () external {
407- skipIfDevFeatureEnabled (DevFeatures .CUSTOM_GAS_TOKEN);
420+ skipIfSysFeatureEnabled (Features .CUSTOM_GAS_TOKEN);
408421 // Set alice to have 7702 code.
409422 vm.etch (alice, abi.encodePacked (hex "EF0100 " , address (0 )));
410423
@@ -428,6 +441,32 @@ contract L1StandardBridge_DepositETH_Test is L1StandardBridge_TestInit {
428441 vm.prank (alice);
429442 l1StandardBridge.depositETH { value: 1 }(300 , hex "" );
430443 }
444+
445+ /// @notice Tests that depositETH reverts when custom gas token is enabled and value is sent.
446+ function testFuzz_depositETH_withCustomGasToken_reverts (uint256 _value , uint32 _minGasLimit ) external {
447+ skipIfSysFeatureDisabled (Features.CUSTOM_GAS_TOKEN);
448+
449+ _value = bound (_value, 1 , type (uint128 ).max);
450+ vm.deal (alice, _value);
451+
452+ vm.prank (alice, alice);
453+ vm.expectRevert (IOptimismPortal2.OptimismPortal_NotAllowedOnCGTMode.selector );
454+ l1StandardBridge.depositETH { value: _value }(_minGasLimit, hex "dead " );
455+ }
456+
457+ /// @notice Tests that depositETH reverts when custom gas token is enabled for EOA with 7702 delegation.
458+ function testFuzz_depositETH_fromEOA7702WithCustomGasToken_reverts (uint256 _value , uint32 _minGasLimit ) external {
459+ skipIfSysFeatureDisabled (Features.CUSTOM_GAS_TOKEN);
460+ _value = bound (_value, 1 , type (uint128 ).max);
461+
462+ // Set alice to have 7702 code.
463+ vm.etch (alice, abi.encodePacked (hex "EF0100 " , address (0 )));
464+
465+ vm.deal (alice, _value);
466+ vm.prank (alice, alice);
467+ vm.expectRevert (IOptimismPortal2.OptimismPortal_NotAllowedOnCGTMode.selector );
468+ l1StandardBridge.depositETH { value: _value }(_minGasLimit, hex "dead " );
469+ }
431470}
432471
433472/// @title L1StandardBridge_DepositETHTo_Test
@@ -439,7 +478,7 @@ contract L1StandardBridge_DepositETHTo_Test is L1StandardBridge_TestInit {
439478 /// EOA or contract can call depositETHTo.
440479 /// ETH ends up in the optimismPortal.
441480 function test_depositETHTo_succeeds () external {
442- skipIfDevFeatureEnabled (DevFeatures .CUSTOM_GAS_TOKEN);
481+ skipIfSysFeatureEnabled (Features .CUSTOM_GAS_TOKEN);
443482 _preBridgeETHTo ({ isLegacy: true , value: 600 });
444483 uint256 portalBalanceBefore = address (optimismPortal2).balance;
445484 uint256 ethLockboxBalanceBefore = address (ethLockbox).balance;
@@ -457,7 +496,7 @@ contract L1StandardBridge_DepositETHTo_Test is L1StandardBridge_TestInit {
457496 /// @param _to Random recipient address
458497 /// @param _amount Random ETH amount to deposit
459498 function testFuzz_depositETHTo_randomRecipient_succeeds (address _to , uint256 _amount ) external {
460- skipIfDevFeatureEnabled (DevFeatures .CUSTOM_GAS_TOKEN);
499+ skipIfSysFeatureEnabled (Features .CUSTOM_GAS_TOKEN);
461500 vm.assume (_to != address (0 ));
462501 _amount = bound (_amount, 1 , 10 ether);
463502
@@ -475,6 +514,23 @@ contract L1StandardBridge_DepositETHTo_Test is L1StandardBridge_TestInit {
475514 assertEq (address (optimismPortal2).balance, portalBalanceBefore + _amount);
476515 }
477516 }
517+
518+ /// @notice Tests that depositETHTo reverts when custom gas token is enabled and value is sent.
519+ function testFuzz_depositETHTo_withCustomGasToken_reverts (
520+ address _to ,
521+ uint256 _value ,
522+ uint32 _minGasLimit
523+ )
524+ external
525+ {
526+ skipIfSysFeatureDisabled (Features.CUSTOM_GAS_TOKEN);
527+ vm.assume (_to != address (0 ));
528+ _value = bound (_value, 1 , type (uint128 ).max);
529+ vm.deal (alice, _value);
530+ vm.prank (alice);
531+ vm.expectRevert (IOptimismPortal2.OptimismPortal_NotAllowedOnCGTMode.selector );
532+ l1StandardBridge.depositETHTo { value: _value }(_to, _minGasLimit, hex "dead " );
533+ }
478534}
479535
480536/// @title L1StandardBridge_DepositERC20_Test
@@ -786,7 +842,7 @@ contract L1StandardBridge_Uncategorized_Test is L1StandardBridge_TestInit {
786842 /// Only EOA can call bridgeETH.
787843 /// ETH ends up in the optimismPortal.
788844 function test_bridgeETH_succeeds () external {
789- skipIfDevFeatureEnabled (DevFeatures .CUSTOM_GAS_TOKEN);
845+ skipIfSysFeatureEnabled (Features .CUSTOM_GAS_TOKEN);
790846 _preBridgeETH ({ isLegacy: false , value: 500 });
791847 uint256 portalBalanceBefore = address (optimismPortal2).balance;
792848 uint256 ethLockboxBalanceBefore = address (ethLockbox).balance;
@@ -806,7 +862,7 @@ contract L1StandardBridge_Uncategorized_Test is L1StandardBridge_TestInit {
806862 /// Only EOA can call bridgeETHTo.
807863 /// ETH ends up in the optimismPortal.
808864 function test_bridgeETHTo_succeeds () external {
809- skipIfDevFeatureEnabled (DevFeatures .CUSTOM_GAS_TOKEN);
865+ skipIfSysFeatureEnabled (Features .CUSTOM_GAS_TOKEN);
810866 _preBridgeETHTo ({ isLegacy: false , value: 600 });
811867 uint256 portalBalanceBefore = address (optimismPortal2).balance;
812868 uint256 ethLockboxBalanceBefore = address (ethLockbox).balance;
@@ -878,4 +934,35 @@ contract L1StandardBridge_Uncategorized_Test is L1StandardBridge_TestInit {
878934 vm.expectRevert ("StandardBridge: cannot send to messenger " );
879935 l1StandardBridge.finalizeBridgeETH { value: 100 }(alice, messenger, 100 , hex "" );
880936 }
937+
938+ /// @notice Tests that bridgeETH reverts when custom gas token is enabled and value is sent.
939+ function testFuzz_bridgeETH_withCustomGasToken_reverts (uint256 _value , uint32 _minGasLimit ) external {
940+ skipIfSysFeatureDisabled (Features.CUSTOM_GAS_TOKEN);
941+
942+ _value = bound (_value, 1 , type (uint128 ).max);
943+ vm.deal (alice, _value);
944+
945+ vm.prank (alice, alice);
946+ vm.expectRevert (IOptimismPortal2.OptimismPortal_NotAllowedOnCGTMode.selector );
947+ l1StandardBridge.bridgeETH { value: _value }(_minGasLimit, hex "dead " );
948+ }
949+
950+ /// @notice Tests that bridgeETHTo reverts when custom gas token is enabled and value is sent.
951+ function testFuzz_bridgeETHTo_withCustomGasToken_reverts (
952+ address _to ,
953+ uint256 _value ,
954+ uint32 _minGasLimit
955+ )
956+ external
957+ {
958+ skipIfSysFeatureDisabled (Features.CUSTOM_GAS_TOKEN);
959+
960+ vm.assume (_to != address (0 ));
961+ _value = bound (_value, 1 , type (uint128 ).max);
962+ vm.deal (alice, _value);
963+
964+ vm.prank (alice);
965+ vm.expectRevert (IOptimismPortal2.OptimismPortal_NotAllowedOnCGTMode.selector );
966+ l1StandardBridge.bridgeETHTo { value: _value }(_to, _minGasLimit, hex "dead " );
967+ }
881968}
0 commit comments