Skip to content

Commit

Permalink
feat: Add tests for updating guardian in SimplePlusAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
jpgonzalezra committed May 20, 2024
1 parent b8e2cbd commit 22b76d9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/SimplePlusAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,40 @@ contract SimplePlusAccountTest is AccountTest {
account.recoverAccount(address(0x101), nonce, signature);
}

function testOwnerCanUpdateGuardian() public {
vm.prank(eoaAddress);

address newGuardian = address(0x200);

vm.expectEmit(true, true, false, false);
emit GuardianUpdated(guardianAddress, newGuardian);
account.updateGuardian(newGuardian);
assertEq(account.guardian(), newGuardian);
}

function testNonOwnerCannotUpdateGuardian() public {
vm.prank(address(0x300));
vm.expectRevert(abi.encodeWithSelector(SimplePlusAccount.NotAuthorized.selector));
account.updateGuardian(address(0x200));
}

function testUpdateGuardianToInvalidAddress() public {
vm.prank(eoaAddress);

address invalidGuardian = address(0);
vm.expectRevert(abi.encodeWithSelector(SimpleGuardianModule.InvalidGuardian.selector, address(0)));

account.updateGuardian(invalidGuardian);
}

function testGuardianCannotUpdateGuardian() public {
vm.prank(guardianAddress);

address newGuardian = address(0x200);
vm.expectRevert(abi.encodeWithSelector(SimplePlusAccount.NotAuthorized.selector));
account.updateGuardian(newGuardian);
}

function _transferOwnership(address currentOwner, address newOwner) internal {
vm.prank(currentOwner);
vm.expectEmit(true, true, false, false);
Expand Down

0 comments on commit 22b76d9

Please sign in to comment.