Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: socket registry #327

Merged
merged 1 commit into from
Dec 5, 2024
Merged
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
49 changes: 49 additions & 0 deletions test/unit/SocketRegistryUnit.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.12;

import {SocketRegistry} from "../../src/SocketRegistry.sol";
import {IRegistryCoordinator} from "../../src/interfaces/IRegistryCoordinator.sol";
import "../utils/MockAVSDeployer.sol";

contract SocketRegistryUnitTests is MockAVSDeployer {

function setUp() virtual public {
_deployMockEigenLayerAndAVS();
}

function test_setOperatorSocket() public {
vm.startPrank(address(registryCoordinator));
socketRegistry.setOperatorSocket(defaultOperatorId, "testSocket");
assertEq(socketRegistry.getOperatorSocket(defaultOperatorId), "testSocket");
}

function test_setOperatorSocket_revert_notRegistryCoordinator() public {
vm.startPrank(address(0));
vm.expectRevert("SocketRegistry.onlyRegistryCoordinator: caller is not the RegistryCoordinator");
socketRegistry.setOperatorSocket(defaultOperatorId, "testSocket");
}

function test_migrateOperatorSockets() public {
bytes32[] memory operatorIds = new bytes32[](1);
operatorIds[0] = defaultOperatorId;
string[] memory sockets = new string[](1);
sockets[0] = "testSocket";

vm.startPrank(registryCoordinator.owner());
socketRegistry.migrateOperatorSockets(operatorIds, sockets);
assertEq(socketRegistry.getOperatorSocket(defaultOperatorId), "testSocket");
}

function test_migrateOperatorSockets_revert_notCoordinatorOwner() public {
bytes32[] memory operatorIds = new bytes32[](1);
operatorIds[0] = defaultOperatorId;
string[] memory sockets = new string[](1);
sockets[0] = "testSocket";

vm.startPrank(address(0));
vm.expectRevert("SocketRegistry.onlyCoordinatorOwner: caller is not the owner of the registryCoordinator");
socketRegistry.migrateOperatorSockets(operatorIds, sockets);
}

}
Loading