Skip to content

Commit

Permalink
test(docs): Add documentation for transferOwnership and IsValidSignature
Browse files Browse the repository at this point in the history
  • Loading branch information
jpgonzalezra committed May 18, 2024
1 parent 9e6a4b2 commit 4095bee
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/SimplePlusAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ contract SimplePlusAccountTest is AccountTest {
vm.deal(address(account), 1 << 128);
}

/**
* transferOwnership test cases
*/
function testOwnerCanTransferOwnership() public {
_transferOwnership(eoaAddress, address(0x100));
}
Expand Down Expand Up @@ -82,6 +85,18 @@ contract SimplePlusAccountTest is AccountTest {
account.transferOwnership(address(account));
}

/**
* IsValidSignature test cases
*/
function testIsValidSignatureForEoaOwner() public view {
bytes32 message = keccak256("simple_plus_account");
bytes memory signature = abi.encodePacked(
SimplePlusAccount.SignatureType.EOA,
sign(EOA_PRIVATE_KEY, getMessageHash(address(account), abi.encode(message)))
);
assertEq(account.isValidSignature(message, signature), bytes4(keccak256("isValidSignature(bytes32,bytes)")));
}

function _transferOwnership(address currentOwner, address newOwner) internal {
vm.prank(currentOwner);
vm.expectEmit(true, true, false, false);
Expand All @@ -97,4 +112,4 @@ contract SimplePlusAccountTest is AccountTest {
emit OwnershipTransferred(eoaAddress, address(0x100));
entryPoint.handleOps(ops, BENEFICIARY);
}
}
}

0 comments on commit 4095bee

Please sign in to comment.