Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
f34502c
clean SystemDeploy.t.sol
jackchuma May 15, 2026
ae48f5a
clean SystemDeploy.t.sol
jackchuma May 15, 2026
49c2594
clean SystemDeploy.t.sol
jackchuma May 15, 2026
8e15c7c
clean SystemDeploy.t.sol
jackchuma May 15, 2026
3f9d3a2
clean SystemDeploy.t.sol
jackchuma May 15, 2026
4a3da72
clean SystemDeploy.t.sol
jackchuma May 15, 2026
e7ab3b2
clean SystemDeployAssertions.sol
jackchuma May 15, 2026
92d3955
clean SystemDeployAssertions.sol
jackchuma May 15, 2026
0f81dd3
clean CrossDomainMessenger.t.sol invariant
jackchuma May 15, 2026
2501e7b
clean CrossDomainMessenger.t.sol invariant
jackchuma May 15, 2026
22ce7db
clean CrossDomainMessenger.t.sol invariant
jackchuma May 15, 2026
d4593d4
clean CrossDomainMessenger.t.sol invariant
jackchuma May 15, 2026
374e79f
clean CrossDomainMessenger.t.sol invariant
jackchuma May 15, 2026
ab848fb
Refactor CrossDomainMessenger.t.sol: remove unused StdUtils import, a…
jackchuma May 15, 2026
876b2d8
Refactor CrossDomainMessenger.t.sol: simplify hash relay message logi…
jackchuma May 15, 2026
6edaaf3
Refactor CrossDomainMessenger.t.sol: update constructor to accept add…
jackchuma May 15, 2026
f696026
Enhance CrossDomainMessenger.t.sol: add comments for clarity, improve…
jackchuma May 15, 2026
9152272
Refactor CrossDomainMessenger.t.sol: update comments for clarity, res…
jackchuma May 15, 2026
b8dab8c
Update CrossDomainMessenger.t.sol: modify RelayActor constructor to a…
jackchuma May 15, 2026
76742f3
Refactor CrossDomainMessenger.t.sol: update RelayActor to include MAX…
jackchuma May 15, 2026
6dca3bf
Refactor CrossDomainMessenger.t.sol: rename doFail to shouldFail for …
jackchuma May 15, 2026
9e958e8
Refactor CrossDomainMessenger.t.sol: replace internal _assertRelayRes…
jackchuma May 15, 2026
b0b9947
Refactor SafeCall.t.sol: consolidate invariant tests into a base cont…
jackchuma May 15, 2026
8dda521
Enhance SafeCall.t.sol: add target selector for performSafeCallMinGas…
jackchuma May 16, 2026
ff84f3c
Refactor SafeCall.t.sol: simplify SafeCaller_Actor constructor by rem…
jackchuma May 16, 2026
1d540c1
Refactor SafeCall.t.sol: update SafeCaller_Actor constructor to accep…
jackchuma May 16, 2026
a460685
improve SafeCall.t.sol comments
jackchuma May 16, 2026
405adb7
Refactor AggregateVerifierTest.t.sol: streamline test initialization …
jackchuma May 16, 2026
a7f3498
Refactor AggregateVerifierTest.t.sol: streamline test cases by introd…
jackchuma May 16, 2026
8c86818
Refactor AggregateVerifierTest.t.sol: replace direct calls to delay a…
jackchuma May 16, 2026
5c1146f
Refactor AnchorStateRegistry.t.sol: introduce helper functions for mo…
jackchuma May 16, 2026
2f4df04
Refactor AnchorStateRegistry.t.sol: introduce additional helper funct…
jackchuma May 16, 2026
de5d31e
Refactor AnchorStateRegistry.t.sol: add helper functions for unauthor…
jackchuma May 16, 2026
99af85b
Refactor AnchorStateRegistry.t.sol: introduce constants for anchor st…
jackchuma May 16, 2026
83beebd
fmt
jackchuma May 16, 2026
8c7fbc0
Refactor Challenge.t.sol: streamline test cases by introducing helper…
jackchuma May 16, 2026
5171e68
Refactor Challenge.t.sol: simplify test cases by consolidating game c…
jackchuma May 16, 2026
3254bc8
Refactor Challenge.t.sol: enhance test clarity by replacing direct ga…
jackchuma May 16, 2026
d2e2e90
Refactor DelayedWETH.t.sol: rename test initialization contract for c…
jackchuma May 16, 2026
ceeb3bc
Refactor DelayedWETH.t.sol: change gas variable to immutable for effi…
jackchuma May 16, 2026
dcd7bc7
Refactor DelayedWETH.t.sol: remove unused fallback harness contracts,…
jackchuma May 16, 2026
3efd7ed
Refactor DisputeGameFactory.t.sol: introduce constants for default va…
jackchuma May 16, 2026
48bcc61
Refactor DisputeGameFactory.t.sol: introduce constants for aggregate …
jackchuma May 16, 2026
e317b44
Refactor DisputeGameFactory.t.sol: rename ownership revert expectatio…
jackchuma May 16, 2026
b02dce7
Refactor NitroEnclaveVerifier.t.sol: update variable visibility to in…
jackchuma May 16, 2026
9431558
Refactor NitroEnclaveVerifier.t.sol: introduce new proof selector con…
jackchuma May 16, 2026
8c7fd6c
Refactor NitroEnclaveVerifier.t.sol: introduce a constant for the fro…
jackchuma May 16, 2026
58ff569
Refactor Nullify.t.sol: streamline nullification tests by consolidati…
jackchuma May 16, 2026
89617f3
Refactor Nullify.t.sol: replace direct proof handling with dedicated …
jackchuma May 16, 2026
146df37
Refactor Nullify.t.sol: rename constant for proof claim delay for cla…
jackchuma May 16, 2026
4fb8853
Refactor TEEProverRegistry.t.sol: update variable visibility to immut…
jackchuma May 16, 2026
a2a219d
Refactor TEEProverRegistry.t.sol: remove redundant comments, streamli…
jackchuma May 16, 2026
763d7a8
Refactor TEEProverRegistry.t.sol: replace constant game type definiti…
jackchuma May 16, 2026
e2f84c8
Refactor TEEVerifier.t.sol: update MockAggregateVerifier to use immut…
jackchuma May 16, 2026
5a0adf2
Refactor TEEVerifier.t.sol: replace constant game type definition wit…
jackchuma May 16, 2026
19cdc80
Refactor BaseTest.t.sol: remove redundant comments, streamline variab…
jackchuma May 16, 2026
f547ea6
Enhance AggregateVerifierTest: integrate LibClone for address cloning…
jackchuma May 16, 2026
e0d834c
Update BaseTest.t.sol: upgrade Solidity version to 0.8.15, change var…
jackchuma May 16, 2026
25736e0
fmt
jackchuma May 16, 2026
8ef57aa
Refactor BalanceTrackerTest: streamline variable initialization by us…
jackchuma May 16, 2026
df12f6b
Refactor ETHLockbox tests: remove unused error declaration, streamlin…
jackchuma May 16, 2026
dfc4611
Refactor L1CrossDomainMessenger tests: simplify setup by consolidatin…
jackchuma May 17, 2026
2637ace
Refactor L1CrossDomainMessenger tests: replace index-based storage sl…
jackchuma May 17, 2026
5657f2a
Refactor L1CrossDomainMessenger tests: streamline message handling by…
jackchuma May 17, 2026
490c9d4
Refactor L1ERC721Bridge tests: introduce internal helper functions fo…
jackchuma May 17, 2026
c99a88d
Refactor L1ERC721Bridge tests: introduce DEFAULT_MIN_GAS_LIMIT consta…
jackchuma May 17, 2026
7451402
Refactor L1ERC721Bridge tests: introduce EXTRA_DATA constant for impr…
jackchuma May 17, 2026
ff108f5
Refactor L1StandardBridge tests: introduce internal helper functions …
jackchuma May 17, 2026
ec04012
Refactor L1StandardBridge tests: introduce internal helper functions …
jackchuma May 17, 2026
1378474
Refactor L1StandardBridge tests: introduce internal helper functions …
jackchuma May 17, 2026
7b2fa4e
Refactor OptimismPortal2 tests: change visibility of isUsingLockbox a…
jackchuma May 17, 2026
93d695b
Refactor OptimismPortal2 tests: introduce internal helper functions f…
jackchuma May 17, 2026
3f3b812
Refactor OptimismPortal2 tests: introduce internal helper functions f…
jackchuma May 17, 2026
c34afb2
Refactor ResourceMetering tests: introduce defaultResourceConfig func…
jackchuma May 17, 2026
7b4c277
Refactor ResourceMetering tests: streamline resource configuration se…
jackchuma May 17, 2026
0cfdd00
Refactor SuperchainConfig tests: introduce internal helper function f…
jackchuma May 17, 2026
132808e
Refactor SystemConfig tests: introduce internal helper functions for …
jackchuma May 17, 2026
bcef574
Refactor BaseFeeVault tests: remove hardcoded feeVaultName assignment…
jackchuma May 17, 2026
b6ac06b
Refactor FeeDisburser tests: introduce constants for wallet addresses…
jackchuma May 17, 2026
5236f28
Refactor FeeVault tests: remove unused IProxyAdmin import, introduce …
jackchuma May 17, 2026
d7e6d20
Refactor GasPriceOracle tests: remove redundant comments, introduce i…
jackchuma May 17, 2026
bab353e
Refactor L1Block tests: introduce internal helper functions for asser…
jackchuma May 17, 2026
cba7abd
Refactor L1FeeVault tests: remove redundant comments, streamline test…
jackchuma May 17, 2026
3447e28
Refactor L2CrossDomainMessenger tests: replace hardcoded values with …
jackchuma May 17, 2026
747e80d
Refactor L2ERC721Bridge tests: remove unused test contracts, replace …
jackchuma May 17, 2026
441e82e
Refactor L2StandardBridge tests: simplify function signatures by remo…
jackchuma May 17, 2026
534b910
Refactor L2ToL1MessagePasser tests: introduce an abstract test initia…
jackchuma May 17, 2026
2a21994
Refactor OperatorFeeVault tests: streamline test setup by removing ha…
jackchuma May 17, 2026
2955f11
Refactor OptimismMintableERC721 tests: replace hardcoded values with …
jackchuma May 17, 2026
ae218df
Refactor OptimismMintableERC721Factory tests: replace hardcoded value…
jackchuma May 17, 2026
cf3fe6b
Refactor SequencerFeeVault tests: streamline test setup by removing h…
jackchuma May 17, 2026
c76af2a
Refactor WETH tests: update function names for clarity, streamline as…
jackchuma May 17, 2026
f8d5b26
Refactor L1ChugSplashProxy tests: simplify test setup by introducing …
jackchuma May 17, 2026
7409728
Refactor ResolvedDelegateProxy tests: streamline test setup by introd…
jackchuma May 17, 2026
e025f27
Refactor LibGameId tests: enhance clarity by adding GameType import, …
jackchuma May 17, 2026
3b6e793
Refactor RLPReader tests: introduce an abstract base contract for reu…
jackchuma May 17, 2026
a11d386
Refactor RLPWriter tests: introduce an abstract base contract for reu…
jackchuma May 17, 2026
c074720
Refactor MerkleTrie tests: update import statements for error handlin…
jackchuma May 17, 2026
f84d48b
Refactor Bytes tests: streamline memory pointer management with new i…
jackchuma May 17, 2026
8401d7c
Refactor Constants tests: enhance clarity by removing redundant comme…
jackchuma May 17, 2026
e7b000b
Refactor Encoding tests: introduce internal helper functions for gene…
jackchuma May 17, 2026
6138771
Refactor EOA tests: replace abstract contract with direct test contra…
jackchuma May 17, 2026
3c1f7fb
Refactor Hashing tests: introduce an abstract base contract for share…
jackchuma May 17, 2026
d94831c
Refactor Predeploys tests: remove unnecessary omission check, streaml…
jackchuma May 17, 2026
e8dbf85
Refactor Preinstalls tests: introduce internal helper functions for p…
jackchuma May 17, 2026
817e3a1
Refactor SafeCall tests: introduce a CallBalances struct for improved…
jackchuma May 17, 2026
ea6f68a
Refactor SemverComp tests: streamline error handling by introducing i…
jackchuma May 17, 2026
4d869b1
Refactor DelegateCaller and GasBurner contracts: optimize gas handlin…
jackchuma May 17, 2026
76b7728
Refactor EIP1967Helper library: replace hardcoded storage slot consta…
jackchuma May 17, 2026
1571466
Update DevTEEProverRegistry contract: clarify documentation for the d…
jackchuma May 17, 2026
69c23ae
Refactor NextImpl contract: update import path for Initializable, enh…
jackchuma May 17, 2026
e006329
Refactor L2Genesis tests: streamline test functions by renaming for c…
jackchuma May 17, 2026
a0c1a1b
Refactor CommonTest contract: update console import, replace hardcode…
jackchuma May 17, 2026
cf2539f
Refactor Events contract: remove unused events to streamline the cont…
jackchuma May 17, 2026
f4aaa37
Refactor FeatureFlags contract: remove unused feature bitmap manageme…
jackchuma May 17, 2026
616dc00
Refactor FFIInterface contract: streamline command construction by in…
jackchuma May 17, 2026
ab276b5
Refactor ForkLive contract: remove unused imports and StdAssertions d…
jackchuma May 17, 2026
0c4e298
Refactor Setup contract: add DeployConfig import, streamline L2 genes…
jackchuma May 17, 2026
de512bd
Refactor Counter contract: initialize count variable without a defaul…
jackchuma May 17, 2026
a3d2de0
Refactor CrossDomainMessenger tests: enhance message relay functional…
jackchuma May 17, 2026
474f4ae
Refactor ExtendedPause tests: streamline pause and unpause logic by i…
jackchuma May 17, 2026
7246c2a
Refactor MultisigScript tests: simplify counter initialization, corre…
jackchuma May 17, 2026
1b54703
Refactor MultisigScriptDeposit tests: streamline deposit transaction …
jackchuma May 17, 2026
e79d6dd
Refactor OptimismMintableERC20 tests: introduce a helper function for…
jackchuma May 17, 2026
f002cea
Enhance OptimismMintableERC20Factory tests: introduce a constant for …
jackchuma May 17, 2026
1ca5be2
Refactor Proxy tests: streamline upgrade logic by introducing helper …
jackchuma May 17, 2026
b01854a
Refactor ProxyAdmin tests: replace hardcoded addresses with constants…
jackchuma May 17, 2026
498ad5d
Refactor ProxyAdminOwnedBase tests: replace hardcoded values with hel…
jackchuma May 17, 2026
93b5b10
Refactor ReinitializableBase tests: change visibility of test functio…
jackchuma May 17, 2026
1b9319a
Refactor StandardBridge tests: update import paths for legacy interfa…
jackchuma May 17, 2026
571576a
Refactor WETH98 tests: update contract initialization to use the WETH…
jackchuma May 17, 2026
65d6e8d
Refactor CBMulticall tests: streamline call creation with helper func…
jackchuma May 17, 2026
0b621a5
Remove redundant test description in AddressAliasHelper tests for imp…
jackchuma May 17, 2026
8f44af2
Refactor Initializable tests: streamline contract initialization by c…
jackchuma May 17, 2026
8a4a2b8
Refactor InitializableOZv5 tests: rename struct for clarity, consolid…
jackchuma May 17, 2026
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
203 changes: 102 additions & 101 deletions test/L1/BalanceTracker.t.sol

Large diffs are not rendered by default.

132 changes: 51 additions & 81 deletions test/L1/ETHLockbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.sol";
/// @title ETHLockbox_TestInit
/// @notice Base contract that sets up the testing environment for ETHLockbox tests.
abstract contract ETHLockbox_TestInit is CommonTest {
error InvalidInitialization();

event ETHLocked(IOptimismPortal2 indexed portal, uint256 amount);
event ETHUnlocked(IOptimismPortal2 indexed portal, uint256 amount);
event PortalAuthorized(IOptimismPortal2 indexed portal);
Expand All @@ -41,6 +39,28 @@ abstract contract ETHLockbox_TestInit is CommonTest {
// If the ETHLockbox system feature is not enabled, skip these tests.
skipIfSysFeatureDisabled(Features.ETH_LOCKBOX);
}

function _mockPortalSharedOwnerAndSuperchainConfig(IOptimismPortal2 _portal) internal {
vm.mockCall(
address(_portal), abi.encodeCall(IProxyAdminOwnedBase.proxyAdminOwner, ()), abi.encode(proxyAdminOwner)
);
vm.mockCall(
address(_portal), abi.encodeCall(IOptimismPortal2.superchainConfig, ()), abi.encode(superchainConfig)
);
}

function _authorizePortalIfNeeded(IOptimismPortal2 _portal) internal {
if (!ethLockbox.authorizedPortals(_portal)) {
vm.prank(proxyAdminOwner);
ethLockbox.authorizePortal(_portal);
}
}

function _mockLockboxSharedOwner(address _lockbox) internal {
vm.mockCall(
address(_lockbox), abi.encodeCall(IProxyAdminOwnedBase.proxyAdminOwner, ()), abi.encode(proxyAdminOwner)
);
}
}

/// @title ETHLockbox_Version_Test
Expand All @@ -56,6 +76,14 @@ contract ETHLockbox_Version_Test is ETHLockbox_TestInit {
/// @title ETHLockbox_Initialize_Test
/// @notice Test contract for the initialize function.
contract ETHLockbox_Initialize_Test is ETHLockbox_TestInit {
StorageSlot internal initializedSlot;

function setUp() public override {
super.setUp();

initializedSlot = ForgeArtifacts.getSlot("ETHLockbox", "_initialized");
}

/// @notice Tests the superchain config was correctly set during initialization.
function test_initialize_succeeds() public view {
assertEq(address(ethLockbox.systemConfig().superchainConfig()), address(superchainConfig));
Expand All @@ -67,14 +95,9 @@ contract ETHLockbox_Initialize_Test is ETHLockbox_TestInit {
/// but confirms that the initValue is not incremented incorrectly if an upgrade
/// function is not present.
function test_initialize_correctInitializerValue_succeeds() public view {
// Get the slot for _initialized.
StorageSlot memory slot = ForgeArtifacts.getSlot("ETHLockbox", "_initialized");

// Get the initializer value.
bytes32 slotVal = vm.load(address(ethLockbox), bytes32(slot.slot));
bytes32 slotVal = vm.load(address(ethLockbox), bytes32(initializedSlot.slot));
uint8 val = uint8(uint256(slotVal) & 0xFF);

// Assert that the initializer value matches the expected value.
assertEq(val, ethLockbox.initVersion());
}

Expand All @@ -85,11 +108,8 @@ contract ETHLockbox_Initialize_Test is ETHLockbox_TestInit {
// Prank as the not ProxyAdmin or ProxyAdmin owner.
vm.assume(_sender != address(proxyAdmin) && _sender != proxyAdminOwner);

// Get the slot for _initialized.
StorageSlot memory slot = ForgeArtifacts.getSlot("ETHLockbox", "_initialized");

// Set the initialized slot to 0.
vm.store(address(ethLockbox), bytes32(slot.slot), bytes32(0));
vm.store(address(ethLockbox), bytes32(initializedSlot.slot), bytes32(0));

// Expect the revert with `ProxyAdminOwnedBase_NotProxyAdminOrProxyAdminOwner` selector
vm.expectRevert(IProxyAdminOwnedBase.ProxyAdminOwnedBase_NotProxyAdminOrProxyAdminOwner.selector);
Expand Down Expand Up @@ -183,10 +203,9 @@ contract ETHLockbox_AuthorizePortal_Test is ETHLockbox_TestInit {
/// @notice Tests the `authorizePortal` function succeeds using the `optimismPortal2` address
/// as the portal.
function test_authorizePortal_succeeds() public {
// Calculate the correct storage slot for the mapping value
bytes32 mappingSlot = bytes32(uint256(1)); // position on the layout
StorageSlot memory authorizedPortalsSlot = ForgeArtifacts.getSlot("ETHLockbox", "authorizedPortals");
address key = address(optimismPortal2);
bytes32 slot = keccak256(abi.encode(key, mappingSlot));
bytes32 slot = keccak256(abi.encode(key, bytes32(authorizedPortalsSlot.slot)));

// Reset the authorization status to false
vm.store(address(ethLockbox), slot, bytes32(0));
Expand All @@ -203,21 +222,11 @@ contract ETHLockbox_AuthorizePortal_Test is ETHLockbox_TestInit {
assertTrue(ethLockbox.authorizedPortals(optimismPortal2));
}

/// @notice Tests the `authorizeLockbox` function succeeds
/// @notice Tests the `authorizePortal` function succeeds
function testFuzz_authorizePortal_succeeds(IOptimismPortal2 _portal) public {
assumeNotForgeAddress(address(_portal));

// Mock the admin owner of the portal to be the same as the current lockbox proxy admin
// owner
vm.mockCall(
address(_portal), abi.encodeCall(IProxyAdminOwnedBase.proxyAdminOwner, ()), abi.encode(proxyAdminOwner)
);

// Mock the SuperchainConfig on the portal to be the same as the SuperchainConfig on the
// Lockbox.
vm.mockCall(
address(_portal), abi.encodeCall(IOptimismPortal2.superchainConfig, ()), abi.encode(superchainConfig)
);
_mockPortalSharedOwnerAndSuperchainConfig(_portal);

// Expect the `PortalAuthorized` event to be emitted
vm.expectEmit(address(ethLockbox));
Expand Down Expand Up @@ -245,11 +254,7 @@ contract ETHLockbox_ReceiveLiquidity_Test is ETHLockbox_TestInit {
// Deal the value to the lockbox
deal(address(_lockbox), _value);

// Mock the admin owner of the lockbox to be the same as the current lockbox proxy admin
// owner
vm.mockCall(
address(_lockbox), abi.encodeCall(IProxyAdminOwnedBase.proxyAdminOwner, ()), abi.encode(proxyAdminOwner)
);
_mockLockboxSharedOwner(_lockbox);

// Authorize the lockbox if needed
if (!ethLockbox.authorizedLockboxes(IETHLockbox(_lockbox))) {
Expand Down Expand Up @@ -323,23 +328,10 @@ contract ETHLockbox_LockETH_Test is ETHLockbox_TestInit {
assumeNotForgeAddress(address(_portal));
vm.assume(address(_portal) != address(ethLockbox));

// Mock the admin owner of the portal to be the same as the current lockbox proxy admin
// owner
vm.mockCall(
address(_portal), abi.encodeCall(IProxyAdminOwnedBase.proxyAdminOwner, ()), abi.encode(proxyAdminOwner)
);

// Mock the SuperchainConfig on the portal to be the same as the SuperchainConfig on the
// lockbox.
vm.mockCall(
address(_portal), abi.encodeCall(IOptimismPortal2.superchainConfig, ()), abi.encode(superchainConfig)
);
_mockPortalSharedOwnerAndSuperchainConfig(_portal);

// Set the portal as an authorized portal if needed
if (!ethLockbox.authorizedPortals(_portal)) {
vm.prank(proxyAdminOwner);
ethLockbox.authorizePortal(_portal);
}
_authorizePortalIfNeeded(_portal);

// Deal the ETH amount to the portal
vm.deal(address(_portal), _amount);
Expand Down Expand Up @@ -450,49 +442,41 @@ contract ETHLockbox_UnlockETH_Test is ETHLockbox_TestInit {

/// @notice Tests the ETH is correctly unlocked when the caller is an authorized portal.
function testFuzz_unlockETH_multiplePortals_succeeds(IOptimismPortal2 _portal, uint256 _value) public {
// Since on the fork the `_portal` fuzzed address doesn't exist, we skip the test
if (isForkTest()) vm.skip(true);
assumeNotForgeAddress(address(_portal));
vm.assume(address(_portal) != address(ethLockbox));

// Mock the admin owner of the portal to be the same as the current lockbox proxy admin
// owner
vm.mockCall(
address(_portal), abi.encodeCall(IProxyAdminOwnedBase.proxyAdminOwner, ()), abi.encode(proxyAdminOwner)
);

// Mock the SuperchainConfig on the portal to be the same as the SuperchainConfig on the
// lockbox.

_mockPortalSharedOwnerAndSuperchainConfig(_portal);
vm.mockCall(
address(_portal), abi.encodeCall(IOptimismPortal2.superchainConfig, ()), abi.encode(superchainConfig)
address(_portal), abi.encodeCall(IOptimismPortal2.l2Sender, ()), abi.encode(Constants.DEFAULT_L2_SENDER)
);

// Set the portal as an authorized portal if needed
if (!ethLockbox.authorizedPortals(_portal)) {
vm.prank(proxyAdminOwner);
ethLockbox.authorizePortal(_portal);
}
_authorizePortalIfNeeded(_portal);

// Deal the ETH amount to the lockbox
vm.deal(address(ethLockbox), _value);

// Get the balance of the portal and lockbox before the unlock to compare later on the
// assertions
uint256 portalBalanceBefore = address(optimismPortal2).balance;
uint256 portalBalanceBefore = address(_portal).balance;
uint256 lockboxBalanceBefore = address(ethLockbox).balance;

// Expect `donateETH` function to be called on Portal
vm.expectCall(address(optimismPortal2), abi.encodeCall(IOptimismPortal2.donateETH, ()));
vm.expectCall(address(_portal), abi.encodeCall(IOptimismPortal2.donateETH, ()));

// Look for the emit of the `ETHUnlocked` event
vm.expectEmit(address(ethLockbox));
emit ETHUnlocked(optimismPortal2, _value);
emit ETHUnlocked(_portal, _value);

// Call the `unlockETH` function with the portal
vm.prank(address(optimismPortal2));
vm.prank(address(_portal));
ethLockbox.unlockETH(_value);

// Assert the portal's balance increased and the lockbox's balance decreased by the amount
// unlocked
assertEq(address(optimismPortal2).balance, portalBalanceBefore + _value);
assertEq(address(_portal).balance, portalBalanceBefore + _value);
assertEq(address(ethLockbox).balance, lockboxBalanceBefore - _value);
}
}
Expand Down Expand Up @@ -532,11 +516,7 @@ contract ETHLockbox_AuthorizeLockbox_Test is ETHLockbox_TestInit {
function testFuzz_authorizeLockbox_succeeds(address _lockbox) public {
assumeNotForgeAddress(_lockbox);

// Mock the admin owner of the lockbox to be the same as the current lockbox proxy admin
// owner
vm.mockCall(
address(_lockbox), abi.encodeCall(IProxyAdminOwnedBase.proxyAdminOwner, ()), abi.encode(proxyAdminOwner)
);
_mockLockboxSharedOwner(_lockbox);

// Expect the `LockboxAuthorized` event to be emitted
vm.expectEmit(address(ethLockbox));
Expand Down Expand Up @@ -611,16 +591,6 @@ contract ETHLockbox_MigrateLiquidity_Test is ETHLockbox_TestInit {
vm.prank(proxyAdminOwner);
IETHLockbox(destinationLockbox).authorizeLockbox(ethLockbox);

// Mock the calls for checks on the destination lockbox so it can receive the migration
vm.mockCall(
address(destinationLockbox),
abi.encodeCall(IProxyAdminOwnedBase.proxyAdminOwner, ()),
abi.encode(proxyAdminOwner)
);
vm.mockCall(
address(destinationLockbox), abi.encodeCall(IETHLockbox.authorizedLockboxes, (ethLockbox)), abi.encode(true)
);

// Deal the balance to both lockboxes
deal(address(ethLockbox), _originLockboxBalance);
deal(address(destinationLockbox), _destinationLockboxBalance);
Expand Down
Loading
Loading