Skip to content

Commit

Permalink
Feat/fix test allow validator recovery (#44)
Browse files Browse the repository at this point in the history
* Fix test cases in allow validator recovery.

* Add mockCall for isModuleInstalled function.
  • Loading branch information
wshino authored Sep 8, 2024
1 parent 630baae commit 3d39050
Showing 1 changed file with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
contract UniversalEmailRecoveryModule_allowValidatorRecovery_Test is UnitBase {
using ModuleKitHelpers for *;

address validator2Address;

function setUp() public override {
super.setUp();
// Deploy new validator, it's not installed via installModule function.
OwnableValidator validator2 = new OwnableValidator();
validator2Address = address(validator2);
}

function test_AllowValidatorRecovery_RevertWhen_RecoveryModuleNotInitialized() public {
Expand All @@ -32,32 +37,52 @@ contract UniversalEmailRecoveryModule_allowValidatorRecovery_Test is UnitBase {
function test_AllowValidatorRecovery_When_SafeAddOwnerSelector() public {
_skipIfNotSafeAccountType();
vm.startPrank(accountAddress);
vm.mockCall(
address(accountAddress),
abi.encodeWithSelector(IERC7579Account.isModuleInstalled.selector),
abi.encode(true)
);
emailRecoveryModule.allowValidatorRecovery(
validatorAddress, bytes("0"), ISafe.addOwnerWithThreshold.selector
validator2Address, bytes("0"), ISafe.addOwnerWithThreshold.selector
);
}

function test_AllowValidatorRecovery_When_SafeRemoveOwnerSelector() public {
_skipIfNotSafeAccountType();
vm.startPrank(accountAddress);
vm.mockCall(
address(accountAddress),
abi.encodeWithSelector(IERC7579Account.isModuleInstalled.selector),
abi.encode(true)
);
emailRecoveryModule.allowValidatorRecovery(
validatorAddress, bytes("0"), ISafe.removeOwner.selector
validator2Address, bytes("0"), ISafe.removeOwner.selector
);
}

function test_AllowValidatorRecovery_When_SafeSwapOwnerSelector() public {
_skipIfNotSafeAccountType();
vm.startPrank(accountAddress);
vm.mockCall(
address(accountAddress),
abi.encodeWithSelector(IERC7579Account.isModuleInstalled.selector),
abi.encode(true)
);
emailRecoveryModule.allowValidatorRecovery(
validatorAddress, bytes("0"), ISafe.swapOwner.selector
validator2Address, bytes("0"), ISafe.swapOwner.selector
);
}

function test_AllowValidatorRecovery_When_SafeChangeThresholdSelector() public {
_skipIfNotSafeAccountType();
vm.startPrank(accountAddress);
vm.mockCall(
address(accountAddress),
abi.encodeWithSelector(IERC7579Account.isModuleInstalled.selector),
abi.encode(true)
);
emailRecoveryModule.allowValidatorRecovery(
validatorAddress, bytes("0"), ISafe.changeThreshold.selector
validator2Address, bytes("0"), ISafe.changeThreshold.selector
);
}

Expand Down

0 comments on commit 3d39050

Please sign in to comment.