Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
imduchuyyy committed Jun 22, 2024
1 parent 8646cb3 commit ffe6fa7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
23 changes: 23 additions & 0 deletions test/Wallet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity >=0.8.4;
import "account-abstraction/core/EntryPoint.sol";
import "account-abstraction/interfaces/IEntryPoint.sol";
import "../src/WalletFactory.sol";
import "../src/modules/Passkey.sol";
import "../src/Wallet.sol";
import "./utils/ERC4337Utils.sol";
import "forge-std/Test.sol";
Expand Down Expand Up @@ -46,6 +47,28 @@ contract WalletTest is Test {
entryPoint.handleOps(ops, beneficiary);
}

function testWalletPasskey() external {
bytes32 salt = keccak256("testCreateWalletWithPasskey");
PasskeyModule passkeyModule = walletFactory.createPasskey(
28203248099655634232680422976510411012986437076966613883671554831358983509938,
79473938854726638551736530376995476499049493858003728502280535141260854783821,
salt
);

UserOperation memory op = entryPoint.fillUserOp(address(0), "");
bytes memory signature =
hex"00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001eb6f6689e7b96f60dcae3542888f9d094a9abb8e04bd391104d6ee79a9f0967d3bc293dc51c51b23f9063ae81bb2e4a99b520f5f04cda804f0dd80b4c8d7f353000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22644c4836595a6f78345332616a6f4e4a384c374d47734657436c75584c6258514a62306e466c7377685930222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000";
op.signature = abi.encodePacked(address(passkeyModule), signature);

vm.startPrank(address(entryPoint));

wallet.addKey(address(passkeyModule));
uint256 valid = wallet.validateUserOp(op, 0x74b1fa619a31e12d9a8e8349f0becc1ac1560a5b972db5d025bd27165b30858d, 0);

console.log("valid", valid);

}

function test_SendEth() external {
vm.deal(address(wallet), 1 ether);

Expand Down
15 changes: 10 additions & 5 deletions test/modules/PasskeyModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ import "account-abstraction/core/EntryPoint.sol";
import "../../src/modules/Passkey.sol";
import "../../src/libraries/WebAuthn.sol";
import "../../src/WalletFactory.sol";
import "../utils/ERC4337Utils.sol";
import "forge-std/Test.sol";
import "forge-std/console.sol";

using ERC4337Utils for EntryPoint;

contract PasskeyModuleTest is Test {
EntryPoint entryPoint;
PasskeyModule passkeyModule;
WalletFactory walletFactory;

function setUp() external {
EntryPoint entryPoint = new EntryPoint();
entryPoint = new EntryPoint();
walletFactory = new WalletFactory(address(entryPoint));
}

Expand All @@ -25,14 +29,15 @@ contract PasskeyModuleTest is Test {
function testPassKey() external {
bytes32 salt = keccak256("testCreateWalletWithPasskey");
passkeyModule = walletFactory.createPasskey(
28203248099655634232680422976510411012986437076966613883671554831358983509938,
79473938854726638551736530376995476499049493858003728502280535141260854783821,
0xa60dd7f9d8edc4a6c7e2ad99c360804bb01d3942c7a975da1a33bdb1d136ddab,
0x2c35b9180fd0f24047974c6cfa8992c20a8f60bf9b337644918c2f163dd5deee,
salt
);

bytes memory signature =
hex"00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001eb6f6689e7b96f60dcae3542888f9d094a9abb8e04bd391104d6ee79a9f0967d3bc293dc51c51b23f9063ae81bb2e4a99b520f5f04cda804f0dd80b4c8d7f353000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22644c4836595a6f78345332616a6f4e4a384c374d47734657436c75584c6258514a62306e466c7377685930222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000";
hex"00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000011cf2c8e67f1406348fab3e97670aabd0046c412d46676b639ea590e692011f32e68a1fb29f6060c755d03358f03b1a262672ecd8d609ab279f8c968af20562d1000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22456a736c6d51594d4d5f305976646139502d66313341363066586865585072307534373547665565463449222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000";
bytes4 returnValue = passkeyModule.isValidSignature(
0x74b1fa619a31e12d9a8e8349f0becc1ac1560a5b972db5d025bd27165b30858d, signature
0x123b2599060c33fd18bdd6bd3fe7f5dc0eb47d785e5cfaf4bb8ef919f51e1782, signature
);

require(returnValue == passkeyModule.isValidSignature.selector, "signature should be valid");
Expand Down

0 comments on commit ffe6fa7

Please sign in to comment.