From 2f2a0b6c0ae23c098f75390fca338e769c9254cf Mon Sep 17 00:00:00 2001 From: Roman Kolpakov Date: Thu, 8 Aug 2024 14:25:31 +0300 Subject: [PATCH] feat: error cleanup --- contracts/DualGovernance.sol | 34 +++++++++---------- contracts/EmergencyProtectedTimelock.sol | 28 +++++++-------- contracts/Escrow.sol | 12 +++---- contracts/ResealManager.sol | 11 +++--- contracts/TimelockedGovernance.sol | 10 +++--- .../EmergencyActivationCommittee.sol | 2 +- .../EmergencyExecutionCommittee.sol | 4 +-- contracts/committees/HashConsensus.sol | 18 +++++----- contracts/committees/ResealCommittee.sol | 2 +- contracts/committees/TiebreakerCore.sol | 4 +-- .../committees/TiebreakerSubCommittee.sol | 2 +- contracts/libraries/EmergencyProtection.sol | 16 ++++----- contracts/libraries/EscrowState.sol | 5 ++- contracts/libraries/Proposers.sol | 15 ++++---- contracts/libraries/Tiebreaker.sol | 2 +- contracts/libraries/TimelockState.sol | 5 +-- test/scenario/escrow.t.sol | 12 +++---- test/scenario/happy-path-plan-b.t.sol | 10 +++--- test/scenario/timelocked-governance.t.sol | 4 +-- test/unit/EmergencyProtectedTimelock.t.sol | 32 ++++++++--------- test/unit/HashConsensus.t.sol | 10 +++--- test/unit/ResealManager.t.sol | 4 +-- test/unit/TimelockedGovernance.t.sol | 4 +-- test/unit/libraries/EmergencyProtection.t.sol | 4 +-- 24 files changed, 124 insertions(+), 126 deletions(-) diff --git a/contracts/DualGovernance.sol b/contracts/DualGovernance.sol index 61a78958..aa6f9ff7 100644 --- a/contracts/DualGovernance.sol +++ b/contracts/DualGovernance.sol @@ -26,10 +26,10 @@ contract DualGovernance is IDualGovernance { // Errors // --- + error CallerIsNotResealCommittee(address caller); + error CallerIsNotAdminExecutor(address caller); error InvalidConfigProvider(IDualGovernanceConfigProvider configProvider); - error NotResealCommittee(address account); error ProposalSubmissionBlocked(); - error InvalidAdminExecutor(address value); error ProposalSchedulingBlocked(uint256 proposalId); error ResealIsNotAllowedInNormalState(); @@ -104,7 +104,7 @@ contract DualGovernance is IDualGovernance { function submitProposal(ExternalCall[] calldata calls) external returns (uint256 proposalId) { _stateMachine.activateNextState(_configProvider.getDualGovernanceConfig(), ESCROW_MASTER_COPY); - _proposers.checkSenderIsProposer(); + _proposers.checkCallerIsProposer(); if (!_stateMachine.canSubmitProposal()) { revert ProposalSubmissionBlocked(); } @@ -123,7 +123,7 @@ contract DualGovernance is IDualGovernance { } function cancelAllPendingProposals() external { - _proposers.checkSenderIsAdminProposer(TIMELOCK.getAdminExecutor()); + _proposers.checkCallerIsAdminProposer(TIMELOCK.getAdminExecutor()); TIMELOCK.cancelAllNonExecutedProposals(); } @@ -146,7 +146,7 @@ contract DualGovernance is IDualGovernance { } function setConfigProvider(IDualGovernanceConfigProvider newConfigProvider) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _setConfigProvider(newConfigProvider); /// @dev the minAssetsLockDuration is kept as a storage variable in the signalling Escrow instance @@ -185,12 +185,12 @@ contract DualGovernance is IDualGovernance { // --- function registerProposer(address proposer, address executor) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _proposers.register(proposer, executor); } function unregisterProposer(address proposer) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _proposers.unregister(TIMELOCK.getAdminExecutor(), proposer); } @@ -215,35 +215,35 @@ contract DualGovernance is IDualGovernance { // --- function addTiebreakerSealableWithdrawalBlocker(address sealableWithdrawalBlocker) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _tiebreaker.addSealableWithdrawalBlocker(sealableWithdrawalBlocker, MAX_SEALABLE_WITHDRAWAL_BLOCKERS_COUNT); } function removeTiebreakerSealableWithdrawalBlocker(address sealableWithdrawalBlocker) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _tiebreaker.removeSealableWithdrawalBlocker(sealableWithdrawalBlocker); } function setTiebreakerCommittee(address tiebreakerCommittee) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _tiebreaker.setTiebreakerCommittee(tiebreakerCommittee); } function setTiebreakerActivationTimeout(Duration tiebreakerActivationTimeout) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _tiebreaker.setTiebreakerActivationTimeout( MIN_TIEBREAKER_ACTIVATION_TIMEOUT, tiebreakerActivationTimeout, MAX_TIEBREAKER_ACTIVATION_TIMEOUT ); } function tiebreakerResumeSealable(address sealable) external { - _tiebreaker.checkSenderIsTiebreakerCommittee(); + _tiebreaker.checkCallerIsTiebreakerCommittee(); _tiebreaker.checkTie(_stateMachine.getCurrentState(), _stateMachine.getNormalOrVetoCooldownStateExitedAt()); RESEAL_MANAGER.resume(sealable); } function tiebreakerScheduleProposal(uint256 proposalId) external { - _tiebreaker.checkSenderIsTiebreakerCommittee(); + _tiebreaker.checkCallerIsTiebreakerCommittee(); _tiebreaker.checkTie(_stateMachine.getCurrentState(), _stateMachine.getNormalOrVetoCooldownStateExitedAt()); TIMELOCK.schedule(proposalId); } @@ -268,7 +268,7 @@ contract DualGovernance is IDualGovernance { function resealSealable(address sealable) external { if (msg.sender != _resealCommittee) { - revert NotResealCommittee(msg.sender); + revert CallerIsNotResealCommittee(msg.sender); } if (_stateMachine.getCurrentState() == State.Normal) { revert ResealIsNotAllowedInNormalState(); @@ -277,7 +277,7 @@ contract DualGovernance is IDualGovernance { } function setResealCommittee(address resealCommittee) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _resealCommittee = resealCommittee; } @@ -298,9 +298,9 @@ contract DualGovernance is IDualGovernance { emit ConfigProviderSet(newConfigProvider); } - function _checkSenderIsAdminExecutor() internal view { + function _checkCallerIsAdminExecutor() internal view { if (TIMELOCK.getAdminExecutor() != msg.sender) { - revert InvalidAdminExecutor(msg.sender); + revert CallerIsNotAdminExecutor(msg.sender); } } } diff --git a/contracts/EmergencyProtectedTimelock.sol b/contracts/EmergencyProtectedTimelock.sol index f08babb2..48b9e2ef 100644 --- a/contracts/EmergencyProtectedTimelock.sol +++ b/contracts/EmergencyProtectedTimelock.sol @@ -22,7 +22,7 @@ contract EmergencyProtectedTimelock is ITimelock { using ExecutableProposals for ExecutableProposals.State; using EmergencyProtection for EmergencyProtection.Context; - error InvalidAdminExecutor(address value); + error CallerIsNotAdminExecutor(address value); // --- // Sanity Check Params Immutables @@ -73,7 +73,7 @@ contract EmergencyProtectedTimelock is ITimelock { /// @param calls An array of `ExternalCall` structs representing the calls to be executed. /// @return newProposalId The ID of the newly created proposal. function submit(address executor, ExternalCall[] calldata calls) external returns (uint256 newProposalId) { - _timelockState.checkSenderIsGovernance(); + _timelockState.checkCallerIsGovernance(); newProposalId = _proposals.submit(executor, calls); } @@ -81,7 +81,7 @@ contract EmergencyProtectedTimelock is ITimelock { /// Only the governance contract can call this function. /// @param proposalId The ID of the proposal to be scheduled. function schedule(uint256 proposalId) external { - _timelockState.checkSenderIsGovernance(); + _timelockState.checkCallerIsGovernance(); _proposals.schedule(proposalId, _timelockState.getAfterSubmitDelay()); } @@ -96,7 +96,7 @@ contract EmergencyProtectedTimelock is ITimelock { /// @dev Cancels all non-executed proposals. /// Only the governance contract can call this function. function cancelAllNonExecutedProposals() external { - _timelockState.checkSenderIsGovernance(); + _timelockState.checkCallerIsGovernance(); _proposals.cancelAll(); } @@ -105,12 +105,12 @@ contract EmergencyProtectedTimelock is ITimelock { // --- function setGovernance(address newGovernance) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _timelockState.setGovernance(newGovernance); } function setDelays(Duration afterSubmitDelay, Duration afterScheduleDelay) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _timelockState.setAfterSubmitDelay(afterSubmitDelay, MAX_AFTER_SUBMIT_DELAY); _timelockState.setAfterScheduleDelay(afterScheduleDelay, MAX_AFTER_SCHEDULE_DELAY); } @@ -120,7 +120,7 @@ contract EmergencyProtectedTimelock is ITimelock { /// @param executor The address of the executor contract. /// @param owner The address of the new owner. function transferExecutorOwnership(address executor, address owner) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); IOwnable(executor).transferOwnership(owner); } @@ -135,7 +135,7 @@ contract EmergencyProtectedTimelock is ITimelock { Timestamp emergencyProtectionEndDate, Duration emergencyModeDuration ) external { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); _emergencyProtection.setEmergencyGovernance(emergencyGovernance); _emergencyProtection.setEmergencyActivationCommittee(emergencyActivationCommittee); @@ -149,7 +149,7 @@ contract EmergencyProtectedTimelock is ITimelock { /// @dev Activates the emergency mode. /// Only the activation committee can call this function. function activateEmergencyMode() external { - _emergencyProtection.checkSenderIsEmergencyActivationCommittee(); + _emergencyProtection.checkCallerIsEmergencyActivationCommittee(); _emergencyProtection.checkEmergencyMode({isActive: false}); _emergencyProtection.activateEmergencyMode(); } @@ -159,7 +159,7 @@ contract EmergencyProtectedTimelock is ITimelock { /// @param proposalId The ID of the proposal to be executed. function emergencyExecute(uint256 proposalId) external { _emergencyProtection.checkEmergencyMode({isActive: true}); - _emergencyProtection.checkSenderIsEmergencyExecutionCommittee(); + _emergencyProtection.checkCallerIsEmergencyExecutionCommittee(); _proposals.execute({proposalId: proposalId, afterScheduleDelay: Duration.wrap(0)}); } @@ -168,7 +168,7 @@ contract EmergencyProtectedTimelock is ITimelock { function deactivateEmergencyMode() external { _emergencyProtection.checkEmergencyMode({isActive: true}); if (!_emergencyProtection.isEmergencyModeDurationPassed()) { - _checkSenderIsAdminExecutor(); + _checkCallerIsAdminExecutor(); } _emergencyProtection.deactivateEmergencyMode(); _proposals.cancelAll(); @@ -177,7 +177,7 @@ contract EmergencyProtectedTimelock is ITimelock { /// @dev Resets the system after entering the emergency mode. /// Only the execution committee can call this function. function emergencyReset() external { - _emergencyProtection.checkSenderIsEmergencyExecutionCommittee(); + _emergencyProtection.checkCallerIsEmergencyExecutionCommittee(); _emergencyProtection.checkEmergencyMode({isActive: true}); _emergencyProtection.deactivateEmergencyMode(); @@ -278,9 +278,9 @@ contract EmergencyProtectedTimelock is ITimelock { return _proposals.canSchedule(proposalId, _timelockState.getAfterSubmitDelay()); } - function _checkSenderIsAdminExecutor() internal view { + function _checkCallerIsAdminExecutor() internal view { if (msg.sender != _ADMIN_EXECUTOR) { - revert InvalidAdminExecutor(msg.sender); + revert CallerIsNotAdminExecutor(msg.sender); } } } diff --git a/contracts/Escrow.sol b/contracts/Escrow.sol index 5a67d896..a9500125 100644 --- a/contracts/Escrow.sol +++ b/contracts/Escrow.sol @@ -53,7 +53,7 @@ contract Escrow is IEscrow { error UnexpectedUnstETHId(); error NonProxyCallsForbidden(); error InvalidBatchSize(uint256 size); - error InvalidDualGovernance(address value); + error CallerIsNotGovernance(address caller); error InvalidHintsLength(uint256 actual, uint256 expected); error InvalidETHSender(address actual, address expected); @@ -124,7 +124,7 @@ contract Escrow is IEscrow { if (address(this) == _SELF) { revert NonProxyCallsForbidden(); } - _checkSenderIsDualGovernance(); + _checkCallerIsGovernance(); _escrowState.initialize(minAssetsLockDuration); @@ -243,7 +243,7 @@ contract Escrow is IEscrow { // --- function startRageQuit(Duration rageQuitExtensionDelay, Duration rageQuitWithdrawalsTimelock) external { - _checkSenderIsDualGovernance(); + _checkCallerIsGovernance(); _escrowState.startRageQuit(rageQuitExtensionDelay, rageQuitWithdrawalsTimelock); _batchesQueue.open(); } @@ -316,7 +316,7 @@ contract Escrow is IEscrow { // --- function setMinAssetsLockDuration(Duration newMinAssetsLockDuration) external { - _checkSenderIsDualGovernance(); + _checkCallerIsGovernance(); _escrowState.setMinAssetsLockDuration(newMinAssetsLockDuration); } @@ -422,9 +422,9 @@ contract Escrow is IEscrow { } } - function _checkSenderIsDualGovernance() internal view { + function _checkCallerIsGovernance() internal view { if (msg.sender != address(DUAL_GOVERNANCE)) { - revert InvalidDualGovernance(msg.sender); + revert CallerIsNotGovernance(msg.sender); } } } diff --git a/contracts/ResealManager.sol b/contracts/ResealManager.sol index 6bbfe9f6..b7a79ef8 100644 --- a/contracts/ResealManager.sol +++ b/contracts/ResealManager.sol @@ -11,8 +11,7 @@ import {IResealManager} from "./interfaces/IResealManager.sol"; /// @dev Allows to extend pause of temporarily paused contracts to permanent pause or resume it. contract ResealManager is IResealManager { error SealableWrongPauseState(); - error SenderIsNotGovernance(); - error NotAllowed(); + error CallerIsNotGovernance(address caller); uint256 public constant PAUSE_INFINITELY = type(uint256).max; ITimelock public immutable EMERGENCY_PROTECTED_TIMELOCK; @@ -31,7 +30,7 @@ contract ResealManager is IResealManager { /// - Function is called by the governance contract. /// @param sealable The address of the sealable contract. function reseal(address sealable) public { - _checkSenderIsGovernance(); + _checkCallerIsGovernance(); uint256 sealableResumeSinceTimestamp = ISealable(sealable).getResumeSinceTimestamp(); if (sealableResumeSinceTimestamp < block.timestamp || sealableResumeSinceTimestamp == PAUSE_INFINITELY) { @@ -48,7 +47,7 @@ contract ResealManager is IResealManager { /// - Function is called by the governance contract. /// @param sealable The address of the sealable contract. function resume(address sealable) public { - _checkSenderIsGovernance(); + _checkCallerIsGovernance(); uint256 sealableResumeSinceTimestamp = ISealable(sealable).getResumeSinceTimestamp(); if (sealableResumeSinceTimestamp < block.timestamp) { @@ -59,10 +58,10 @@ contract ResealManager is IResealManager { /// @notice Ensures that the function can only be called by the governance address. /// @dev Reverts if the sender is not the governance address. - function _checkSenderIsGovernance() internal view { + function _checkCallerIsGovernance() internal view { address governance = EMERGENCY_PROTECTED_TIMELOCK.getGovernance(); if (msg.sender != governance) { - revert SenderIsNotGovernance(); + revert CallerIsNotGovernance(msg.sender); } } } diff --git a/contracts/TimelockedGovernance.sol b/contracts/TimelockedGovernance.sol index 2cbca5a4..4dc05c93 100644 --- a/contracts/TimelockedGovernance.sol +++ b/contracts/TimelockedGovernance.sol @@ -9,7 +9,7 @@ import {ExternalCall} from "./libraries/ExternalCalls.sol"; /// @title TimelockedGovernance /// @dev A contract that serves as the interface for submitting and scheduling the execution of governance proposals. contract TimelockedGovernance is IGovernance { - error NotGovernance(address account); + error CallerIsNotGovernance(address caller); address public immutable GOVERNANCE; ITimelock public immutable TIMELOCK; @@ -26,7 +26,7 @@ contract TimelockedGovernance is IGovernance { /// @param calls An array of ExternalCall structs representing the calls to be executed in the proposal. /// @return proposalId The ID of the submitted proposal. function submitProposal(ExternalCall[] calldata calls) external returns (uint256 proposalId) { - _checkSenderIsGovernance(); + _checkCallerIsGovernance(); return TIMELOCK.submit(TIMELOCK.getAdminExecutor(), calls); } @@ -51,14 +51,14 @@ contract TimelockedGovernance is IGovernance { /// @dev Cancels all pending proposals that have not been executed. function cancelAllPendingProposals() external { - _checkSenderIsGovernance(); + _checkCallerIsGovernance(); TIMELOCK.cancelAllNonExecutedProposals(); } /// @dev Checks if the msg.sender is the governance address. - function _checkSenderIsGovernance() internal view { + function _checkCallerIsGovernance() internal view { if (msg.sender != GOVERNANCE) { - revert NotGovernance(msg.sender); + revert CallerIsNotGovernance(msg.sender); } } } diff --git a/contracts/committees/EmergencyActivationCommittee.sol b/contracts/committees/EmergencyActivationCommittee.sol index c1441e9b..cb52f498 100644 --- a/contracts/committees/EmergencyActivationCommittee.sol +++ b/contracts/committees/EmergencyActivationCommittee.sol @@ -26,7 +26,7 @@ contract EmergencyActivationCommittee is HashConsensus { /// @notice Approves the emergency activation by casting a vote /// @dev Only callable by committee members function approveActivateEmergencyMode() public { - _checkSenderIsMember(); + _checkCallerIsMember(); _vote(EMERGENCY_ACTIVATION_HASH, true); } diff --git a/contracts/committees/EmergencyExecutionCommittee.sol b/contracts/committees/EmergencyExecutionCommittee.sol index f715b3b8..f3f6d2ce 100644 --- a/contracts/committees/EmergencyExecutionCommittee.sol +++ b/contracts/committees/EmergencyExecutionCommittee.sol @@ -35,7 +35,7 @@ contract EmergencyExecutionCommittee is HashConsensus, ProposalsList { /// @param proposalId The ID of the proposal to vote on /// @param _supports Indicates whether the member supports the proposal execution function voteEmergencyExecute(uint256 proposalId, bool _supports) public { - _checkSenderIsMember(); + _checkCallerIsMember(); (bytes memory proposalData, bytes32 key) = _encodeEmergencyExecute(proposalId); _vote(key, _supports); _pushProposal(key, uint256(ProposalType.EmergencyExecute), proposalData); @@ -85,7 +85,7 @@ contract EmergencyExecutionCommittee is HashConsensus, ProposalsList { /// @notice Approves an emergency reset proposal /// @dev Only callable by committee members function approveEmergencyReset() public { - _checkSenderIsMember(); + _checkCallerIsMember(); bytes32 proposalKey = _encodeEmergencyResetProposalKey(); _vote(proposalKey, true); _pushProposal(proposalKey, uint256(ProposalType.EmergencyReset), bytes("")); diff --git a/contracts/committees/HashConsensus.sol b/contracts/committees/HashConsensus.sol index 4df17083..fb86b11d 100644 --- a/contracts/committees/HashConsensus.sol +++ b/contracts/committees/HashConsensus.sol @@ -17,12 +17,12 @@ abstract contract HashConsensus is Ownable { event Voted(address indexed signer, bytes32 hash, bool support); event TimelockDurationSet(uint256 timelockDuration); - error IsNotMember(); - error SenderIsNotMember(); - error HashAlreadyUsed(); + error DuplicatedMember(address account); + error AccountIsNotMember(address account); + error CallerIsNotMember(address caller); + error HashAlreadyUsed(bytes32 hash); error QuorumIsNotReached(); error InvalidQuorum(); - error DuplicatedMember(address member); error TimelockNotPassed(); struct HashState { @@ -58,7 +58,7 @@ abstract contract HashConsensus is Ownable { /// @param support Indicates whether the member supports the hash function _vote(bytes32 hash, bool support) internal { if (_hashStates[hash].usedAt > 0) { - revert HashAlreadyUsed(); + revert HashAlreadyUsed(hash); } if (approves[msg.sender][hash] == support) { @@ -79,7 +79,7 @@ abstract contract HashConsensus is Ownable { /// @param hash The hash to mark as used function _markUsed(bytes32 hash) internal { if (_hashStates[hash].usedAt > 0) { - revert HashAlreadyUsed(); + revert HashAlreadyUsed(hash); } if (_getSupport(hash) < quorum) { revert QuorumIsNotReached(); @@ -132,7 +132,7 @@ abstract contract HashConsensus is Ownable { _checkOwner(); if (!_members.contains(memberToRemove)) { - revert IsNotMember(); + revert AccountIsNotMember(memberToRemove); } _members.remove(memberToRemove); emit MemberRemoved(memberToRemove); @@ -206,9 +206,9 @@ abstract contract HashConsensus is Ownable { /// @notice Restricts access to only committee members /// @dev Reverts if the sender is not a member - function _checkSenderIsMember() internal view { + function _checkCallerIsMember() internal view { if (!_members.contains(msg.sender)) { - revert SenderIsNotMember(); + revert CallerIsNotMember(msg.sender); } } } diff --git a/contracts/committees/ResealCommittee.sol b/contracts/committees/ResealCommittee.sol index 8cc8490e..3fd3c0d7 100644 --- a/contracts/committees/ResealCommittee.sol +++ b/contracts/committees/ResealCommittee.sol @@ -32,7 +32,7 @@ contract ResealCommittee is HashConsensus, ProposalsList { /// @param sealable The address to reseal /// @param support Indicates whether the member supports the proposal function voteReseal(address sealable, bool support) public { - _checkSenderIsMember(); + _checkCallerIsMember(); (bytes memory proposalData, bytes32 key) = _encodeResealProposal(sealable); _vote(key, support); _pushProposal(key, 0, proposalData); diff --git a/contracts/committees/TiebreakerCore.sol b/contracts/committees/TiebreakerCore.sol index aea111fb..43d95065 100644 --- a/contracts/committees/TiebreakerCore.sol +++ b/contracts/committees/TiebreakerCore.sol @@ -43,7 +43,7 @@ contract TiebreakerCore is HashConsensus, ProposalsList { /// @dev Allows committee members to vote on scheduling a proposal /// @param proposalId The ID of the proposal to schedule function scheduleProposal(uint256 proposalId) public { - _checkSenderIsMember(); + _checkCallerIsMember(); (bytes memory proposalData, bytes32 key) = _encodeScheduleProposal(proposalId); _vote(key, true); _pushProposal(key, uint256(ProposalType.ScheduleProposal), proposalData); @@ -98,7 +98,7 @@ contract TiebreakerCore is HashConsensus, ProposalsList { } function sealableResume(address sealable, uint256 nonce) public { - _checkSenderIsMember(); + _checkCallerIsMember(); if (nonce != _sealableResumeNonces[sealable]) { revert ResumeSealableNonceMismatch(); } diff --git a/contracts/committees/TiebreakerSubCommittee.sol b/contracts/committees/TiebreakerSubCommittee.sol index 09f9fa4b..1a8078d2 100644 --- a/contracts/committees/TiebreakerSubCommittee.sol +++ b/contracts/committees/TiebreakerSubCommittee.sol @@ -39,7 +39,7 @@ contract TiebreakerSubCommittee is HashConsensus, ProposalsList { /// @dev Allows committee members to vote on scheduling a proposal /// @param proposalId The ID of the proposal to schedule function scheduleProposal(uint256 proposalId) public { - _checkSenderIsMember(); + _checkCallerIsMember(); (bytes memory proposalData, bytes32 key) = _encodeAproveProposal(proposalId); _vote(key, true); _pushProposal(key, uint256(ProposalType.ScheduleProposal), proposalData); diff --git a/contracts/libraries/EmergencyProtection.sol b/contracts/libraries/EmergencyProtection.sol index c3f72b98..4adc7bcd 100644 --- a/contracts/libraries/EmergencyProtection.sol +++ b/contracts/libraries/EmergencyProtection.sol @@ -8,12 +8,12 @@ import {Timestamp, Timestamps} from "../types/Timestamp.sol"; /// @dev This library manages emergency protection functionality, allowing for /// the activation and deactivation of emergency mode by designated committees. library EmergencyProtection { - error InvalidEmergencyActivationCommittee(address account); - error InvalidEmergencyExecutionCommittee(address account); + error CallerIsNotEmergencyActivationCommittee(address caller); + error CallerIsNotEmergencyExecutionCommittee(address caller); error EmergencyProtectionExpired(Timestamp protectedTill); - error InvalidEmergencyModeState(bool value); error InvalidEmergencyModeDuration(Duration value); error InvalidEmergencyProtectionEndDate(Timestamp value); + error UnexpectedEmergencyModeState(bool value); event EmergencyModeActivated(); event EmergencyModeDeactivated(); @@ -133,17 +133,17 @@ library EmergencyProtection { /// @dev Checks if the caller is the emergency activator and reverts if not. /// @param self The storage reference to the Context struct. - function checkSenderIsEmergencyActivationCommittee(Context storage self) internal view { + function checkCallerIsEmergencyActivationCommittee(Context storage self) internal view { if (self.emergencyActivationCommittee != msg.sender) { - revert InvalidEmergencyActivationCommittee(msg.sender); + revert CallerIsNotEmergencyActivationCommittee(msg.sender); } } /// @dev Checks if the caller is the emergency enactor and reverts if not. /// @param self The storage reference to the Context struct. - function checkSenderIsEmergencyExecutionCommittee(Context storage self) internal view { + function checkCallerIsEmergencyExecutionCommittee(Context storage self) internal view { if (self.emergencyExecutionCommittee != msg.sender) { - revert InvalidEmergencyExecutionCommittee(msg.sender); + revert CallerIsNotEmergencyExecutionCommittee(msg.sender); } } @@ -152,7 +152,7 @@ library EmergencyProtection { /// @param isActive The expected value of the emergency mode. function checkEmergencyMode(Context storage self, bool isActive) internal view { if (isEmergencyModeActive(self) != isActive) { - revert InvalidEmergencyModeState(isActive); + revert UnexpectedEmergencyModeState(isActive); } } diff --git a/contracts/libraries/EscrowState.sol b/contracts/libraries/EscrowState.sol index c25e3809..c968ea31 100644 --- a/contracts/libraries/EscrowState.sol +++ b/contracts/libraries/EscrowState.sol @@ -12,8 +12,7 @@ enum State { library EscrowState { error ClaimingIsFinished(); - error InvalidState(State value); - error InvalidDualGovernance(address value); + error UnexpectedState(State value); error RageQuitExtraTimelockNotStarted(); error WithdrawalsTimelockNotPassed(); @@ -116,7 +115,7 @@ library EscrowState { function _checkState(Context storage self, State state) private view { if (self.state != state) { - revert InvalidState(state); + revert UnexpectedState(state); } } diff --git a/contracts/libraries/Proposers.sol b/contracts/libraries/Proposers.sol index 0d93f9f8..c4653cec 100644 --- a/contracts/libraries/Proposers.sol +++ b/contracts/libraries/Proposers.sol @@ -16,9 +16,8 @@ struct Proposer { library Proposers { using SafeCast for uint256; - error NotProposer(address account); - error NotAdminProposer(address account); - error NotAssignedExecutor(address account, address actualExecutor, address expectedExecutor); + error CallerIsNotProposer(address caller); + error CallerIsNotAdminProposer(address caller); error ProposerNotRegistered(address proposer); error ProposerAlreadyRegistered(address proposer); error LastAdminProposerRemoval(); @@ -133,19 +132,19 @@ library Proposers { /// @dev Checks if msg.sender is a registered proposer and reverts if not. /// @param self The storage state of the Proposers library. - function checkSenderIsProposer(State storage self) internal view { + function checkCallerIsProposer(State storage self) internal view { if (!isProposer(self, msg.sender)) { - revert NotProposer(msg.sender); + revert CallerIsNotProposer(msg.sender); } } /// @dev Checks if msg.sender is an admin proposer and reverts if not. /// @param self The storage state of the Proposers library. /// @param adminExecutor The address of the admin executor. - function checkSenderIsAdminProposer(State storage self, address adminExecutor) internal view { - checkSenderIsProposer(self); + function checkCallerIsAdminProposer(State storage self, address adminExecutor) internal view { + checkCallerIsProposer(self); if (!isAdminProposer(self, adminExecutor, msg.sender)) { - revert NotAdminProposer(msg.sender); + revert CallerIsNotAdminProposer(msg.sender); } } } diff --git a/contracts/libraries/Tiebreaker.sol b/contracts/libraries/Tiebreaker.sol index 91c6db90..137a089c 100644 --- a/contracts/libraries/Tiebreaker.sol +++ b/contracts/libraries/Tiebreaker.sol @@ -102,7 +102,7 @@ library Tiebreaker { // Checks // --- - function checkSenderIsTiebreakerCommittee(Context storage self) internal view { + function checkCallerIsTiebreakerCommittee(Context storage self) internal view { if (msg.sender != self.tiebreakerCommittee) { revert InvalidTiebreakerCommittee(msg.sender); } diff --git a/contracts/libraries/TimelockState.sol b/contracts/libraries/TimelockState.sol index 656e6ecc..39e4038b 100644 --- a/contracts/libraries/TimelockState.sol +++ b/contracts/libraries/TimelockState.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.26; import {Duration} from "../types/Duration.sol"; library TimelockState { + error CallerIsNotGovernance(address caller); error InvalidGovernance(address value); error InvalidAfterSubmitDelay(Duration value); error InvalidAfterScheduleDelay(Duration value); @@ -78,9 +79,9 @@ library TimelockState { emit AfterScheduleDelaySet(newAfterScheduleDelay); } - function checkSenderIsGovernance(Context storage self) internal view { + function checkCallerIsGovernance(Context storage self) internal view { if (self.governance != msg.sender) { - revert InvalidGovernance(msg.sender); + revert CallerIsNotGovernance(msg.sender); } } } diff --git a/test/scenario/escrow.t.sol b/test/scenario/escrow.t.sol index 73709c81..dfc97086 100644 --- a/test/scenario/escrow.t.sol +++ b/test/scenario/escrow.t.sol @@ -498,22 +498,22 @@ contract EscrowHappyPath is ScenarioTestBlueprint { // After the Escrow enters RageQuitEscrow state, lock/unlock of tokens is forbidden // --- - vm.expectRevert(abi.encodeWithSelector(EscrowState.InvalidState.selector, State.SignallingEscrow)); + vm.expectRevert(abi.encodeWithSelector(EscrowState.UnexpectedState.selector, State.SignallingEscrow)); this.externalLockStETH(_VETOER_1, 1 ether); - vm.expectRevert(abi.encodeWithSelector(EscrowState.InvalidState.selector, State.SignallingEscrow)); + vm.expectRevert(abi.encodeWithSelector(EscrowState.UnexpectedState.selector, State.SignallingEscrow)); this.externalLockWstETH(_VETOER_1, 1 ether); - vm.expectRevert(abi.encodeWithSelector(EscrowState.InvalidState.selector, State.SignallingEscrow)); + vm.expectRevert(abi.encodeWithSelector(EscrowState.UnexpectedState.selector, State.SignallingEscrow)); this.externalLockUnstETH(_VETOER_1, notLockedWithdrawalNfts); - vm.expectRevert(abi.encodeWithSelector(EscrowState.InvalidState.selector, State.SignallingEscrow)); + vm.expectRevert(abi.encodeWithSelector(EscrowState.UnexpectedState.selector, State.SignallingEscrow)); this.externalUnlockStETH(_VETOER_1); - vm.expectRevert(abi.encodeWithSelector(EscrowState.InvalidState.selector, State.SignallingEscrow)); + vm.expectRevert(abi.encodeWithSelector(EscrowState.UnexpectedState.selector, State.SignallingEscrow)); this.externalUnlockWstETH(_VETOER_1); - vm.expectRevert(abi.encodeWithSelector(EscrowState.InvalidState.selector, State.SignallingEscrow)); + vm.expectRevert(abi.encodeWithSelector(EscrowState.UnexpectedState.selector, State.SignallingEscrow)); this.externalUnlockUnstETH(_VETOER_1, lockedWithdrawalNfts); } diff --git a/test/scenario/happy-path-plan-b.t.sol b/test/scenario/happy-path-plan-b.t.sol index 947b7057..3c3170fd 100644 --- a/test/scenario/happy-path-plan-b.t.sol +++ b/test/scenario/happy-path-plan-b.t.sol @@ -96,7 +96,7 @@ contract PlanBSetup is ScenarioTestBlueprint { // but the call still not executable _assertCanExecute(maliciousProposalId, false); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, false)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, false)); _executeProposal(maliciousProposalId); } @@ -322,7 +322,7 @@ contract PlanBSetup is ScenarioTestBlueprint { _wait(_timelock.getAfterScheduleDelay().plusSeconds(1)); _assertCanExecute(maliciousProposalId, false); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, false)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, false)); _executeProposal(maliciousProposalId); } @@ -347,7 +347,7 @@ contract PlanBSetup is ScenarioTestBlueprint { _wait(_timelock.getAfterScheduleDelay().plusSeconds(1)); _assertCanExecute(anotherMaliciousProposalId, false); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, false)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, false)); _executeProposal(anotherMaliciousProposalId); } @@ -356,10 +356,10 @@ contract PlanBSetup is ScenarioTestBlueprint { _wait(_EMERGENCY_MODE_DURATION.dividedBy(2)); assertTrue(emergencyState.emergencyModeEndsAfter < Timestamps.now()); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, false)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, false)); _executeProposal(maliciousProposalId); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, false)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, false)); _executeProposal(anotherMaliciousProposalId); } diff --git a/test/scenario/timelocked-governance.t.sol b/test/scenario/timelocked-governance.t.sol index 0e452a97..5008c8ff 100644 --- a/test/scenario/timelocked-governance.t.sol +++ b/test/scenario/timelocked-governance.t.sol @@ -97,7 +97,7 @@ contract TimelockedGovernanceScenario is ScenarioTestBlueprint { _assertCanExecute(maliciousProposalId, false); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, false)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, false)); _executeProposal(maliciousProposalId); } @@ -172,7 +172,7 @@ contract TimelockedGovernanceScenario is ScenarioTestBlueprint { _assertCanExecute(maliciousProposalId, false); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, false)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, false)); _executeProposal(maliciousProposalId); } diff --git a/test/unit/EmergencyProtectedTimelock.t.sol b/test/unit/EmergencyProtectedTimelock.t.sol index cd6b3fd3..976d4d37 100644 --- a/test/unit/EmergencyProtectedTimelock.t.sol +++ b/test/unit/EmergencyProtectedTimelock.t.sol @@ -61,7 +61,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { vm.assume(stranger != _dualGovernance); vm.prank(stranger); - vm.expectRevert(abi.encodeWithSelector(TimelockState.InvalidGovernance.selector, [stranger])); + vm.expectRevert(abi.encodeWithSelector(TimelockState.CallerIsNotGovernance.selector, [stranger])); _timelock.submit(_adminExecutor, new ExternalCall[](0)); assertEq(_timelock.getProposalsCount(), 0); } @@ -98,7 +98,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { _submitProposal(); vm.prank(stranger); - vm.expectRevert(abi.encodeWithSelector(TimelockState.InvalidGovernance.selector, [stranger])); + vm.expectRevert(abi.encodeWithSelector(TimelockState.CallerIsNotGovernance.selector, [stranger])); _timelock.schedule(1); @@ -140,7 +140,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { _activateEmergencyMode(); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, [false])); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, [false])); _timelock.execute(1); ITimelock.Proposal memory proposal = _timelock.getProposal(1); @@ -181,7 +181,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { vm.assume(stranger != address(0)); vm.prank(stranger); - vm.expectRevert(abi.encodeWithSelector(TimelockState.InvalidGovernance.selector, [stranger])); + vm.expectRevert(abi.encodeWithSelector(TimelockState.CallerIsNotGovernance.selector, [stranger])); _timelock.cancelAllNonExecutedProposals(); } @@ -210,7 +210,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { vm.assume(stranger != _adminExecutor); vm.prank(stranger); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtectedTimelock.InvalidAdminExecutor.selector, stranger)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtectedTimelock.CallerIsNotAdminExecutor.selector, stranger)); _timelock.transferExecutorOwnership(_adminExecutor, makeAddr("newOwner")); } @@ -254,7 +254,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { vm.assume(stranger != _adminExecutor); vm.prank(stranger); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtectedTimelock.InvalidAdminExecutor.selector, stranger)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtectedTimelock.CallerIsNotAdminExecutor.selector, stranger)); _timelock.setGovernance(makeAddr("newGovernance")); } @@ -273,7 +273,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { vm.prank(stranger); vm.expectRevert( - abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyActivationCommittee.selector, stranger) + abi.encodeWithSelector(EmergencyProtection.CallerIsNotEmergencyActivationCommittee.selector, stranger) ); _timelock.activateEmergencyMode(); @@ -286,7 +286,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { assertEq(_isEmergencyStateActivated(), true); vm.prank(_emergencyActivator); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, [false])); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, [false])); _timelock.activateEmergencyMode(); assertEq(_isEmergencyStateActivated(), true); @@ -331,7 +331,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { assertEq(_timelock.isEmergencyModeActive(), false); vm.prank(_emergencyActivator); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, [true])); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, [true])); _timelock.emergencyExecute(1); } @@ -355,7 +355,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { vm.prank(stranger); vm.expectRevert( - abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyExecutionCommittee.selector, stranger) + abi.encodeWithSelector(EmergencyProtection.CallerIsNotEmergencyExecutionCommittee.selector, stranger) ); _timelock.emergencyExecute(1); } @@ -408,11 +408,11 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { vm.assume(stranger != _adminExecutor); vm.prank(stranger); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, [true])); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, [true])); _timelock.deactivateEmergencyMode(); vm.prank(_adminExecutor); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, [true])); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, [true])); _timelock.deactivateEmergencyMode(); } @@ -423,7 +423,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { assertEq(_isEmergencyStateActivated(), true); vm.prank(stranger); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtectedTimelock.InvalidAdminExecutor.selector, stranger)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtectedTimelock.CallerIsNotAdminExecutor.selector, stranger)); _timelock.deactivateEmergencyMode(); } @@ -474,7 +474,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { vm.prank(stranger); vm.expectRevert( - abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyExecutionCommittee.selector, stranger) + abi.encodeWithSelector(EmergencyProtection.CallerIsNotEmergencyExecutionCommittee.selector, stranger) ); _timelock.emergencyReset(); @@ -486,7 +486,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { EmergencyProtection.Context memory state = _timelock.getEmergencyProtectionContext(); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, [true])); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, [true])); vm.prank(_emergencyEnactor); _timelock.emergencyReset(); @@ -531,7 +531,7 @@ contract EmergencyProtectedTimelockUnitTests is UnitTest { EmergencyProtectedTimelock _localTimelock = _deployEmergencyProtectedTimelock(); vm.prank(stranger); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtectedTimelock.InvalidAdminExecutor.selector, stranger)); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtectedTimelock.CallerIsNotAdminExecutor.selector, stranger)); _localTimelock.setupEmergencyProtection( _emergencyGovernance, _emergencyActivator, diff --git a/test/unit/HashConsensus.t.sol b/test/unit/HashConsensus.t.sol index 74328891..283dcedc 100644 --- a/test/unit/HashConsensus.t.sol +++ b/test/unit/HashConsensus.t.sol @@ -121,7 +121,7 @@ abstract contract HashConsensusUnitTest is UnitTest { assertEq(_hashConsensus.isMember(_stranger), false); vm.prank(_owner); - vm.expectRevert(abi.encodeWithSignature("IsNotMember()")); + vm.expectRevert(abi.encodeWithSelector(HashConsensus.AccountIsNotMember.selector, _stranger)); _hashConsensus.removeMember(_stranger, _quorum); } @@ -207,7 +207,7 @@ contract HashConsensusWrapper is HashConsensus { } function onlyMemberProtected() public { - _checkSenderIsMember(); + _checkCallerIsMember(); emit OnlyMemberModifierPassed(); } } @@ -332,7 +332,7 @@ contract HashConsensusInternalUnitTest is HashConsensusUnitTest { _hashConsensusWrapper.execute(dataHash); vm.prank(_committeeMembers[0]); - vm.expectRevert(abi.encodeWithSignature("HashAlreadyUsed()")); + vm.expectRevert(abi.encodeWithSelector(HashConsensus.HashAlreadyUsed.selector, dataHash)); _hashConsensusWrapper.vote(dataHash, true); } @@ -359,13 +359,13 @@ contract HashConsensusInternalUnitTest is HashConsensusUnitTest { _hashConsensusWrapper.execute(dataHash); vm.prank(_stranger); - vm.expectRevert(abi.encodeWithSignature("HashAlreadyUsed()")); + vm.expectRevert(abi.encodeWithSelector(HashConsensus.HashAlreadyUsed.selector, dataHash)); _hashConsensusWrapper.execute(dataHash); } function test_onlyMemberModifier() public { vm.prank(_stranger); - vm.expectRevert(abi.encodeWithSignature("SenderIsNotMember()")); + vm.expectRevert(abi.encodeWithSelector(HashConsensus.CallerIsNotMember.selector, _stranger)); _hashConsensusWrapper.onlyMemberProtected(); vm.prank(_committeeMembers[0]); diff --git a/test/unit/ResealManager.t.sol b/test/unit/ResealManager.t.sol index 0326d638..4e65bb97 100644 --- a/test/unit/ResealManager.t.sol +++ b/test/unit/ResealManager.t.sol @@ -89,7 +89,7 @@ contract ResealManagerUnitTests is UnitTest { ); vm.prank(address(0x123)); - vm.expectRevert(ResealManager.SenderIsNotGovernance.selector); + vm.expectRevert(abi.encodeWithSelector(ResealManager.CallerIsNotGovernance.selector, address(0x123))); resealManager.reseal(sealable); } @@ -100,7 +100,7 @@ contract ResealManagerUnitTests is UnitTest { ); vm.prank(address(0x123)); - vm.expectRevert(ResealManager.SenderIsNotGovernance.selector); + vm.expectRevert(abi.encodeWithSelector(ResealManager.CallerIsNotGovernance.selector, address(0x123))); resealManager.resume(sealable); } } diff --git a/test/unit/TimelockedGovernance.t.sol b/test/unit/TimelockedGovernance.t.sol index 52e57f48..52cab0fc 100644 --- a/test/unit/TimelockedGovernance.t.sol +++ b/test/unit/TimelockedGovernance.t.sol @@ -43,7 +43,7 @@ contract TimelockedGovernanceUnitTests is UnitTest { assertEq(_timelock.getSubmittedProposals().length, 0); vm.startPrank(stranger); - vm.expectRevert(abi.encodeWithSelector(TimelockedGovernance.NotGovernance.selector, [stranger])); + vm.expectRevert(abi.encodeWithSelector(TimelockedGovernance.CallerIsNotGovernance.selector, [stranger])); _timelockedGovernance.submitProposal(_getMockTargetRegularStaffCalls(address(0x1))); assertEq(_timelock.getSubmittedProposals().length, 0); @@ -96,7 +96,7 @@ contract TimelockedGovernanceUnitTests is UnitTest { assertEq(_timelock.getLastCancelledProposalId(), 0); vm.startPrank(stranger); - vm.expectRevert(abi.encodeWithSelector(TimelockedGovernance.NotGovernance.selector, [stranger])); + vm.expectRevert(abi.encodeWithSelector(TimelockedGovernance.CallerIsNotGovernance.selector, [stranger])); _timelockedGovernance.cancelAllPendingProposals(); assertEq(_timelock.getLastCancelledProposalId(), 0); diff --git a/test/unit/libraries/EmergencyProtection.t.sol b/test/unit/libraries/EmergencyProtection.t.sol index 5a2dabcb..02856a37 100644 --- a/test/unit/libraries/EmergencyProtection.t.sol +++ b/test/unit/libraries/EmergencyProtection.t.sol @@ -322,7 +322,7 @@ contract EmergencyProtectionUnitTests is UnitTest { } function test_check_emergency_mode_active() external { - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, [true])); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, [true])); _emergencyProtection.checkEmergencyMode(true); _emergencyProtection.checkEmergencyMode(false); @@ -333,7 +333,7 @@ contract EmergencyProtectionUnitTests is UnitTest { _emergencyProtection.activateEmergencyMode(); _emergencyProtection.checkEmergencyMode(true); - vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.InvalidEmergencyModeState.selector, [true])); + vm.expectRevert(abi.encodeWithSelector(EmergencyProtection.UnexpectedEmergencyModeState.selector, [true])); } function _setup(