Skip to content

Commit

Permalink
add AVS upgrade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zodomo committed Nov 26, 2024
1 parent b68f3d5 commit 39bd9bd
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contracts/avs/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ OmniAVS_canRegister_Test:test_canRegister_notAllowed() (gas: 225902)
OmniAVS_canRegister_Test:test_canRegister_notOperator() (gas: 120672)
OmniAVS_initialize_Test:test_initialize_defaultParams_succeeds() (gas: 3606316)
OmniAVS_syncWithOmni_Test:test_depositBeaconEth_succeeds() (gas: 638274)
OmniAVS_syncWithOmni_Test:test_unsupportedStrategyDeposit_succeeds() (gas: 1677678)
OmniAVS_syncWithOmni_Test:test_unsupportedStrategyDeposit_succeeds() (gas: 1677678)
OmniAVS_upgrade_Test:test_upgrade_invalidProxyOwner_reverts() (gas: 2698429)
OmniAVS_upgrade_Test:test_upgrade_succeeds() (gas: 2756363)
63 changes: 63 additions & 0 deletions contracts/avs/test/OmniAVS_upgrade.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity =0.8.12;

import { Base } from "./common/Base.sol";

import { OmniAVS } from "src/OmniAVS.sol";

import { IDelegationManager } from "src/ext/IDelegationManager.sol";
import { IAVSDirectory } from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol";
import { ITransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contract OmniAVS_upgrade_Test is Base {
function _checkAndHashState() internal view returns (bytes32) {
address _avsDirectory = omniAVS.avsDirectory();
uint32 _maxOperatorCount = omniAVS.maxOperatorCount();
uint64 _omniChainId = omniAVS.omniChainId();
uint64 _xcallGasLimitPerOperator = omniAVS.xcallGasLimitPerOperator();
uint64 _xcallBaseGasLimit = omniAVS.xcallBaseGasLimit();
uint96 _minOperatorStake = omniAVS.minOperatorStake();
bool _allowlistEnabled = omniAVS.allowlistEnabled();
address _ethStakeInbox = omniAVS.ethStakeInbox();
address _omni = address(omniAVS.omni());

return keccak256(
abi.encode(
_avsDirectory,
_maxOperatorCount,
_omniChainId,
_xcallGasLimitPerOperator,
_xcallBaseGasLimit,
_minOperatorStake,
_allowlistEnabled,
_ethStakeInbox,
_omni
)
);
}

function test_upgrade_succeeds() public {
address impl =
address(new OmniAVS(IDelegationManager(address(delegation)), IAVSDirectory(address(avsDirectory))));
ITransparentUpgradeableProxy proxy = ITransparentUpgradeableProxy(address(omniAVS));

bytes32 beforeUpgradeHash = _checkAndHashState();

vm.prank(proxyAdminOwner);
proxyAdmin.upgrade(proxy, impl);

bytes32 afterUpgradeHash = _checkAndHashState();

assertEq(proxyAdmin.getProxyImplementation(proxy), impl);
assertEq(beforeUpgradeHash, afterUpgradeHash);
}

function test_upgrade_invalidProxyOwner_reverts() public {
address impl =
address(new OmniAVS(IDelegationManager(address(delegation)), IAVSDirectory(address(avsDirectory))));
ITransparentUpgradeableProxy proxy = ITransparentUpgradeableProxy(address(omniAVS));

vm.expectRevert("Ownable: caller is not the owner");
proxyAdmin.upgrade(proxy, impl);
}
}

0 comments on commit 39bd9bd

Please sign in to comment.