Skip to content

Commit

Permalink
test: pauseability of main funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Jun 29, 2024
1 parent 555e4b7 commit b56ad1b
Showing 1 changed file with 99 additions and 8 deletions.
107 changes: 99 additions & 8 deletions contracts/test/validator-registry/avs/MevCommitAVSTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.20;

import "forge-std/Test.sol";
import "../../../contracts/validator-registry/avs/MevCommitAVS.sol";
import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";
import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol";
import {StrategyManagerMock} from "eigenlayer-contracts/src/test/mocks/StrategyManagerMock.sol";
Expand Down Expand Up @@ -93,13 +94,22 @@ contract MevCommitAVSTest is Test {
}

function testRegisterOperator() public {

address operator = address(0x888);
ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = ISignatureUtils.SignatureWithSaltAndExpiry({
signature: bytes("signature"),
salt: bytes32("salt"),
expiry: block.timestamp + 1 days
});

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(operator);
mevCommitAVS.registerOperator(operatorSignature);
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("sender must be an eigenlayer operator");
vm.prank(operator);
mevCommitAVS.registerOperator(operatorSignature);
Expand All @@ -124,6 +134,15 @@ contract MevCommitAVSTest is Test {
vm.roll(108);

address operator = address(0x888);

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(operator);
mevCommitAVS.requestOperatorDeregistration(operator);
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("operator must be registered");
vm.prank(operator);
mevCommitAVS.requestOperatorDeregistration(operator);
Expand Down Expand Up @@ -158,6 +177,15 @@ contract MevCommitAVSTest is Test {
vm.roll(11);

address operator = address(0x888);

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(operator);
mevCommitAVS.deregisterOperator(operator);
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("operator must be registered");
vm.prank(operator);
mevCommitAVS.deregisterOperator(operator);
Expand Down Expand Up @@ -222,6 +250,15 @@ contract MevCommitAVSTest is Test {
podOwners[0] = podOwner;

address otherAcct = address(0x777);

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(otherAcct);
mevCommitAVS.registerValidatorsByPodOwners(arrayValPubkeys, podOwners);
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("sender must be podOwner or delegated operator");
vm.prank(otherAcct);
mevCommitAVS.registerValidatorsByPodOwners(arrayValPubkeys, podOwners);
Expand Down Expand Up @@ -302,6 +339,14 @@ contract MevCommitAVSTest is Test {
valPubkeys[0] = bytes("valPubkey1");
valPubkeys[1] = bytes("valPubkey2");

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(podOwner);
mevCommitAVS.requestValidatorsDeregistration(valPubkeys);
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("validator must be registered");
vm.prank(podOwner);
mevCommitAVS.requestValidatorsDeregistration(valPubkeys);
Expand Down Expand Up @@ -347,6 +392,15 @@ contract MevCommitAVSTest is Test {
address podOwner = address(0x420);
bytes[] memory valPubkeys = new bytes[](1);
valPubkeys[0] = bytes("valPubkey1");

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(podOwner);
mevCommitAVS.deregisterValidators(valPubkeys);
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("validator must be registered");
vm.prank(podOwner);
mevCommitAVS.deregisterValidators(valPubkeys);
Expand Down Expand Up @@ -397,6 +451,15 @@ contract MevCommitAVSTest is Test {
address lstRestaker = address(0x34443);
address otherAcct = address(0x777);
bytes[] memory chosenVals = new bytes[](0);

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(lstRestaker);
mevCommitAVS.registerLSTRestaker(chosenVals);
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("sender must be delegated to an operator that is registered with MevCommitAVS");
vm.prank(otherAcct);
mevCommitAVS.registerLSTRestaker(chosenVals);
Expand Down Expand Up @@ -448,6 +511,15 @@ contract MevCommitAVSTest is Test {

function testRequestLSTRestakerDeregistration() public {
address otherAcct = address(0x777);

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(otherAcct);
mevCommitAVS.requestLSTRestakerDeregistration();
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("sender must be registered LST restaker");
vm.prank(otherAcct);
mevCommitAVS.requestLSTRestakerDeregistration();
Expand Down Expand Up @@ -482,6 +554,15 @@ contract MevCommitAVSTest is Test {
function testDeregisterLSTRestaker() public {

address otherAcct = address(0x777);

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(otherAcct);
mevCommitAVS.deregisterLSTRestaker();
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("sender must be registered LST restaker");
vm.prank(otherAcct);
mevCommitAVS.deregisterLSTRestaker();
Expand Down Expand Up @@ -533,6 +614,15 @@ contract MevCommitAVSTest is Test {
bytes[] memory valPubkeys = new bytes[](2);
valPubkeys[0] = bytes("valPubkey1");
valPubkeys[1] = bytes("valPubkey2");

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(freezeOracle);
mevCommitAVS.freeze(valPubkeys);
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("validator must be registered");
vm.prank(freezeOracle);
mevCommitAVS.freeze(valPubkeys);
Expand Down Expand Up @@ -645,6 +735,15 @@ contract MevCommitAVSTest is Test {
valPubkeys[1] = bytes("valPubkey2");

address newAccount = address(0x333333333);

vm.prank(owner);
mevCommitAVS.pause();
vm.expectRevert(PausableUpgradeable.EnforcedPause.selector);
vm.prank(newAccount);
mevCommitAVS.unfreeze(valPubkeys);
vm.prank(owner);
mevCommitAVS.unpause();

vm.expectRevert("validator must be registered");
vm.prank(newAccount);
mevCommitAVS.unfreeze(valPubkeys);
Expand Down Expand Up @@ -714,14 +813,6 @@ contract MevCommitAVSTest is Test {
assertFalse(mevCommitAVS.getValidatorRegInfo(valPubkeys[1]).deregRequestHeight.exists);
}

function testPause() public {
// TODO: list out all funcs that are affected
}

function testUnpause() public {
// TODO: list out all funcs that are affected
}

function testSetters() public {
// only owner for all
}
Expand Down

0 comments on commit b56ad1b

Please sign in to comment.