Skip to content

Commit

Permalink
test: admin functions
Browse files Browse the repository at this point in the history
  • Loading branch information
neutiyoo committed May 9, 2024
1 parent 9c9811a commit f8453a4
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions contracts/test/MachServiceManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,47 @@ contract MachServiceManagerTest is AVSDeployer {
event OperatorDisallowed(address operator);
event AllowlistEnabled();
event AllowlistDisabled();
event AlertConfirmerChanged(address previousAddress, address newAddress);
event WhitelisterChanged(address previousAddress, address newAddress);
event QuorumThresholdPercentageChanged(uint8 thresholdPercentages);
event RollupChainIdUpdated(uint256 previousRollupChainId, uint256 newRollupChainId);

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

function test_SetConfirmer() public {
address newConfirmer = address(42);
vm.startPrank(proxyAdminOwner);
assertTrue(serviceManager.alertConfirmer() == proxyAdminOwner, "mismatch");
vm.expectEmit();
emit AlertConfirmerChanged(proxyAdminOwner, newConfirmer);
serviceManager.setConfirmer(newConfirmer);
assertTrue(serviceManager.alertConfirmer() == newConfirmer, "mismatch");
vm.stopPrank();
}

function test_SetConfirmer_RevertIfNotOwner() public {
vm.expectRevert("Ownable: caller is not the owner");
serviceManager.setConfirmer(address(42));
}

function test_SetWhitelister() public {
address newWhitelister = address(42);
vm.startPrank(proxyAdminOwner);
assertTrue(serviceManager.whitelister() == proxyAdminOwner, "mismatch");
vm.expectEmit();
emit WhitelisterChanged(proxyAdminOwner, newWhitelister);
serviceManager.setWhitelister(newWhitelister);
assertTrue(serviceManager.whitelister() == newWhitelister, "mismatch");
vm.stopPrank();
}

function test_SetWhitelister_RevertIfNotOwner() public {
vm.expectRevert("Ownable: caller is not the owner");
serviceManager.setWhitelister(address(42));
}

function test_AddToAllowlist() public {
vm.startPrank(proxyAdminOwner);
assertFalse(serviceManager.allowlist(defaultOperator), "mismatch");
Expand Down Expand Up @@ -112,4 +148,41 @@ contract MachServiceManagerTest is AVSDeployer {
serviceManager.enableAllowlist();
vm.stopPrank();
}

function test_UpdateQuorumThresholdPercentage() public {
vm.startPrank(proxyAdminOwner);
assertTrue(serviceManager.quorumThresholdPercentage() == 66, "mismatch");
vm.expectEmit();
emit QuorumThresholdPercentageChanged(76);
serviceManager.updateQuorumThresholdPercentage(76);
assertTrue(serviceManager.quorumThresholdPercentage() == 76, "mismatch");
vm.stopPrank();
}

function test_UpdateQuorumThresholdPercentage_RevertIfNotOwner() public {
vm.expectRevert("Ownable: caller is not the owner");
serviceManager.updateQuorumThresholdPercentage(76);
}

function test_UpdateQuorumThresholdPercentage_RevertIfInvalidQuorumThresholdPercentage() public {
vm.startPrank(proxyAdminOwner);
vm.expectRevert(InvalidQuorumThresholdPercentage.selector);
serviceManager.updateQuorumThresholdPercentage(101);
vm.stopPrank();
}

function test_UpdateRollupChainId() public {
vm.startPrank(proxyAdminOwner);
assertTrue(serviceManager.rollupChainId() == 1, "mismatch");
vm.expectEmit();
emit RollupChainIdUpdated(1, 42);
serviceManager.updateRollupChainId(42);
assertTrue(serviceManager.rollupChainId() == 42, "mismatch");
vm.stopPrank();
}

function test_UpdateRollupChainId_RevertIfNotOwner() public {
vm.expectRevert("Ownable: caller is not the owner");
serviceManager.updateRollupChainId(42);
}
}

0 comments on commit f8453a4

Please sign in to comment.