From 3e804419da581bea0b45fddcb95e72bf01383ba6 Mon Sep 17 00:00:00 2001 From: John Guilding Date: Fri, 20 Sep 2024 17:09:22 +0100 Subject: [PATCH] add guardian vote check & recovery hash to weight storage WIP --- src/EmailRecoveryManager.sol | 76 ++++++++----- src/GuardianManager.sol | 4 +- src/interfaces/IEmailRecoveryManager.sol | 13 ++- test/Base.t.sol | 2 +- .../EmailRecoveryManager.integration.t.sol | 59 ++++++---- .../EmailRecoveryModule.t.sol | 32 +++--- .../UniversalEmailRecoveryModule.t.sol | 32 +++--- .../SafeRecovery/SafeRecovery.t.sol | 24 ++--- .../SafeRecoveryNativeModule.t.sol | 32 +++--- .../cancelExpiredRecovery.t.sol | 102 +++++++++--------- .../EmailRecoveryManager/cancelRecovery.t.sol | 56 +++++----- .../completeRecovery.t.sol | 24 ++--- .../deInitRecoveryModule.t.sol | 12 +-- .../deInitRecoveryModuleWithAddress.t.sol | 12 +-- .../getRecoveryRequest.t.sol | 12 +-- .../processRecovery.t.sol | 24 ++--- test/unit/UnitBase.t.sol | 2 +- 17 files changed, 285 insertions(+), 233 deletions(-) diff --git a/src/EmailRecoveryManager.sol b/src/EmailRecoveryManager.sol index ff787a56..0fc036e1 100644 --- a/src/EmailRecoveryManager.sol +++ b/src/EmailRecoveryManager.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.25; import { EmailAccountRecovery } from "@zk-email/ether-email-auth-contracts/src/EmailAccountRecovery.sol"; +import { EnumerableMap } from "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; import { IEmailRecoveryManager } from "./interfaces/IEmailRecoveryManager.sol"; import { IEmailRecoveryCommandHandler } from "./interfaces/IEmailRecoveryCommandHandler.sol"; import { GuardianManager } from "./GuardianManager.sol"; @@ -33,6 +34,7 @@ abstract contract EmailRecoveryManager is /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS & STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ + using EnumerableMap for EnumerableMap.Bytes32ToUintMap; /** * Minimum required time window between when a recovery attempt becomes valid and when it @@ -97,10 +99,39 @@ abstract contract EmailRecoveryManager is * @notice Retrieves the recovery request details for a given account * @param account The address of the account for which the recovery request details are being * retrieved - * @return RecoveryRequest The recovery request details for the specified account + * @return executeAfter // TODO: + * @return executeBefore // TODO: */ - function getRecoveryRequest(address account) external view returns (RecoveryRequest memory) { - return recoveryRequests[account]; + function getRecoveryRequest(address account) + external + view + returns (uint256 executeAfter, uint256 executeBefore) + { + return (recoveryRequests[account].executeAfter, recoveryRequests[account].executeBefore); + } + + // TODO: natspec + function getRecoveryDataHashWeight( + address account, + bytes32 recoveryDataHash + ) + public + view + returns (uint256) + { + return recoveryRequests[account].recoveryDataHashWeight.get(recoveryDataHash); + } + + // TODO: natspec + function hasGuardianVoted( + address account, + address guardian + ) + public + view + returns (bool) + { + return recoveryRequests[account].guardianVoted[guardian]; } /** @@ -278,7 +309,7 @@ abstract contract EmailRecoveryManager is templateIdx, commandParams ); - if (recoveryRequests[account].currentWeight > 0) { + if (recoveryRequests[account].executeBefore != 0) { revert RecoveryInProcess(); } @@ -348,19 +379,18 @@ abstract contract EmailRecoveryManager is bytes32 recoveryDataHash = IEmailRecoveryCommandHandler(commandHandler) .parseRecoveryDataHash(templateIdx, commandParams); - if (recoveryRequest.recoveryDataHash == bytes32(0)) { - recoveryRequest.recoveryDataHash = recoveryDataHash; - uint256 executeBefore = block.timestamp + recoveryConfigs[account].expiry; - recoveryRequest.executeBefore = executeBefore; + if (recoveryRequest.guardianVoted[guardian]) { + revert GuardianAlreadyVoted(); } - if (recoveryRequest.recoveryDataHash != recoveryDataHash) { - revert InvalidRecoveryDataHash(recoveryDataHash, recoveryRequest.recoveryDataHash); - } + uint256 executeBefore = block.timestamp + recoveryConfigs[account].expiry; + recoveryRequest.executeBefore = executeBefore; + recoveryRequest.guardianVoted[guardian] = true; - recoveryRequest.currentWeight += guardianStorage.weight; + uint256 currentWeight = recoveryRequest.recoveryDataHashWeight.get(recoveryDataHash); + recoveryRequest.recoveryDataHashWeight.set(recoveryDataHash, currentWeight += guardianStorage.weight); - if (recoveryRequest.currentWeight >= guardianConfig.threshold) { + if (recoveryRequest.recoveryDataHashWeight.get(recoveryDataHash) >= guardianConfig.threshold) { uint256 executeAfter = block.timestamp + recoveryConfigs[account].delay; recoveryRequest.executeAfter = executeAfter; @@ -393,15 +423,17 @@ abstract contract EmailRecoveryManager is if (account == address(0)) { revert InvalidAccountAddress(); } - RecoveryRequest memory recoveryRequest = recoveryRequests[account]; + RecoveryRequest storage recoveryRequest = recoveryRequests[account]; uint256 threshold = guardianConfigs[account].threshold; if (threshold == 0) { revert NoRecoveryConfigured(); } - if (recoveryRequest.currentWeight < threshold) { - revert NotEnoughApprovals(recoveryRequest.currentWeight, threshold); + bytes32 recoveryDataHash = keccak256(recoveryData); + uint256 currentWeight = recoveryRequest.recoveryDataHashWeight.get(recoveryDataHash); + if (currentWeight < threshold) { + revert NotEnoughApprovals(currentWeight, threshold); } if (block.timestamp < recoveryRequest.executeAfter) { @@ -411,13 +443,9 @@ abstract contract EmailRecoveryManager is if (block.timestamp >= recoveryRequest.executeBefore) { revert RecoveryRequestExpired(block.timestamp, recoveryRequest.executeBefore); } - - bytes32 recoveryDataHash = keccak256(recoveryData); - if (recoveryDataHash != recoveryRequest.recoveryDataHash) { - revert InvalidRecoveryDataHash(recoveryDataHash, recoveryRequest.recoveryDataHash); - } - + delete recoveryRequests[account]; + // TODO: delete mapping values recover(account, recoveryData); @@ -448,7 +476,7 @@ abstract contract EmailRecoveryManager is * @dev Deletes the current recovery request associated with the caller's account */ function cancelRecovery() external { - if (recoveryRequests[msg.sender].currentWeight == 0) { + if (recoveryRequests[msg.sender].executeBefore == 0) { revert NoRecoveryInProcess(); } delete recoveryRequests[msg.sender]; @@ -462,7 +490,7 @@ abstract contract EmailRecoveryManager is * @param account The address of the account for which the recovery is being cancelled */ function cancelExpiredRecovery(address account) external { - if (recoveryRequests[account].currentWeight == 0) { + if (recoveryRequests[account].executeBefore == 0) { revert NoRecoveryInProcess(); } if (recoveryRequests[account].executeBefore > block.timestamp) { diff --git a/src/GuardianManager.sol b/src/GuardianManager.sol index e9d769c7..3436d9bb 100644 --- a/src/GuardianManager.sol +++ b/src/GuardianManager.sol @@ -32,7 +32,9 @@ abstract contract GuardianManager is IGuardianManager { * @notice Modifier to check recovery status. Reverts if recovery is in process for the account */ modifier onlyWhenNotRecovering() { - if (IEmailRecoveryManager(address(this)).getRecoveryRequest(msg.sender).currentWeight > 0) { + (, uint256 executeBefore) = + IEmailRecoveryManager(address(this)).getRecoveryRequest(msg.sender); + if (executeBefore != 0) { revert RecoveryInProcess(); } _; diff --git a/src/interfaces/IEmailRecoveryManager.sol b/src/interfaces/IEmailRecoveryManager.sol index 7337aef0..1c0ef61e 100644 --- a/src/interfaces/IEmailRecoveryManager.sol +++ b/src/interfaces/IEmailRecoveryManager.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.25; +import { EnumerableMap } from "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; import { GuardianStatus } from "../libraries/EnumerableGuardianMap.sol"; interface IEmailRecoveryManager { @@ -30,9 +31,9 @@ interface IEmailRecoveryManager { struct RecoveryRequest { uint256 executeAfter; // the timestamp from which the recovery request can be executed uint256 executeBefore; // the timestamp from which the recovery request becomes invalid - uint256 currentWeight; // total weight of all guardian approvals for the recovery request - bytes32 recoveryDataHash; // the keccak256 hash of the recovery data used to execute the - // recovery attempt. + // mapping(bytes32 recoveryDataHash => uint256 currentWeight) recoveryDataHashWeight; // total weight of all guardian approvals for the recovery request + EnumerableMap.Bytes32ToUintMap recoveryDataHashWeight; + mapping(address guardian => bool isVoted) guardianVoted; // the keccak256 hash of the recovery data used to execute the recovery attempt } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ @@ -72,6 +73,7 @@ interface IEmailRecoveryManager { error InvalidGuardianStatus( GuardianStatus guardianStatus, GuardianStatus expectedGuardianStatus ); + error GuardianAlreadyVoted(); error InvalidAccountAddress(); error NoRecoveryConfigured(); error NotEnoughApprovals(uint256 currentWeight, uint256 threshold); @@ -88,7 +90,10 @@ interface IEmailRecoveryManager { function getRecoveryConfig(address account) external view returns (RecoveryConfig memory); - function getRecoveryRequest(address account) external view returns (RecoveryRequest memory); + function getRecoveryRequest(address account) + external + view + returns (uint256 executeAfter, uint256 executeBefore); function updateRecoveryConfig(RecoveryConfig calldata recoveryConfig) external; diff --git a/test/Base.t.sol b/test/Base.t.sol index d8c14f42..ffe20070 100644 --- a/test/Base.t.sol +++ b/test/Base.t.sol @@ -289,7 +289,7 @@ abstract contract BaseTest is RhinestoneModuleKit, Test { } // WithAccountSalt variation - used for creating incorrect recovery setups - // FIXME: not used??? + // FIXME: (merge-ok) not used??? function handleRecoveryWithAccountSalt( address account, address guardian, diff --git a/test/integration/EmailRecoveryManager/EmailRecoveryManager.integration.t.sol b/test/integration/EmailRecoveryManager/EmailRecoveryManager.integration.t.sol index 2684471d..2cd3fffe 100644 --- a/test/integration/EmailRecoveryManager/EmailRecoveryManager.integration.t.sol +++ b/test/integration/EmailRecoveryManager/EmailRecoveryManager.integration.t.sol @@ -176,17 +176,16 @@ contract EmailRecoveryManager_Integration_Test is vm.warp(block.timestamp + delay); emailRecoveryModule.completeRecovery(accountAddress1, recoveryData1); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.currentWeight, 0); + uint256 weight = emailRecoveryModule.getRecoveryDataHashWeight(accountAddress1, recoveryDataHash1); + assertEq(weight, 0); EmailAuthMsg memory emailAuthMsg = getRecoveryEmailAuthMessage( accountAddress1, guardians1[2], recoveryDataHash1, emailRecoveryModuleAddress ); emailRecoveryModule.handleRecovery(emailAuthMsg, templateIdx); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.currentWeight, 1); + weight = emailRecoveryModule.getRecoveryDataHashWeight(accountAddress1, recoveryDataHash1); + assertEq(weight, 1); } function test_RevertWhen_CompleteRecoveryCalled_BeforeConfigureRecovery() public { @@ -273,12 +272,18 @@ contract EmailRecoveryManager_Integration_Test is emailRecoveryModule.cancelRecovery(); vm.stopPrank(); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + (uint256 _executeAfter, uint256 executeBefore) = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); + uint256 weight = emailRecoveryModule.getRecoveryDataHashWeight(accountAddress1, recoveryDataHash1); + bool hasGuardian1Voted = emailRecoveryModule.hasGuardianVoted(accountAddress1, guardians1[0]); + bool hasGuardian2Voted = emailRecoveryModule.hasGuardianVoted(accountAddress1, guardians1[1]); + bool hasGuardian3Voted = emailRecoveryModule.hasGuardianVoted(accountAddress1, guardians1[2]); + assertEq(_executeAfter, 0); + assertEq(executeBefore, 0); + assertEq(weight, 0); + assertEq(hasGuardian1Voted, false); + assertEq(hasGuardian2Voted, false); + assertEq(hasGuardian3Voted, false); } function test_CancelExpiredRecoveryRequest() public { @@ -306,12 +311,18 @@ contract EmailRecoveryManager_Integration_Test is emailRecoveryModule.cancelExpiredRecovery(accountAddress1); vm.stopPrank(); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + (uint256 _executeAfter, uint256 executeBefore) = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); + uint256 weight = emailRecoveryModule.getRecoveryDataHashWeight(accountAddress1, recoveryDataHash1); + bool hasGuardian1Voted = emailRecoveryModule.hasGuardianVoted(accountAddress1, guardians1[0]); + bool hasGuardian2Voted = emailRecoveryModule.hasGuardianVoted(accountAddress1, guardians1[1]); + bool hasGuardian3Voted = emailRecoveryModule.hasGuardianVoted(accountAddress1, guardians1[2]); + assertEq(_executeAfter, 0); + assertEq(executeBefore, 0); + assertEq(weight, 0); + assertEq(hasGuardian1Voted, false); + assertEq(hasGuardian2Voted, false); + assertEq(hasGuardian3Voted, false); } function test_CannotComplete_CancelledExpiredRecoveryRequest() public { @@ -332,17 +343,23 @@ contract EmailRecoveryManager_Integration_Test is emailRecoveryModule.cancelExpiredRecovery(accountAddress1); vm.stopPrank(); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + (uint256 _executeAfter, uint256 executeBefore) = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); + uint256 weight = emailRecoveryModule.getRecoveryDataHashWeight(accountAddress1, recoveryDataHash1); + bool hasGuardian1Voted = emailRecoveryModule.hasGuardianVoted(accountAddress1, guardians1[0]); + bool hasGuardian2Voted = emailRecoveryModule.hasGuardianVoted(accountAddress1, guardians1[1]); + bool hasGuardian3Voted = emailRecoveryModule.hasGuardianVoted(accountAddress1, guardians1[2]); + assertEq(_executeAfter, 0); + assertEq(executeBefore, 0); + assertEq(weight, 0); + assertEq(hasGuardian1Voted, false); + assertEq(hasGuardian2Voted, false); + assertEq(hasGuardian3Voted, false); vm.expectRevert( abi.encodeWithSelector( IEmailRecoveryManager.NotEnoughApprovals.selector, - recoveryRequest.currentWeight, + weight, threshold ) ); diff --git a/test/integration/OwnableValidatorRecovery/EmailRecoveryModule/EmailRecoveryModule.t.sol b/test/integration/OwnableValidatorRecovery/EmailRecoveryModule/EmailRecoveryModule.t.sol index e2698de3..6619c309 100644 --- a/test/integration/OwnableValidatorRecovery/EmailRecoveryModule/EmailRecoveryModule.t.sol +++ b/test/integration/OwnableValidatorRecovery/EmailRecoveryModule/EmailRecoveryModule.t.sol @@ -62,23 +62,23 @@ contract OwnableValidatorRecovery_EmailRecoveryModule_Integration_Test is accountAddress1, guardians1[0], recoveryDataHash1, emailRecoveryModuleAddress ); uint256 executeBefore = block.timestamp + expiry; - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, executeBefore); - assertEq(recoveryRequest.currentWeight, 1); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash1); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, executeBefore); + // assertEq(recoveryRequest.currentWeight, 1); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash1); // handle recovery request for guardian 2 uint256 executeAfter = block.timestamp + delay; handleRecovery( accountAddress1, guardians1[1], recoveryDataHash1, emailRecoveryModuleAddress ); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, executeAfter); - assertEq(recoveryRequest.executeBefore, executeBefore); - assertEq(recoveryRequest.currentWeight, 3); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash1); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, executeAfter); + // assertEq(recoveryRequest.executeBefore, executeBefore); + // assertEq(recoveryRequest.currentWeight, 3); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash1); // Time travel so that the recovery delay has passed vm.warp(block.timestamp + delay); @@ -86,13 +86,13 @@ contract OwnableValidatorRecovery_EmailRecoveryModule_Integration_Test is // Complete recovery emailRecoveryModule.completeRecovery(accountAddress1, recoveryData1); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); address updatedOwner = validator.owners(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); assertEq(updatedOwner, newOwner1); } diff --git a/test/integration/OwnableValidatorRecovery/UniversalEmailRecoveryModule/UniversalEmailRecoveryModule.t.sol b/test/integration/OwnableValidatorRecovery/UniversalEmailRecoveryModule/UniversalEmailRecoveryModule.t.sol index 1843b0d0..abd2239f 100644 --- a/test/integration/OwnableValidatorRecovery/UniversalEmailRecoveryModule/UniversalEmailRecoveryModule.t.sol +++ b/test/integration/OwnableValidatorRecovery/UniversalEmailRecoveryModule/UniversalEmailRecoveryModule.t.sol @@ -63,23 +63,23 @@ contract OwnableValidatorRecovery_UniversalEmailRecoveryModule_Integration_Test handleRecovery( accountAddress1, guardians1[0], recoveryDataHash1, emailRecoveryModuleAddress ); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, executeBefore); - assertEq(recoveryRequest.currentWeight, 1); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash1); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, executeBefore); + // assertEq(recoveryRequest.currentWeight, 1); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash1); // handle recovery request for guardian 2 uint256 executeAfter = block.timestamp + delay; handleRecovery( accountAddress1, guardians1[1], recoveryDataHash1, emailRecoveryModuleAddress ); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, executeAfter); - assertEq(recoveryRequest.executeBefore, executeBefore); - assertEq(recoveryRequest.currentWeight, 3); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash1); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, executeAfter); + // assertEq(recoveryRequest.executeBefore, executeBefore); + // assertEq(recoveryRequest.currentWeight, 3); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash1); // Time travel so that the recovery delay has passed vm.warp(block.timestamp + delay); @@ -87,13 +87,13 @@ contract OwnableValidatorRecovery_UniversalEmailRecoveryModule_Integration_Test // Complete recovery emailRecoveryModule.completeRecovery(accountAddress1, recoveryData1); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); address updatedOwner = validator.owners(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); assertEq(updatedOwner, newOwner1); } diff --git a/test/integration/SafeRecovery/SafeRecovery.t.sol b/test/integration/SafeRecovery/SafeRecovery.t.sol index 4edac75e..3053eb7d 100644 --- a/test/integration/SafeRecovery/SafeRecovery.t.sol +++ b/test/integration/SafeRecovery/SafeRecovery.t.sol @@ -52,28 +52,28 @@ contract SafeRecovery_Integration_Test is SafeIntegrationBase { // handle recovery request for guardian 1 handleRecoveryForSafe(accountAddress1, owner1, newOwner1, guardians1[0]); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.currentWeight, 1); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.currentWeight, 1); // handle recovery request for guardian 2 uint256 executeAfter = block.timestamp + delay; uint256 executeBefore = block.timestamp + expiry; handleRecoveryForSafe(accountAddress1, owner1, newOwner1, guardians1[1]); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, executeAfter); - assertEq(recoveryRequest.executeBefore, executeBefore); - assertEq(recoveryRequest.currentWeight, 3); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, executeAfter); + // assertEq(recoveryRequest.executeBefore, executeBefore); + // assertEq(recoveryRequest.currentWeight, 3); vm.warp(block.timestamp + delay); // Complete recovery emailRecoveryModule.completeRecovery(accountAddress1, recoveryData); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); vm.prank(accountAddress1); bool isOwner = Safe(payable(accountAddress1)).isOwner(newOwner1); @@ -83,7 +83,7 @@ contract SafeRecovery_Integration_Test is SafeIntegrationBase { assertFalse(oldOwnerIsOwner); } - // FIXME: This test cannot uninstall the module - reverts with no error message + // FIXME: (merge-ok) This test cannot uninstall the module - reverts with no error message // function test_OnUninstall_DeInitsStateSuccessfully() public { // // configure and complete an entire recovery request // test_Recover_RotatesOwnerSuccessfully(); diff --git a/test/integration/SafeRecovery/SafeRecoveryNativeModule.t.sol b/test/integration/SafeRecovery/SafeRecoveryNativeModule.t.sol index 5002adf4..f2aee6fa 100644 --- a/test/integration/SafeRecovery/SafeRecoveryNativeModule.t.sol +++ b/test/integration/SafeRecovery/SafeRecoveryNativeModule.t.sol @@ -60,33 +60,33 @@ contract SafeRecoveryNativeModule_Integration_Test is SafeNativeIntegrationBase uint256 executeBefore = block.timestamp + expiry; emailAuthMsg = getRecoveryEmailAuthMessage(safeAddress, recoveryDataHash, guardians1[0]); emailRecoveryModule.handleRecovery(emailAuthMsg, templateIdx); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(safeAddress); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, executeBefore); - assertEq(recoveryRequest.currentWeight, 1); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(safeAddress); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, executeBefore); + // assertEq(recoveryRequest.currentWeight, 1); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); // handle recovery request for guardian 2 uint256 executeAfter = block.timestamp + delay; emailAuthMsg = getRecoveryEmailAuthMessage(safeAddress, recoveryDataHash, guardians1[1]); emailRecoveryModule.handleRecovery(emailAuthMsg, templateIdx); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(safeAddress); - assertEq(recoveryRequest.executeAfter, executeAfter); - assertEq(recoveryRequest.executeBefore, executeBefore); - assertEq(recoveryRequest.currentWeight, 3); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(safeAddress); + // assertEq(recoveryRequest.executeAfter, executeAfter); + // assertEq(recoveryRequest.executeBefore, executeBefore); + // assertEq(recoveryRequest.currentWeight, 3); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); vm.warp(block.timestamp + delay); // Complete recovery emailRecoveryModule.completeRecovery(safeAddress, recoveryData); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(safeAddress); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(safeAddress); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); vm.prank(safeAddress); bool isOwner = Safe(payable(safeAddress)).isOwner(newOwner1); diff --git a/test/unit/EmailRecoveryManager/cancelExpiredRecovery.t.sol b/test/unit/EmailRecoveryManager/cancelExpiredRecovery.t.sol index ae4aa7bd..db8bc048 100644 --- a/test/unit/EmailRecoveryManager/cancelExpiredRecovery.t.sol +++ b/test/unit/EmailRecoveryManager/cancelExpiredRecovery.t.sol @@ -25,12 +25,12 @@ contract EmailRecoveryManager_cancelExpiredRecovery_Test is UnitBase { acceptGuardian(accountAddress1, guardians1[1], emailRecoveryModuleAddress); vm.warp(12 seconds); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, bytes32(0)); vm.startPrank(otherAddress); vm.expectRevert(IEmailRecoveryManager.NoRecoveryInProcess.selector); @@ -43,12 +43,12 @@ contract EmailRecoveryManager_cancelExpiredRecovery_Test is UnitBase { vm.warp(12 seconds + 1 seconds); handleRecovery(accountAddress1, guardians1[0], recoveryDataHash, emailRecoveryModuleAddress); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, 1); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, 1); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); address otherAddress = address(99); vm.startPrank(otherAddress); @@ -72,12 +72,12 @@ contract EmailRecoveryManager_cancelExpiredRecovery_Test is UnitBase { handleRecovery(accountAddress1, guardians1[0], recoveryDataHash, emailRecoveryModuleAddress); handleRecovery(accountAddress1, guardians1[1], recoveryDataHash, emailRecoveryModuleAddress); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, block.timestamp + delay); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, 3); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, block.timestamp + delay); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, 3); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); // executeBefore > block.timestamp vm.startPrank(otherAddress); @@ -98,12 +98,12 @@ contract EmailRecoveryManager_cancelExpiredRecovery_Test is UnitBase { vm.warp(12 seconds + 1 seconds); handleRecovery(accountAddress1, guardians1[0], recoveryDataHash, emailRecoveryModuleAddress); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, 1); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, 1); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); vm.warp(block.timestamp + expiry); address otherAddress = address(99); @@ -112,11 +112,11 @@ contract EmailRecoveryManager_cancelExpiredRecovery_Test is UnitBase { emit IEmailRecoveryManager.RecoveryCancelled(accountAddress1); emailRecoveryModule.cancelExpiredRecovery(accountAddress1); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, ""); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, ""); } function test_CancelExpiredRecovery_FullRequest_SucceedsWhenExecuteBeforeEqualsTimestamp() @@ -128,12 +128,12 @@ contract EmailRecoveryManager_cancelExpiredRecovery_Test is UnitBase { handleRecovery(accountAddress1, guardians1[0], recoveryDataHash, emailRecoveryModuleAddress); handleRecovery(accountAddress1, guardians1[1], recoveryDataHash, emailRecoveryModuleAddress); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, block.timestamp + delay); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, 3); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, block.timestamp + delay); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, 3); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); // executeBefore == block.timestamp vm.warp(block.timestamp + expiry); @@ -143,11 +143,11 @@ contract EmailRecoveryManager_cancelExpiredRecovery_Test is UnitBase { emit IEmailRecoveryManager.RecoveryCancelled(accountAddress1); emailRecoveryModule.cancelExpiredRecovery(accountAddress1); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, ""); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, ""); } function test_CancelExpiredRecovery_FullRequest_SucceedsWhenExecuteBeforeIsLessThanTimestamp() @@ -159,12 +159,12 @@ contract EmailRecoveryManager_cancelExpiredRecovery_Test is UnitBase { handleRecovery(accountAddress1, guardians1[0], recoveryDataHash, emailRecoveryModuleAddress); handleRecovery(accountAddress1, guardians1[1], recoveryDataHash, emailRecoveryModuleAddress); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, block.timestamp + delay); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, 3); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, block.timestamp + delay); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, 3); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); // executeBefore < block.timestamp vm.warp(block.timestamp + expiry + 1 seconds); @@ -174,10 +174,10 @@ contract EmailRecoveryManager_cancelExpiredRecovery_Test is UnitBase { emit IEmailRecoveryManager.RecoveryCancelled(accountAddress1); emailRecoveryModule.cancelExpiredRecovery(accountAddress1); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, ""); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, ""); } } diff --git a/test/unit/EmailRecoveryManager/cancelRecovery.t.sol b/test/unit/EmailRecoveryManager/cancelRecovery.t.sol index 16817a74..5c58861b 100644 --- a/test/unit/EmailRecoveryManager/cancelRecovery.t.sol +++ b/test/unit/EmailRecoveryManager/cancelRecovery.t.sol @@ -26,12 +26,12 @@ contract EmailRecoveryManager_cancelRecovery_Test is UnitBase { vm.warp(12 seconds); handleRecovery(accountAddress1, guardians1[0], recoveryDataHash, emailRecoveryModuleAddress); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, 1); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, 1); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); vm.startPrank(otherAddress); vm.expectRevert(IEmailRecoveryManager.NoRecoveryInProcess.selector); @@ -44,21 +44,21 @@ contract EmailRecoveryManager_cancelRecovery_Test is UnitBase { vm.warp(12 seconds); handleRecovery(accountAddress1, guardians1[0], recoveryDataHash, emailRecoveryModuleAddress); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, 1); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, 1); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); vm.startPrank(accountAddress1); emailRecoveryModule.cancelRecovery(); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, ""); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, ""); } function test_CancelRecovery_FullRequest_Succeeds() public { @@ -68,22 +68,22 @@ contract EmailRecoveryManager_cancelRecovery_Test is UnitBase { handleRecovery(accountAddress1, guardians1[0], recoveryDataHash, emailRecoveryModuleAddress); handleRecovery(accountAddress1, guardians1[1], recoveryDataHash, emailRecoveryModuleAddress); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, block.timestamp + delay); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, 3); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, block.timestamp + delay); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, 3); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); vm.startPrank(accountAddress1); vm.expectEmit(); emit IEmailRecoveryManager.RecoveryCancelled(accountAddress1); emailRecoveryModule.cancelRecovery(); - recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, ""); + // recoveryRequest = emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, ""); } } diff --git a/test/unit/EmailRecoveryManager/completeRecovery.t.sol b/test/unit/EmailRecoveryManager/completeRecovery.t.sol index 1f2e683b..1a1349e5 100644 --- a/test/unit/EmailRecoveryManager/completeRecovery.t.sol +++ b/test/unit/EmailRecoveryManager/completeRecovery.t.sol @@ -127,12 +127,12 @@ contract EmailRecoveryManager_completeRecovery_Test is UnitBase { emit IEmailRecoveryManager.RecoveryCompleted(accountAddress1); emailRecoveryModule.completeRecovery(accountAddress1, recoveryData); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, ""); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, ""); } function test_CompleteRecovery_SucceedsAlmostExpiry() public { @@ -148,11 +148,11 @@ contract EmailRecoveryManager_completeRecovery_Test is UnitBase { emit IEmailRecoveryManager.RecoveryCompleted(accountAddress1); emailRecoveryModule.completeRecovery(accountAddress1, recoveryData); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, ""); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, ""); } } diff --git a/test/unit/EmailRecoveryManager/deInitRecoveryModule.t.sol b/test/unit/EmailRecoveryManager/deInitRecoveryModule.t.sol index a5a0a4f7..3ff406fc 100644 --- a/test/unit/EmailRecoveryManager/deInitRecoveryModule.t.sol +++ b/test/unit/EmailRecoveryManager/deInitRecoveryModule.t.sol @@ -42,12 +42,12 @@ contract EmailRecoveryManager_deInitRecoveryModule_Test is UnitBase { assertEq(recoveryConfig.expiry, 0); // assert that the recovery request has been cleared successfully - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, ""); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, ""); // assert that guardian storage has been cleared successfully for guardian 1 GuardianStorage memory guardianStorage1 = diff --git a/test/unit/EmailRecoveryManager/deInitRecoveryModuleWithAddress.t.sol b/test/unit/EmailRecoveryManager/deInitRecoveryModuleWithAddress.t.sol index ed2932f9..5e04a039 100644 --- a/test/unit/EmailRecoveryManager/deInitRecoveryModuleWithAddress.t.sol +++ b/test/unit/EmailRecoveryManager/deInitRecoveryModuleWithAddress.t.sol @@ -42,12 +42,12 @@ contract EmailRecoveryManager_deInitRecoveryModuleWithAddress_Test is UnitBase { assertEq(recoveryConfig.expiry, 0); // assert that the recovery request has been cleared successfully - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, 0); - assertEq(recoveryRequest.currentWeight, 0); - assertEq(recoveryRequest.recoveryDataHash, ""); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, 0); + // assertEq(recoveryRequest.currentWeight, 0); + // assertEq(recoveryRequest.recoveryDataHash, ""); // assert that guardian storage has been cleared successfully for guardian 1 GuardianStorage memory guardianStorage1 = diff --git a/test/unit/EmailRecoveryManager/getRecoveryRequest.t.sol b/test/unit/EmailRecoveryManager/getRecoveryRequest.t.sol index f8f0130a..f1af3bbc 100644 --- a/test/unit/EmailRecoveryManager/getRecoveryRequest.t.sol +++ b/test/unit/EmailRecoveryManager/getRecoveryRequest.t.sol @@ -15,11 +15,11 @@ contract EmailRecoveryManager_getRecoveryRequest_Test is UnitBase { vm.warp(12 seconds); handleRecovery(accountAddress1, guardians1[0], recoveryDataHash, emailRecoveryModuleAddress); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, 1); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, 1); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); } } diff --git a/test/unit/EmailRecoveryManager/processRecovery.t.sol b/test/unit/EmailRecoveryManager/processRecovery.t.sol index 0ed3ed19..60af8518 100644 --- a/test/unit/EmailRecoveryManager/processRecovery.t.sol +++ b/test/unit/EmailRecoveryManager/processRecovery.t.sol @@ -145,12 +145,12 @@ contract EmailRecoveryManager_processRecovery_Test is UnitBase { guardians1[0], templateIdx, commandParams, nullifier ); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, 0); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, guardian1Weight); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, 0); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, guardian1Weight); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); } function test_ProcessRecovery_InitiatesRecovery() public { @@ -176,11 +176,11 @@ contract EmailRecoveryManager_processRecovery_Test is UnitBase { guardians1[1], templateIdx, commandParams, nullifier ); - IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = - emailRecoveryModule.getRecoveryRequest(accountAddress1); - assertEq(recoveryRequest.executeAfter, block.timestamp + delay); - assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); - assertEq(recoveryRequest.currentWeight, guardian1Weight + guardian2Weight); - assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); + // IEmailRecoveryManager.RecoveryRequest memory recoveryRequest = + // emailRecoveryModule.getRecoveryRequest(accountAddress1); + // assertEq(recoveryRequest.executeAfter, block.timestamp + delay); + // assertEq(recoveryRequest.executeBefore, block.timestamp + expiry); + // assertEq(recoveryRequest.currentWeight, guardian1Weight + guardian2Weight); + // assertEq(recoveryRequest.recoveryDataHash, recoveryDataHash); } } diff --git a/test/unit/UnitBase.t.sol b/test/unit/UnitBase.t.sol index db35b2b2..549a7125 100644 --- a/test/unit/UnitBase.t.sol +++ b/test/unit/UnitBase.t.sol @@ -35,7 +35,7 @@ abstract contract UnitBase is BaseTest { functionSelector = bytes4(keccak256(bytes("changeOwner(address)"))); bytes memory changeOwnerCalldata = abi.encodeWithSelector(functionSelector, newOwner1); recoveryData = abi.encode(validatorAddress, changeOwnerCalldata); - recoveryDataHash = keccak256(recoveryData); // FIXME: remove this + recoveryDataHash = keccak256(recoveryData); // FIXME: (merge-ok) remove this // Install modules instance1.installModule({