datahaven/contracts/test/ServiceManagerBase.t.sol
Facundo Farall 5baa789f52
feat: Relay Validators operator set through Snowbridge (#39)
In this PR:
1. Implement application-specific functionalities in the
`DataHavenServiceManager` contract:
    1. Registering of 3 operator sets: Validators, BSPs and MSPs.
    2. Allowlisted sign up of operators.
    3. Integration with Snowbridge to send message of new validator set.
2. Basic testing of the above functionalities.
3. Tests now use less mocked contracts (especially from EigenLayer).
4. Refactor of `SignUpOperator` script, which now supports the three
kinds of Operator sets.
2025-04-16 15:49:35 +00:00

58 lines
2.3 KiB
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
/* solhint-disable func-name-mixedcase */
import {Test, console} from "forge-std/Test.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol";
import {IRewardsCoordinator} from
"eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
import {StrategyBase} from "eigenlayer-contracts/src/contracts/strategies/StrategyBase.sol";
import {
IAllocationManagerErrors,
IAllocationManager
} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
import {ServiceManagerMock} from "./mocks/ServiceManagerMock.sol";
import {AVSDeployer} from "./utils/AVSDeployer.sol";
import {IServiceManager} from "../src/interfaces/IServiceManager.sol";
import {IServiceManagerUI} from "../src/interfaces/IServiceManagerUI.sol";
import {ServiceManagerBase} from "../src/middleware/ServiceManagerBase.sol";
contract ServiceManagerBaseTest is AVSDeployer {
function setUp() public virtual {
_deployMockEigenLayerAndAVS();
}
function beforeTestSetup(
bytes4 testSelector
) public pure returns (bytes[] memory beforeTestCalldata) {
if (testSelector == this.test_createOperatorSetsWithEmptyParams.selector) {
beforeTestCalldata = new bytes[](1);
beforeTestCalldata[0] = abi.encodePacked(this.test_registerAVS.selector);
}
}
function test_registerAVS() public {
vm.prank(avsOwner);
IServiceManagerUI(address(serviceManager)).updateAVSMetadataURI("https://example.com");
}
function test_registerAVSRevertsIfNotAVSOwner() public {
vm.prank(rewardsUpdater);
vm.expectRevert(bytes("Ownable: caller is not the owner"));
IServiceManagerUI(address(serviceManager)).updateAVSMetadataURI("https://example.com");
}
function test_createOperatorSetsWithEmptyParams() public {
vm.prank(avsOwner);
IAllocationManager.CreateSetParams[] memory emptyParams =
new IAllocationManager.CreateSetParams[](0);
ServiceManagerBase(address(serviceManager)).createOperatorSets(emptyParams);
}
function test_returnsAVSAddress() public view {
assertEq(serviceManager.avs(), address(serviceManager));
}
}