Skip to content

Commit

Permalink
test: socket registry (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 authored Dec 5, 2024
1 parent a80bfe9 commit 80f0f84
Showing 1 changed file with 49 additions and 0 deletions.
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);
}

}

0 comments on commit 80f0f84

Please sign in to comment.