diff --git a/src/EmailRecoveryManager.sol b/src/EmailRecoveryManager.sol index 7d3a386..ad8ca27 100644 --- a/src/EmailRecoveryManager.sol +++ b/src/EmailRecoveryManager.sol @@ -279,10 +279,11 @@ contract EmailRecoveryManager is EmailAccountRecovery, Initializable, IEmailReco revert AccountNotConfigured(); } if (recoveryConfig.delay > recoveryConfig.expiry) { - revert DelayMoreThanExpiry(); + revert DelayMoreThanExpiry(recoveryConfig.delay, recoveryConfig.expiry); } - if (recoveryConfig.expiry - recoveryConfig.delay < MINIMUM_RECOVERY_WINDOW) { - revert RecoveryWindowTooShort(); + uint256 recoveryWindow = recoveryConfig.expiry - recoveryConfig.delay; + if (recoveryWindow < MINIMUM_RECOVERY_WINDOW) { + revert RecoveryWindowTooShort(recoveryWindow); } recoveryConfigs[account] = recoveryConfig; @@ -374,7 +375,9 @@ contract EmailRecoveryManager is EmailAccountRecovery, Initializable, IEmailReco GuardianConfig memory guardianConfig = guardianConfigs[account]; if (guardianConfig.threshold > guardianConfig.acceptedWeight) { - revert ThresholdExceedsAcceptedWeight(); + revert ThresholdExceedsAcceptedWeight( + guardianConfig.threshold, guardianConfig.acceptedWeight + ); } // This check ensures GuardianStatus is correct and also implicitly that the @@ -431,20 +434,20 @@ contract EmailRecoveryManager is EmailAccountRecovery, Initializable, IEmailReco } if (recoveryRequest.currentWeight < threshold) { - revert NotEnoughApprovals(); + revert NotEnoughApprovals(recoveryRequest.currentWeight, threshold); } if (block.timestamp < recoveryRequest.executeAfter) { - revert DelayNotPassed(); + revert DelayNotPassed(block.timestamp, recoveryRequest.executeAfter); } if (block.timestamp >= recoveryRequest.executeBefore) { - revert RecoveryRequestExpired(); + revert RecoveryRequestExpired(block.timestamp, recoveryRequest.executeBefore); } bytes32 calldataHash = keccak256(recoveryCalldata); if (calldataHash != recoveryRequest.calldataHash) { - revert InvalidCalldataHash(); + revert InvalidCalldataHash(calldataHash, recoveryRequest.calldataHash); } delete recoveryRequests[account]; diff --git a/src/handlers/EmailRecoverySubjectHandler.sol b/src/handlers/EmailRecoverySubjectHandler.sol index 48e4d5c..d934967 100644 --- a/src/handlers/EmailRecoverySubjectHandler.sol +++ b/src/handlers/EmailRecoverySubjectHandler.sol @@ -10,10 +10,10 @@ import { StringUtils } from "../libraries/StringUtils.sol"; * This is the default subject handler that will work with any validator. */ contract EmailRecoverySubjectHandler is IEmailRecoverySubjectHandler { - error InvalidTemplateIndex(); - error InvalidSubjectParams(); + error InvalidTemplateIndex(uint256 templateIdx, uint256 expectedTemplateIdx); + error InvalidSubjectParams(uint256 paramsLength, uint256 expectedParamsLength); error InvalidAccount(); - error InvalidRecoveryModule(); + error InvalidRecoveryModule(address recoveryModule); /** * @notice Returns a hard-coded two-dimensional array of strings representing the subject @@ -102,10 +102,10 @@ contract EmailRecoverySubjectHandler is IEmailRecoverySubjectHandler { returns (address) { if (templateIdx != 0) { - revert InvalidTemplateIndex(); + revert InvalidTemplateIndex(templateIdx, 0); } if (subjectParams.length != 1) { - revert InvalidSubjectParams(); + revert InvalidSubjectParams(subjectParams.length, 1); } // The GuardianStatus check in acceptGuardian implicitly @@ -132,10 +132,10 @@ contract EmailRecoverySubjectHandler is IEmailRecoverySubjectHandler { returns (address) { if (templateIdx != 0) { - revert InvalidTemplateIndex(); + revert InvalidTemplateIndex(templateIdx, 0); } if (subjectParams.length != 3) { - revert InvalidSubjectParams(); + revert InvalidSubjectParams(subjectParams.length, 3); } address accountInEmail = abi.decode(subjectParams[0], (address)); @@ -155,7 +155,7 @@ contract EmailRecoverySubjectHandler is IEmailRecoverySubjectHandler { address expectedRecoveryModule = EmailRecoveryManager(recoveryManager).emailRecoveryModule(); if (recoveryModuleInEmail == address(0) || recoveryModuleInEmail != expectedRecoveryModule) { - revert InvalidRecoveryModule(); + revert InvalidRecoveryModule(recoveryModuleInEmail); } return accountInEmail; @@ -177,7 +177,7 @@ contract EmailRecoverySubjectHandler is IEmailRecoverySubjectHandler { returns (bytes32) { if (templateIdx != 0) { - revert InvalidTemplateIndex(); + revert InvalidTemplateIndex(templateIdx, 0); } string memory calldataHashInEmail = abi.decode(subjectParams[2], (string)); diff --git a/src/handlers/SafeRecoverySubjectHandler.sol b/src/handlers/SafeRecoverySubjectHandler.sol index 8c130de..f312a48 100644 --- a/src/handlers/SafeRecoverySubjectHandler.sol +++ b/src/handlers/SafeRecoverySubjectHandler.sol @@ -10,11 +10,11 @@ import { EmailRecoveryManager } from "../EmailRecoveryManager.sol"; * This is a custom subject handler that will work with Safes and defines custom validation. */ contract SafeRecoverySubjectHandler is IEmailRecoverySubjectHandler { - error InvalidSubjectParams(); - error InvalidTemplateIndex(); - error InvalidOldOwner(); - error InvalidNewOwner(); - error InvalidRecoveryModule(); + error InvalidTemplateIndex(uint256 templateIdx, uint256 expectedTemplateIdx); + error InvalidSubjectParams(uint256 paramsLength, uint256 expectedParamsLength); + error InvalidOldOwner(address oldOwner); + error InvalidNewOwner(address newOwner); + error InvalidRecoveryModule(address recoveryModule); /** * @notice Returns a hard-coded two-dimensional array of strings representing the subject @@ -107,10 +107,10 @@ contract SafeRecoverySubjectHandler is IEmailRecoverySubjectHandler { returns (address) { if (templateIdx != 0) { - revert InvalidTemplateIndex(); + revert InvalidTemplateIndex(templateIdx, 0); } if (subjectParams.length != 1) { - revert InvalidSubjectParams(); + revert InvalidSubjectParams(subjectParams.length, 1); } // The GuardianStatus check in acceptGuardian implicitly @@ -137,10 +137,10 @@ contract SafeRecoverySubjectHandler is IEmailRecoverySubjectHandler { returns (address) { if (templateIdx != 0) { - revert InvalidTemplateIndex(); + revert InvalidTemplateIndex(templateIdx, 0); } if (subjectParams.length != 4) { - revert InvalidSubjectParams(); + revert InvalidSubjectParams(subjectParams.length, 4); } address accountInEmail = abi.decode(subjectParams[0], (address)); @@ -150,12 +150,12 @@ contract SafeRecoverySubjectHandler is IEmailRecoverySubjectHandler { bool isOldAddressOwner = ISafe(accountInEmail).isOwner(oldOwnerInEmail); if (!isOldAddressOwner) { - revert InvalidOldOwner(); + revert InvalidOldOwner(oldOwnerInEmail); } bool isNewAddressOwner = ISafe(accountInEmail).isOwner(newOwnerInEmail); if (newOwnerInEmail == address(0) || isNewAddressOwner) { - revert InvalidNewOwner(); + revert InvalidNewOwner(newOwnerInEmail); } // Even though someone could use a malicious contract as the recoveryManager argument, it @@ -165,7 +165,7 @@ contract SafeRecoverySubjectHandler is IEmailRecoverySubjectHandler { address expectedRecoveryModule = EmailRecoveryManager(recoveryManager).emailRecoveryModule(); if (recoveryModuleInEmail == address(0) || recoveryModuleInEmail != expectedRecoveryModule) { - revert InvalidRecoveryModule(); + revert InvalidRecoveryModule(recoveryModuleInEmail); } return accountInEmail; @@ -187,7 +187,7 @@ contract SafeRecoverySubjectHandler is IEmailRecoverySubjectHandler { returns (bytes32) { if (templateIdx != 0) { - revert InvalidTemplateIndex(); + revert InvalidTemplateIndex(templateIdx, 0); } address accountInEmail = abi.decode(subjectParams[0], (address)); diff --git a/src/interfaces/IEmailRecoveryManager.sol b/src/interfaces/IEmailRecoveryManager.sol index 6ee0afb..3738698 100644 --- a/src/interfaces/IEmailRecoveryManager.sol +++ b/src/interfaces/IEmailRecoveryManager.sol @@ -74,28 +74,28 @@ interface IEmailRecoveryManager { ERRORS //////////////////////////////////////////////////////////////////////////*/ + error RecoveryInProcess(); error InvalidVerifier(); error InvalidDkimRegistry(); error InvalidEmailAuthImpl(); error InvalidSubjectHandler(); error InitializerNotDeployer(); error InvalidRecoveryModule(); - error RecoveryInProcess(); error SetupAlreadyCalled(); error AccountNotConfigured(); error RecoveryModuleNotAuthorized(); - error DelayMoreThanExpiry(); - error RecoveryWindowTooShort(); - error ThresholdExceedsAcceptedWeight(); + error DelayMoreThanExpiry(uint256 delay, uint256 expiry); + error RecoveryWindowTooShort(uint256 recoveryWindow); + error ThresholdExceedsAcceptedWeight(uint256 threshold, uint256 acceptedWeight); error InvalidGuardianStatus( GuardianStatus guardianStatus, GuardianStatus expectedGuardianStatus ); error InvalidAccountAddress(); error NoRecoveryConfigured(); - error NotEnoughApprovals(); - error DelayNotPassed(); - error RecoveryRequestExpired(); - error InvalidCalldataHash(); + error NotEnoughApprovals(uint256 currentWeight, uint256 threshold); + error DelayNotPassed(uint256 blockTimestamp, uint256 executeAfter); + error RecoveryRequestExpired(uint256 blockTimestamp, uint256 executeBefore); + error InvalidCalldataHash(bytes32 calldataHash, bytes32 expectedCalldataHash); error NoRecoveryInProcess(); error NotRecoveryModule(); error SetupNotCalled(); diff --git a/src/libraries/GuardianUtils.sol b/src/libraries/GuardianUtils.sol index 5779721..fa79bcb 100644 --- a/src/libraries/GuardianUtils.sol +++ b/src/libraries/GuardianUtils.sol @@ -17,13 +17,13 @@ library GuardianUtils { event RemovedGuardian(address indexed account, address indexed guardian, uint256 weight); event ChangedThreshold(address indexed account, uint256 threshold); - error IncorrectNumberOfWeights(); + error IncorrectNumberOfWeights(uint256 guardianCount, uint256 weightCount); error ThresholdCannotBeZero(); - error InvalidGuardianAddress(); + error InvalidGuardianAddress(address guardian); error InvalidGuardianWeight(); error AddressAlreadyGuardian(); - error ThresholdExceedsTotalWeight(); - error StatusCannotBeTheSame(); + error ThresholdExceedsTotalWeight(uint256 threshold, uint256 totalWeight); + error StatusCannotBeTheSame(GuardianStatus newStatus); error SetupNotCalled(); error AddressNotGuardianForAccount(); @@ -69,7 +69,7 @@ library GuardianUtils { uint256 guardianCount = guardians.length; if (guardianCount != weights.length) { - revert IncorrectNumberOfWeights(); + revert IncorrectNumberOfWeights(guardianCount, weights.length); } if (threshold == 0) { @@ -82,7 +82,7 @@ library GuardianUtils { uint256 totalWeight = guardianConfigs[account].totalWeight; if (threshold > totalWeight) { - revert ThresholdExceedsTotalWeight(); + revert ThresholdExceedsTotalWeight(threshold, totalWeight); } guardianConfigs[account].threshold = threshold; @@ -106,7 +106,7 @@ library GuardianUtils { { GuardianStorage memory guardianStorage = guardiansStorage[account].get(guardian); if (newStatus == guardianStorage.status) { - revert StatusCannotBeTheSame(); + revert StatusCannotBeTheSame(newStatus); } guardiansStorage[account].set({ @@ -134,7 +134,7 @@ library GuardianUtils { internal { if (guardian == address(0) || guardian == account) { - revert InvalidGuardianAddress(); + revert InvalidGuardianAddress(guardian); } if (weight == 0) { @@ -180,8 +180,9 @@ library GuardianUtils { } // Only allow guardian removal if threshold can still be reached. - if (guardianConfig.totalWeight - guardianStorage.weight < guardianConfig.threshold) { - revert ThresholdExceedsTotalWeight(); + uint256 newTotalWeight = guardianConfig.totalWeight - guardianStorage.weight; + if (newTotalWeight < guardianConfig.threshold) { + revert ThresholdExceedsTotalWeight(newTotalWeight, guardianConfig.threshold); } guardianConfigs[account].guardianCount--; @@ -228,7 +229,7 @@ library GuardianUtils { // Validate that threshold is smaller than the total weight. if (threshold > guardianConfigs[account].totalWeight) { - revert ThresholdExceedsTotalWeight(); + revert ThresholdExceedsTotalWeight(threshold, guardianConfigs[account].totalWeight); } // Guardian weight should be at least 1 diff --git a/test/integration/EmailRecoveryManager/EmailRecoveryManager.integration.t.sol b/test/integration/EmailRecoveryManager/EmailRecoveryManager.integration.t.sol index fa369fd..365d519 100644 --- a/test/integration/EmailRecoveryManager/EmailRecoveryManager.integration.t.sol +++ b/test/integration/EmailRecoveryManager/EmailRecoveryManager.integration.t.sol @@ -170,14 +170,18 @@ contract EmailRecoveryManager_Integration_Test is } function test_RevertWhen_CompleteRecoveryCalled_BeforeHandleAcceptance() public { - vm.expectRevert(IEmailRecoveryManager.NotEnoughApprovals.selector); + vm.expectRevert( + abi.encodeWithSelector(IEmailRecoveryManager.NotEnoughApprovals.selector, 0, threshold) + ); emailRecoveryManager.completeRecovery(accountAddress1, recoveryCalldata1); } function test_RevertWhen_CompleteRecoveryCalled_BeforeProcessRecovery() public { acceptGuardian(accountAddress1, guardians1[0]); - vm.expectRevert(IEmailRecoveryManager.NotEnoughApprovals.selector); + vm.expectRevert( + abi.encodeWithSelector(IEmailRecoveryManager.NotEnoughApprovals.selector, 0, threshold) + ); emailRecoveryManager.completeRecovery(accountAddress1, recoveryCalldata1); } @@ -241,10 +245,15 @@ contract EmailRecoveryManager_Integration_Test is vm.warp(12 seconds); handleRecovery(accountAddress1, guardians1[0], calldataHash1); handleRecovery(accountAddress1, guardians1[1], calldataHash1); + uint256 executeAfter = block.timestamp + expiry; vm.warp(10 weeks); - vm.expectRevert(IEmailRecoveryManager.RecoveryRequestExpired.selector); + vm.expectRevert( + abi.encodeWithSelector( + IEmailRecoveryManager.RecoveryRequestExpired.selector, block.timestamp, executeAfter + ) + ); emailRecoveryManager.completeRecovery(accountAddress1, recoveryCalldata1); // Can cancel recovery even when stale diff --git a/test/unit/EmailRecoveryManager/completeRecovery.t.sol b/test/unit/EmailRecoveryManager/completeRecovery.t.sol index 8c65be9..7b7df16 100644 --- a/test/unit/EmailRecoveryManager/completeRecovery.t.sol +++ b/test/unit/EmailRecoveryManager/completeRecovery.t.sol @@ -24,7 +24,11 @@ contract EmailRecoveryManager_completeRecovery_Test is UnitBase { handleRecovery(recoveryModuleAddress, calldataHash, accountSalt1); // only one guardian added and one approval - vm.expectRevert(IEmailRecoveryManager.NotEnoughApprovals.selector); + vm.expectRevert( + abi.encodeWithSelector( + IEmailRecoveryManager.NotEnoughApprovals.selector, guardianWeights[0], threshold + ) + ); emailRecoveryManager.completeRecovery(accountAddress, recoveryCalldata); } @@ -38,7 +42,13 @@ contract EmailRecoveryManager_completeRecovery_Test is UnitBase { // one second before it should be valid vm.warp(block.timestamp + delay - 1 seconds); - vm.expectRevert(IEmailRecoveryManager.DelayNotPassed.selector); + vm.expectRevert( + abi.encodeWithSelector( + IEmailRecoveryManager.DelayNotPassed.selector, + block.timestamp, + block.timestamp + delay + ) + ); emailRecoveryManager.completeRecovery(accountAddress, recoveryCalldata); } @@ -50,11 +60,16 @@ contract EmailRecoveryManager_completeRecovery_Test is UnitBase { vm.warp(12 seconds); handleRecovery(recoveryModuleAddress, calldataHash, accountSalt1); handleRecovery(recoveryModuleAddress, calldataHash, accountSalt2); + uint256 executeAfter = block.timestamp + expiry; // block.timestamp == recoveryRequest.executeBefore vm.warp(block.timestamp + expiry); - vm.expectRevert(IEmailRecoveryManager.RecoveryRequestExpired.selector); + vm.expectRevert( + abi.encodeWithSelector( + IEmailRecoveryManager.RecoveryRequestExpired.selector, block.timestamp, executeAfter + ) + ); emailRecoveryManager.completeRecovery(accountAddress, recoveryCalldata); } @@ -66,11 +81,16 @@ contract EmailRecoveryManager_completeRecovery_Test is UnitBase { vm.warp(12 seconds); handleRecovery(recoveryModuleAddress, calldataHash, accountSalt1); handleRecovery(recoveryModuleAddress, calldataHash, accountSalt2); + uint256 executeAfter = block.timestamp + expiry; // block.timestamp > recoveryRequest.executeBefore vm.warp(block.timestamp + expiry + 1 seconds); - vm.expectRevert(IEmailRecoveryManager.RecoveryRequestExpired.selector); + vm.expectRevert( + abi.encodeWithSelector( + IEmailRecoveryManager.RecoveryRequestExpired.selector, block.timestamp, executeAfter + ) + ); emailRecoveryManager.completeRecovery(accountAddress, recoveryCalldata); } @@ -85,7 +105,13 @@ contract EmailRecoveryManager_completeRecovery_Test is UnitBase { vm.warp(block.timestamp + delay); - vm.expectRevert(IEmailRecoveryManager.InvalidCalldataHash.selector); + vm.expectRevert( + abi.encodeWithSelector( + IEmailRecoveryManager.InvalidCalldataHash.selector, + keccak256(invalidRecoveryCalldata), + calldataHash + ) + ); emailRecoveryManager.completeRecovery(accountAddress, invalidRecoveryCalldata); } diff --git a/test/unit/EmailRecoveryManager/configureRecovery.t.sol b/test/unit/EmailRecoveryManager/configureRecovery.t.sol index 7a77c3e..40ad02a 100644 --- a/test/unit/EmailRecoveryManager/configureRecovery.t.sol +++ b/test/unit/EmailRecoveryManager/configureRecovery.t.sol @@ -78,7 +78,13 @@ contract EmailRecoveryManager_configureRecovery_Test is UnitBase { emailRecoveryModule.workaround_validatorsPush(accountAddress, validatorAddress); address[] memory zeroGuardians; - vm.expectRevert(GuardianUtils.IncorrectNumberOfWeights.selector); + vm.expectRevert( + abi.encodeWithSelector( + GuardianUtils.IncorrectNumberOfWeights.selector, + zeroGuardians.length, + guardianWeights.length + ) + ); emailRecoveryManager.configureRecovery( zeroGuardians, guardianWeights, threshold, delay, expiry ); @@ -90,7 +96,13 @@ contract EmailRecoveryManager_configureRecovery_Test is UnitBase { emailRecoveryModule.workaround_validatorsPush(accountAddress, validatorAddress); uint256[] memory zeroGuardianWeights; - vm.expectRevert(GuardianUtils.IncorrectNumberOfWeights.selector); + vm.expectRevert( + abi.encodeWithSelector( + GuardianUtils.IncorrectNumberOfWeights.selector, + guardians.length, + zeroGuardianWeights.length + ) + ); emailRecoveryManager.configureRecovery( guardians, zeroGuardianWeights, threshold, delay, expiry ); @@ -108,7 +120,7 @@ contract EmailRecoveryManager_configureRecovery_Test is UnitBase { ); } - function test_ConfigureRecovery_RevetrWhen_NoGuardians() public { + function test_ConfigureRecovery_RevertWhen_NoGuardians() public { instance.uninstallModule(MODULE_TYPE_EXECUTOR, recoveryModuleAddress, ""); vm.startPrank(accountAddress); emailRecoveryModule.workaround_validatorsPush(accountAddress, validatorAddress); @@ -116,7 +128,9 @@ contract EmailRecoveryManager_configureRecovery_Test is UnitBase { address[] memory zeroGuardians; uint256[] memory zeroGuardianWeights; - vm.expectRevert(GuardianUtils.ThresholdExceedsTotalWeight.selector); + vm.expectRevert( + abi.encodeWithSelector(GuardianUtils.ThresholdExceedsTotalWeight.selector, threshold, 0) + ); emailRecoveryManager.configureRecovery( zeroGuardians, zeroGuardianWeights, threshold, delay, expiry ); diff --git a/test/unit/EmailRecoveryManager/processRecovery.t.sol b/test/unit/EmailRecoveryManager/processRecovery.t.sol index 138bfa1..aeab9c7 100644 --- a/test/unit/EmailRecoveryManager/processRecovery.t.sol +++ b/test/unit/EmailRecoveryManager/processRecovery.t.sol @@ -103,7 +103,11 @@ contract EmailRecoveryManager_processRecovery_Test is UnitBase { vm.warp(12 seconds); - vm.expectRevert(IEmailRecoveryManager.ThresholdExceedsAcceptedWeight.selector); + vm.expectRevert( + abi.encodeWithSelector( + IEmailRecoveryManager.ThresholdExceedsAcceptedWeight.selector, newThreshold, 3 + ) + ); emailRecoveryManager.exposed_processRecovery( guardian2, templateIdx, subjectParams, nullifier ); diff --git a/test/unit/EmailRecoveryManager/updateRecoveryConfig.t.sol b/test/unit/EmailRecoveryManager/updateRecoveryConfig.t.sol index 670edfc..eb09f01 100644 --- a/test/unit/EmailRecoveryManager/updateRecoveryConfig.t.sol +++ b/test/unit/EmailRecoveryManager/updateRecoveryConfig.t.sol @@ -42,7 +42,11 @@ contract EmailRecoveryManager_updateRecoveryConfig_Test is UnitBase { IEmailRecoveryManager.RecoveryConfig(invalidDelay, expiry); vm.startPrank(accountAddress); - vm.expectRevert(IEmailRecoveryManager.DelayMoreThanExpiry.selector); + vm.expectRevert( + abi.encodeWithSelector( + IEmailRecoveryManager.DelayMoreThanExpiry.selector, invalidDelay, expiry + ) + ); emailRecoveryManager.updateRecoveryConfig(recoveryConfig); } @@ -54,7 +58,11 @@ contract EmailRecoveryManager_updateRecoveryConfig_Test is UnitBase { IEmailRecoveryManager.RecoveryConfig(newDelay, newExpiry); vm.startPrank(accountAddress); - vm.expectRevert(IEmailRecoveryManager.RecoveryWindowTooShort.selector); + vm.expectRevert( + abi.encodeWithSelector( + IEmailRecoveryManager.RecoveryWindowTooShort.selector, newExpiry - newDelay + ) + ); emailRecoveryManager.updateRecoveryConfig(recoveryConfig); } @@ -66,7 +74,11 @@ contract EmailRecoveryManager_updateRecoveryConfig_Test is UnitBase { IEmailRecoveryManager.RecoveryConfig(newDelay, newExpiry); vm.startPrank(accountAddress); - vm.expectRevert(IEmailRecoveryManager.RecoveryWindowTooShort.selector); + vm.expectRevert( + abi.encodeWithSelector( + IEmailRecoveryManager.RecoveryWindowTooShort.selector, newExpiry - newDelay + ) + ); emailRecoveryManager.updateRecoveryConfig(recoveryConfig); } diff --git a/test/unit/assertErrorSelectors.t.sol b/test/unit/assertErrorSelectors.t.sol index eb303a3..6934269 100644 --- a/test/unit/assertErrorSelectors.t.sol +++ b/test/unit/assertErrorSelectors.t.sol @@ -18,18 +18,18 @@ import { GuardianUtils } from "src/libraries/GuardianUtils.sol"; // errors contract LogErrorSelectors_Test is Test { function test_EmailRecoverySubjectHandler_AssertSelectors() public { - assertEq(EmailRecoverySubjectHandler.InvalidTemplateIndex.selector, bytes4(0x5abe71c9)); - assertEq(EmailRecoverySubjectHandler.InvalidSubjectParams.selector, bytes4(0xd743ae6c)); + assertEq(EmailRecoverySubjectHandler.InvalidTemplateIndex.selector, bytes4(0x5be77855)); + assertEq(EmailRecoverySubjectHandler.InvalidSubjectParams.selector, bytes4(0x9c6fa025)); assertEq(EmailRecoverySubjectHandler.InvalidAccount.selector, bytes4(0x6d187b28)); - assertEq(EmailRecoverySubjectHandler.InvalidRecoveryModule.selector, bytes4(0x7f263111)); + assertEq(EmailRecoverySubjectHandler.InvalidRecoveryModule.selector, bytes4(0xa01f773d)); } function test_SafeRecoverySubjectHandler_AssertSelectors() public { - assertEq(SafeRecoverySubjectHandler.InvalidTemplateIndex.selector, bytes4(0x5abe71c9)); - assertEq(SafeRecoverySubjectHandler.InvalidSubjectParams.selector, bytes4(0xd743ae6c)); - assertEq(SafeRecoverySubjectHandler.InvalidOldOwner.selector, bytes4(0xa9ab2692)); - assertEq(SafeRecoverySubjectHandler.InvalidNewOwner.selector, bytes4(0x54a56786)); - assertEq(SafeRecoverySubjectHandler.InvalidRecoveryModule.selector, bytes4(0x7f263111)); + assertEq(SafeRecoverySubjectHandler.InvalidTemplateIndex.selector, bytes4(0x5be77855)); + assertEq(SafeRecoverySubjectHandler.InvalidSubjectParams.selector, bytes4(0x9c6fa025)); + assertEq(SafeRecoverySubjectHandler.InvalidOldOwner.selector, bytes4(0x377abe51)); + assertEq(SafeRecoverySubjectHandler.InvalidNewOwner.selector, bytes4(0x896d9ad0)); + assertEq(SafeRecoverySubjectHandler.InvalidRecoveryModule.selector, bytes4(0xa01f773d)); } function test_IEmailRecoveryManager_AssertSelectors() public { @@ -43,16 +43,16 @@ contract LogErrorSelectors_Test is Test { assertEq(IEmailRecoveryManager.SetupAlreadyCalled.selector, bytes4(0xb3af5593)); assertEq(IEmailRecoveryManager.AccountNotConfigured.selector, bytes4(0x66ecbd6d)); assertEq(IEmailRecoveryManager.RecoveryModuleNotAuthorized.selector, bytes4(0xbfa7d2a9)); - assertEq(IEmailRecoveryManager.DelayMoreThanExpiry.selector, bytes4(0x655a4874)); - assertEq(IEmailRecoveryManager.RecoveryWindowTooShort.selector, bytes4(0x12fa0714)); - assertEq(IEmailRecoveryManager.ThresholdExceedsAcceptedWeight.selector, bytes4(0x8f8457ba)); + assertEq(IEmailRecoveryManager.DelayMoreThanExpiry.selector, bytes4(0xb742a43c)); + assertEq(IEmailRecoveryManager.RecoveryWindowTooShort.selector, bytes4(0x50799cce)); + assertEq(IEmailRecoveryManager.ThresholdExceedsAcceptedWeight.selector, bytes4(0x7c3e983c)); assertEq(IEmailRecoveryManager.InvalidGuardianStatus.selector, bytes4(0x5689b51a)); assertEq(IEmailRecoveryManager.InvalidAccountAddress.selector, bytes4(0x401b6ade)); assertEq(IEmailRecoveryManager.NoRecoveryConfigured.selector, bytes4(0xa66e66b6)); - assertEq(IEmailRecoveryManager.NotEnoughApprovals.selector, bytes4(0x24bcdbea)); - assertEq(IEmailRecoveryManager.DelayNotPassed.selector, bytes4(0xc806ff6e)); - assertEq(IEmailRecoveryManager.RecoveryRequestExpired.selector, bytes4(0x4c2babb1)); - assertEq(IEmailRecoveryManager.InvalidCalldataHash.selector, bytes4(0xf05609de)); + assertEq(IEmailRecoveryManager.NotEnoughApprovals.selector, bytes4(0x443282f5)); + assertEq(IEmailRecoveryManager.DelayNotPassed.selector, bytes4(0x2f37ae39)); + assertEq(IEmailRecoveryManager.RecoveryRequestExpired.selector, bytes4(0x566ad75e)); + assertEq(IEmailRecoveryManager.InvalidCalldataHash.selector, bytes4(0x54d53855)); assertEq(IEmailRecoveryManager.NoRecoveryInProcess.selector, bytes4(0x87434f51)); assertEq(IEmailRecoveryManager.NotRecoveryModule.selector, bytes4(0x2f6ef3d6)); assertEq(IEmailRecoveryManager.SetupNotCalled.selector, bytes4(0xae69115b)); @@ -97,13 +97,13 @@ contract LogErrorSelectors_Test is Test { } function test_GuardianUtils_AssertSelectors() public { - assertEq(GuardianUtils.IncorrectNumberOfWeights.selector, bytes4(0xf4a950ef)); + assertEq(GuardianUtils.IncorrectNumberOfWeights.selector, bytes4(0x166e79bd)); assertEq(GuardianUtils.ThresholdCannotBeZero.selector, bytes4(0xf4124166)); - assertEq(GuardianUtils.InvalidGuardianAddress.selector, bytes4(0x1b081054)); + assertEq(GuardianUtils.InvalidGuardianAddress.selector, bytes4(0x1af74975)); assertEq(GuardianUtils.InvalidGuardianWeight.selector, bytes4(0x148f78e0)); assertEq(GuardianUtils.AddressAlreadyGuardian.selector, bytes4(0xe4e1614e)); - assertEq(GuardianUtils.ThresholdExceedsTotalWeight.selector, bytes4(0x3c7a2aad)); - assertEq(GuardianUtils.StatusCannotBeTheSame.selector, bytes4(0x115e823f)); + assertEq(GuardianUtils.ThresholdExceedsTotalWeight.selector, bytes4(0xeb912f71)); + assertEq(GuardianUtils.StatusCannotBeTheSame.selector, bytes4(0x7e120711)); assertEq(GuardianUtils.SetupNotCalled.selector, bytes4(0xae69115b)); assertEq(GuardianUtils.AddressNotGuardianForAccount.selector, bytes4(0xf3f77749)); } diff --git a/test/unit/handlers/EmailRecoverySubjectHandler/parseRecoveryCalldataHash.t.sol b/test/unit/handlers/EmailRecoverySubjectHandler/parseRecoveryCalldataHash.t.sol index 0b66024..bd0a997 100644 --- a/test/unit/handlers/EmailRecoverySubjectHandler/parseRecoveryCalldataHash.t.sol +++ b/test/unit/handlers/EmailRecoverySubjectHandler/parseRecoveryCalldataHash.t.sol @@ -25,7 +25,11 @@ contract EmailRecoverySubjectHandler_parseRecoveryCalldataHash_Test is UnitBase function test_ParseRecoveryCalldataHash_RevertWhen_InvalidTemplateIndex() public { uint256 invalidTemplateIdx = 1; - vm.expectRevert(EmailRecoverySubjectHandler.InvalidTemplateIndex.selector); + vm.expectRevert( + abi.encodeWithSelector( + EmailRecoverySubjectHandler.InvalidTemplateIndex.selector, invalidTemplateIdx, 0 + ) + ); emailRecoveryHandler.parseRecoveryCalldataHash(invalidTemplateIdx, subjectParams); } diff --git a/test/unit/handlers/EmailRecoverySubjectHandler/validateAcceptanceSubject.t.sol b/test/unit/handlers/EmailRecoverySubjectHandler/validateAcceptanceSubject.t.sol index 14aa714..499ed75 100644 --- a/test/unit/handlers/EmailRecoverySubjectHandler/validateAcceptanceSubject.t.sol +++ b/test/unit/handlers/EmailRecoverySubjectHandler/validateAcceptanceSubject.t.sol @@ -15,14 +15,24 @@ contract EmailRecoverySubjectHandler_validateAcceptanceSubject_Test is UnitBase subjectParams[0] = abi.encode(accountAddress); uint256 invalidTemplateIdx = 1; - vm.expectRevert(EmailRecoverySubjectHandler.InvalidTemplateIndex.selector); + vm.expectRevert( + abi.encodeWithSelector( + EmailRecoverySubjectHandler.InvalidTemplateIndex.selector, invalidTemplateIdx, 0 + ) + ); emailRecoveryHandler.validateAcceptanceSubject(invalidTemplateIdx, subjectParams); } function test_ValidateAcceptanceSubject_RevertWhen_NoSubjectParams() public { bytes[] memory emptySubjectParams; - vm.expectRevert(EmailRecoverySubjectHandler.InvalidSubjectParams.selector); + vm.expectRevert( + abi.encodeWithSelector( + EmailRecoverySubjectHandler.InvalidSubjectParams.selector, + emptySubjectParams.length, + 1 + ) + ); emailRecoveryHandler.validateAcceptanceSubject(templateIdx, emptySubjectParams); } @@ -31,7 +41,11 @@ contract EmailRecoverySubjectHandler_validateAcceptanceSubject_Test is UnitBase subjectParams[0] = abi.encode(accountAddress); subjectParams[1] = abi.encode("extra param"); - vm.expectRevert(EmailRecoverySubjectHandler.InvalidSubjectParams.selector); + vm.expectRevert( + abi.encodeWithSelector( + EmailRecoverySubjectHandler.InvalidSubjectParams.selector, subjectParams.length, 1 + ) + ); emailRecoveryHandler.validateAcceptanceSubject(templateIdx, subjectParams); } diff --git a/test/unit/handlers/EmailRecoverySubjectHandler/validateRecoverySubject.t.sol b/test/unit/handlers/EmailRecoverySubjectHandler/validateRecoverySubject.t.sol index e523038..8f1ec6b 100644 --- a/test/unit/handlers/EmailRecoverySubjectHandler/validateRecoverySubject.t.sol +++ b/test/unit/handlers/EmailRecoverySubjectHandler/validateRecoverySubject.t.sol @@ -26,7 +26,11 @@ contract EmailRecoverySubjectHandler_validateRecoverySubject_Test is UnitBase { function test_ValidateRecoverySubject_RevertWhen_InvalidTemplateIndex() public { uint256 invalidTemplateIdx = 1; - vm.expectRevert(EmailRecoverySubjectHandler.InvalidTemplateIndex.selector); + vm.expectRevert( + abi.encodeWithSelector( + EmailRecoverySubjectHandler.InvalidTemplateIndex.selector, invalidTemplateIdx, 0 + ) + ); emailRecoveryHandler.validateRecoverySubject( invalidTemplateIdx, subjectParams, emailRecoveryManagerAddress ); @@ -35,7 +39,13 @@ contract EmailRecoverySubjectHandler_validateRecoverySubject_Test is UnitBase { function test_ValidateRecoverySubject_RevertWhen_NoSubjectParams() public { bytes[] memory emptySubjectParams; - vm.expectRevert(EmailRecoverySubjectHandler.InvalidSubjectParams.selector); + vm.expectRevert( + abi.encodeWithSelector( + EmailRecoverySubjectHandler.InvalidSubjectParams.selector, + emptySubjectParams.length, + 3 + ) + ); emailRecoveryHandler.validateRecoverySubject( templateIdx, emptySubjectParams, emailRecoveryManagerAddress ); @@ -48,7 +58,13 @@ contract EmailRecoverySubjectHandler_validateRecoverySubject_Test is UnitBase { longSubjectParams[2] = abi.encode(calldataHashString); longSubjectParams[3] = abi.encode("extra param"); - vm.expectRevert(EmailRecoverySubjectHandler.InvalidSubjectParams.selector); + vm.expectRevert( + abi.encodeWithSelector( + EmailRecoverySubjectHandler.InvalidSubjectParams.selector, + longSubjectParams.length, + 3 + ) + ); emailRecoveryHandler.validateRecoverySubject( templateIdx, longSubjectParams, emailRecoveryManagerAddress ); @@ -66,7 +82,11 @@ contract EmailRecoverySubjectHandler_validateRecoverySubject_Test is UnitBase { function test_ValidateRecoverySubject_RevertWhen_RecoveryModuleAddressIsZero() public { subjectParams[1] = abi.encode(address(0)); - vm.expectRevert(EmailRecoverySubjectHandler.InvalidRecoveryModule.selector); + vm.expectRevert( + abi.encodeWithSelector( + EmailRecoverySubjectHandler.InvalidRecoveryModule.selector, address(0) + ) + ); emailRecoveryHandler.validateRecoverySubject( templateIdx, subjectParams, emailRecoveryManagerAddress ); @@ -77,7 +97,11 @@ contract EmailRecoverySubjectHandler_validateRecoverySubject_Test is UnitBase { { subjectParams[1] = abi.encode(address(1)); - vm.expectRevert(EmailRecoverySubjectHandler.InvalidRecoveryModule.selector); + vm.expectRevert( + abi.encodeWithSelector( + EmailRecoverySubjectHandler.InvalidRecoveryModule.selector, address(1) + ) + ); emailRecoveryHandler.validateRecoverySubject( templateIdx, subjectParams, emailRecoveryManagerAddress ); diff --git a/test/unit/handlers/SafeRecoverySubjectHandler/parseRecoveryCalldataHash.t.sol b/test/unit/handlers/SafeRecoverySubjectHandler/parseRecoveryCalldataHash.t.sol index 37924ba..2177a2b 100644 --- a/test/unit/handlers/SafeRecoverySubjectHandler/parseRecoveryCalldataHash.t.sol +++ b/test/unit/handlers/SafeRecoverySubjectHandler/parseRecoveryCalldataHash.t.sol @@ -22,7 +22,11 @@ contract SafeRecoverySubjectHandler_parseRecoveryCalldataHash_Test is SafeUnitBa skipIfNotSafeAccountType(); uint256 invalidTemplateIdx = 1; - vm.expectRevert(SafeRecoverySubjectHandler.InvalidTemplateIndex.selector); + vm.expectRevert( + abi.encodeWithSelector( + SafeRecoverySubjectHandler.InvalidTemplateIndex.selector, invalidTemplateIdx, 0 + ) + ); safeRecoverySubjectHandler.parseRecoveryCalldataHash(invalidTemplateIdx, subjectParams); } diff --git a/test/unit/handlers/SafeRecoverySubjectHandler/validateAcceptanceSubject.t.sol b/test/unit/handlers/SafeRecoverySubjectHandler/validateAcceptanceSubject.t.sol index d39e380..98203fb 100644 --- a/test/unit/handlers/SafeRecoverySubjectHandler/validateAcceptanceSubject.t.sol +++ b/test/unit/handlers/SafeRecoverySubjectHandler/validateAcceptanceSubject.t.sol @@ -16,7 +16,11 @@ contract SafeRecoverySubjectHandler_validateAcceptanceSubject_Test is SafeUnitBa subjectParams[0] = abi.encode(accountAddress1); uint256 invalidTemplateIdx = 1; - vm.expectRevert(SafeRecoverySubjectHandler.InvalidTemplateIndex.selector); + vm.expectRevert( + abi.encodeWithSelector( + SafeRecoverySubjectHandler.InvalidTemplateIndex.selector, invalidTemplateIdx, 0 + ) + ); safeRecoverySubjectHandler.validateAcceptanceSubject(invalidTemplateIdx, subjectParams); } @@ -24,7 +28,13 @@ contract SafeRecoverySubjectHandler_validateAcceptanceSubject_Test is SafeUnitBa skipIfNotSafeAccountType(); bytes[] memory emptySubjectParams; - vm.expectRevert(SafeRecoverySubjectHandler.InvalidSubjectParams.selector); + vm.expectRevert( + abi.encodeWithSelector( + SafeRecoverySubjectHandler.InvalidSubjectParams.selector, + emptySubjectParams.length, + 1 + ) + ); safeRecoverySubjectHandler.validateAcceptanceSubject(templateIdx, emptySubjectParams); } @@ -34,7 +44,11 @@ contract SafeRecoverySubjectHandler_validateAcceptanceSubject_Test is SafeUnitBa subjectParams[0] = abi.encode(accountAddress1); subjectParams[1] = abi.encode("extra param"); - vm.expectRevert(SafeRecoverySubjectHandler.InvalidSubjectParams.selector); + vm.expectRevert( + abi.encodeWithSelector( + SafeRecoverySubjectHandler.InvalidSubjectParams.selector, subjectParams.length, 1 + ) + ); safeRecoverySubjectHandler.validateAcceptanceSubject(templateIdx, subjectParams); } diff --git a/test/unit/handlers/SafeRecoverySubjectHandler/validateRecoverySubject.t.sol b/test/unit/handlers/SafeRecoverySubjectHandler/validateRecoverySubject.t.sol index e2e87e1..56dd4f7 100644 --- a/test/unit/handlers/SafeRecoverySubjectHandler/validateRecoverySubject.t.sol +++ b/test/unit/handlers/SafeRecoverySubjectHandler/validateRecoverySubject.t.sol @@ -25,7 +25,11 @@ contract SafeRecoverySubjectHandler_validateRecoverySubject_Test is SafeUnitBase skipIfNotSafeAccountType(); uint256 invalidTemplateIdx = 1; - vm.expectRevert(SafeRecoverySubjectHandler.InvalidTemplateIndex.selector); + vm.expectRevert( + abi.encodeWithSelector( + SafeRecoverySubjectHandler.InvalidTemplateIndex.selector, invalidTemplateIdx, 0 + ) + ); safeRecoverySubjectHandler.validateRecoverySubject( invalidTemplateIdx, subjectParams, emailRecoveryManagerAddress ); @@ -35,7 +39,13 @@ contract SafeRecoverySubjectHandler_validateRecoverySubject_Test is SafeUnitBase skipIfNotSafeAccountType(); bytes[] memory emptySubjectParams; - vm.expectRevert(SafeRecoverySubjectHandler.InvalidSubjectParams.selector); + vm.expectRevert( + abi.encodeWithSelector( + SafeRecoverySubjectHandler.InvalidSubjectParams.selector, + emptySubjectParams.length, + 4 + ) + ); safeRecoverySubjectHandler.validateRecoverySubject( templateIdx, emptySubjectParams, emailRecoveryManagerAddress ); @@ -50,7 +60,13 @@ contract SafeRecoverySubjectHandler_validateRecoverySubject_Test is SafeUnitBase longSubjectParams[3] = subjectParams[3]; longSubjectParams[4] = abi.encode("extra param"); - vm.expectRevert(SafeRecoverySubjectHandler.InvalidSubjectParams.selector); + vm.expectRevert( + abi.encodeWithSelector( + SafeRecoverySubjectHandler.InvalidSubjectParams.selector, + longSubjectParams.length, + 4 + ) + ); safeRecoverySubjectHandler.validateRecoverySubject( templateIdx, longSubjectParams, emailRecoveryManagerAddress ); @@ -60,7 +76,9 @@ contract SafeRecoverySubjectHandler_validateRecoverySubject_Test is SafeUnitBase skipIfNotSafeAccountType(); subjectParams[1] = abi.encode(address(0)); - vm.expectRevert(SafeRecoverySubjectHandler.InvalidOldOwner.selector); + vm.expectRevert( + abi.encodeWithSelector(SafeRecoverySubjectHandler.InvalidOldOwner.selector, address(0)) + ); safeRecoverySubjectHandler.validateRecoverySubject( templateIdx, subjectParams, emailRecoveryManagerAddress ); @@ -70,7 +88,9 @@ contract SafeRecoverySubjectHandler_validateRecoverySubject_Test is SafeUnitBase skipIfNotSafeAccountType(); subjectParams[2] = abi.encode(address(0)); - vm.expectRevert(SafeRecoverySubjectHandler.InvalidNewOwner.selector); + vm.expectRevert( + abi.encodeWithSelector(SafeRecoverySubjectHandler.InvalidNewOwner.selector, address(0)) + ); safeRecoverySubjectHandler.validateRecoverySubject( templateIdx, subjectParams, emailRecoveryManagerAddress ); @@ -80,7 +100,9 @@ contract SafeRecoverySubjectHandler_validateRecoverySubject_Test is SafeUnitBase skipIfNotSafeAccountType(); subjectParams[2] = abi.encode(owner1); - vm.expectRevert(SafeRecoverySubjectHandler.InvalidNewOwner.selector); + vm.expectRevert( + abi.encodeWithSelector(SafeRecoverySubjectHandler.InvalidNewOwner.selector, owner1) + ); safeRecoverySubjectHandler.validateRecoverySubject( templateIdx, subjectParams, emailRecoveryManagerAddress ); @@ -90,7 +112,11 @@ contract SafeRecoverySubjectHandler_validateRecoverySubject_Test is SafeUnitBase skipIfNotSafeAccountType(); subjectParams[3] = abi.encode(address(0)); - vm.expectRevert(SafeRecoverySubjectHandler.InvalidRecoveryModule.selector); + vm.expectRevert( + abi.encodeWithSelector( + SafeRecoverySubjectHandler.InvalidRecoveryModule.selector, address(0) + ) + ); safeRecoverySubjectHandler.validateRecoverySubject( templateIdx, subjectParams, emailRecoveryManagerAddress ); @@ -102,7 +128,11 @@ contract SafeRecoverySubjectHandler_validateRecoverySubject_Test is SafeUnitBase skipIfNotSafeAccountType(); subjectParams[3] = abi.encode(address(1)); - vm.expectRevert(SafeRecoverySubjectHandler.InvalidRecoveryModule.selector); + vm.expectRevert( + abi.encodeWithSelector( + SafeRecoverySubjectHandler.InvalidRecoveryModule.selector, address(1) + ) + ); safeRecoverySubjectHandler.validateRecoverySubject( templateIdx, subjectParams, emailRecoveryManagerAddress ); diff --git a/test/unit/libraries/GuardianUtils/addGuardian.t.sol b/test/unit/libraries/GuardianUtils/addGuardian.t.sol index bd1478c..31a6dbf 100644 --- a/test/unit/libraries/GuardianUtils/addGuardian.t.sol +++ b/test/unit/libraries/GuardianUtils/addGuardian.t.sol @@ -20,7 +20,11 @@ contract GuardianUtils_addGuardian_Test is UnitBase { address invalidGuardianAddress = address(0); vm.startPrank(accountAddress); - vm.expectRevert(GuardianUtils.InvalidGuardianAddress.selector); + vm.expectRevert( + abi.encodeWithSelector( + GuardianUtils.InvalidGuardianAddress.selector, invalidGuardianAddress + ) + ); emailRecoveryManager.addGuardian(invalidGuardianAddress, guardianWeights[0]); } @@ -28,7 +32,11 @@ contract GuardianUtils_addGuardian_Test is UnitBase { address invalidGuardianAddress = accountAddress; vm.startPrank(accountAddress); - vm.expectRevert(GuardianUtils.InvalidGuardianAddress.selector); + vm.expectRevert( + abi.encodeWithSelector( + GuardianUtils.InvalidGuardianAddress.selector, invalidGuardianAddress + ) + ); emailRecoveryManager.addGuardian(invalidGuardianAddress, guardianWeights[0]); } diff --git a/test/unit/libraries/GuardianUtils/changeThreshold.t.sol b/test/unit/libraries/GuardianUtils/changeThreshold.t.sol index aa39986..89a6567 100644 --- a/test/unit/libraries/GuardianUtils/changeThreshold.t.sol +++ b/test/unit/libraries/GuardianUtils/changeThreshold.t.sol @@ -20,7 +20,11 @@ contract GuardianUtils_changeThreshold_Test is UnitBase { uint256 highThreshold = totalWeight + 1; vm.startPrank(accountAddress); - vm.expectRevert(GuardianUtils.ThresholdExceedsTotalWeight.selector); + vm.expectRevert( + abi.encodeWithSelector( + GuardianUtils.ThresholdExceedsTotalWeight.selector, highThreshold, totalWeight + ) + ); emailRecoveryManager.changeThreshold(highThreshold); } diff --git a/test/unit/libraries/GuardianUtils/removeGuardian.t.sol b/test/unit/libraries/GuardianUtils/removeGuardian.t.sol index eaa96b5..d666955 100644 --- a/test/unit/libraries/GuardianUtils/removeGuardian.t.sol +++ b/test/unit/libraries/GuardianUtils/removeGuardian.t.sol @@ -34,7 +34,13 @@ contract GuardianUtils_removeGuardian_Test is UnitBase { acceptGuardian(accountSalt1); vm.startPrank(accountAddress); - vm.expectRevert(GuardianUtils.ThresholdExceedsTotalWeight.selector); + vm.expectRevert( + abi.encodeWithSelector( + GuardianUtils.ThresholdExceedsTotalWeight.selector, + totalWeight - guardianWeights[1], + threshold + ) + ); emailRecoveryManager.removeGuardian(guardian); } diff --git a/test/unit/libraries/GuardianUtils/setupGuardians.t.sol b/test/unit/libraries/GuardianUtils/setupGuardians.t.sol index cfff2d5..6c71b0c 100644 --- a/test/unit/libraries/GuardianUtils/setupGuardians.t.sol +++ b/test/unit/libraries/GuardianUtils/setupGuardians.t.sol @@ -23,7 +23,13 @@ contract GuardianUtils_setupGuardians_Test is UnitBase { invalidGuardianWeights[2] = 1; invalidGuardianWeights[3] = 1; - vm.expectRevert(GuardianUtils.IncorrectNumberOfWeights.selector); + vm.expectRevert( + abi.encodeWithSelector( + GuardianUtils.IncorrectNumberOfWeights.selector, + guardians.length, + invalidGuardianWeights.length + ) + ); emailRecoveryManager.exposed_setupGuardians( accountAddress, guardians, invalidGuardianWeights, threshold ); @@ -41,7 +47,9 @@ contract GuardianUtils_setupGuardians_Test is UnitBase { function test_SetupGuardians_RevertWhen_InvalidGuardianAddress() public { guardians[0] = address(0); - vm.expectRevert(GuardianUtils.InvalidGuardianAddress.selector); + vm.expectRevert( + abi.encodeWithSelector(GuardianUtils.InvalidGuardianAddress.selector, guardians[0]) + ); emailRecoveryManager.exposed_setupGuardians( accountAddress, guardians, guardianWeights, threshold ); @@ -50,7 +58,9 @@ contract GuardianUtils_setupGuardians_Test is UnitBase { function test_SetupGuardians_RevertWhen_GuardianAddressIsAccountAddress() public { guardians[0] = accountAddress; - vm.expectRevert(GuardianUtils.InvalidGuardianAddress.selector); + vm.expectRevert( + abi.encodeWithSelector(GuardianUtils.InvalidGuardianAddress.selector, guardians[0]) + ); emailRecoveryManager.exposed_setupGuardians( accountAddress, guardians, guardianWeights, threshold ); @@ -85,7 +95,11 @@ contract GuardianUtils_setupGuardians_Test is UnitBase { instance.uninstallModule(MODULE_TYPE_EXECUTOR, recoveryModuleAddress, ""); vm.stopPrank(); - vm.expectRevert(GuardianUtils.ThresholdExceedsTotalWeight.selector); + vm.expectRevert( + abi.encodeWithSelector( + GuardianUtils.ThresholdExceedsTotalWeight.selector, invalidThreshold, totalWeight + ) + ); emailRecoveryManager.exposed_setupGuardians( accountAddress, guardians, guardianWeights, invalidThreshold ); diff --git a/test/unit/libraries/GuardianUtils/updateGuardianStatus.t.sol b/test/unit/libraries/GuardianUtils/updateGuardianStatus.t.sol index 5a90a59..07399cd 100644 --- a/test/unit/libraries/GuardianUtils/updateGuardianStatus.t.sol +++ b/test/unit/libraries/GuardianUtils/updateGuardianStatus.t.sol @@ -23,7 +23,9 @@ contract GuardianUtils_updateGuardianStatus_Test is UnitBase { function test_UpdateGuardianStatus_RevertWhen_StatusIsAlreadyNONE() public { GuardianStatus newStatus = GuardianStatus.NONE; - vm.expectRevert(GuardianUtils.StatusCannotBeTheSame.selector); + vm.expectRevert( + abi.encodeWithSelector(GuardianUtils.StatusCannotBeTheSame.selector, uint256(newStatus)) + ); emailRecoveryManager.exposed_updateGuardianStatus(accountAddress, guardian1, newStatus); } @@ -32,7 +34,9 @@ contract GuardianUtils_updateGuardianStatus_Test is UnitBase { emailRecoveryManager.exposed_updateGuardianStatus(accountAddress, guardian1, newStatus); - vm.expectRevert(GuardianUtils.StatusCannotBeTheSame.selector); + vm.expectRevert( + abi.encodeWithSelector(GuardianUtils.StatusCannotBeTheSame.selector, uint256(newStatus)) + ); emailRecoveryManager.exposed_updateGuardianStatus(accountAddress, guardian1, newStatus); } @@ -41,7 +45,9 @@ contract GuardianUtils_updateGuardianStatus_Test is UnitBase { emailRecoveryManager.exposed_updateGuardianStatus(accountAddress, guardian1, newStatus); - vm.expectRevert(GuardianUtils.StatusCannotBeTheSame.selector); + vm.expectRevert( + abi.encodeWithSelector(GuardianUtils.StatusCannotBeTheSame.selector, uint256(newStatus)) + ); emailRecoveryManager.exposed_updateGuardianStatus(accountAddress, guardian1, newStatus); }