Skip to content

Commit

Permalink
Remove validator list length check in onUninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGuilding committed Jun 20, 2024
1 parent aee7b4e commit 11b8e9a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/modules/EmailRecoveryModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,7 @@ contract EmailRecoveryModule is ERC7579ExecutorBase, IRecoveryModule {

address[] memory allowedValidators = getAllowedValidators(msg.sender);

uint256 allowedValidatorsLength = allowedValidators.length;
if (validatorList.count != allowedValidatorsLength) {
// TODO: assess if this check is needed
revert InvalidValidatorsLength();
}

for (uint256 i; i < allowedValidatorsLength; i++) {
for (uint256 i; i < allowedValidators.length; i++) {
bytes4 allowedSelector = allowedSelectors[allowedValidators[i]][msg.sender];
delete selectorToValidator[allowedSelector][msg.sender];
delete allowedSelectors[allowedValidators[i]][msg.sender];
Expand Down
20 changes: 19 additions & 1 deletion test/unit/modules/EmailRecoveryModule/getAllowedValidators.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,35 @@ pragma solidity ^0.8.25;
import "forge-std/console2.sol";
import { ModuleKitHelpers } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR, MODULE_TYPE_VALIDATOR } from "modulekit/external/ERC7579.sol";
import { SentinelListHelper } from "sentinellist/SentinelListHelper.sol";
import { OwnableValidator } from "src/test/OwnableValidator.sol";
import { UnitBase } from "../../UnitBase.t.sol";

contract EmailRecoveryModule_getAllowedValidators_Test is UnitBase {
using ModuleKitHelpers for *;
using SentinelListHelper for address[];

function setUp() public override {
super.setUp();
}

function test_GetAllowedValidators_Succeeds() public {
function test_GetAllowedValidators_SucceedsWhenNoValidators() public {
address[] memory allowedValidators =
emailRecoveryModule.getAllowedValidators(accountAddress);
address prevValidator = allowedValidators.findPrevious(validatorAddress);

vm.startPrank(accountAddress);
emailRecoveryModule.disallowValidatorRecovery(
validatorAddress, prevValidator, "", functionSelector
);
vm.stopPrank();

allowedValidators = emailRecoveryModule.getAllowedValidators(accountAddress);

assertEq(allowedValidators.length, 0);
}

function test_GetAllowedValidators_SucceedsWithOneValidator() public {
address[] memory allowedValidators =
emailRecoveryModule.getAllowedValidators(accountAddress);

Expand Down
1 change: 0 additions & 1 deletion test/unit/modules/EmailRecoveryModule/onUninstall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity ^0.8.25;
import "forge-std/console2.sol";
import { ModuleKitHelpers } from "modulekit/ModuleKit.sol";
import { MODULE_TYPE_EXECUTOR } from "modulekit/external/ERC7579.sol";
import { SentinelListLib } from "sentinellist/SentinelList.sol";
import { SentinelListHelper } from "sentinellist/SentinelListHelper.sol";
import { UnitBase } from "../../UnitBase.t.sol";

Expand Down

0 comments on commit 11b8e9a

Please sign in to comment.