generated from PaulRBerg/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add SimplePlusAccountFactory test suite
- Loading branch information
1 parent
05c05d1
commit 21a95bd
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.23; | ||
|
||
import { Test } from "forge-std/src/Test.sol"; | ||
|
||
import { EntryPoint } from "@account-abstraction/contracts/core/EntryPoint.sol"; | ||
|
||
import { SimplePlusAccount } from "../src/SimplePlusAccount.sol"; | ||
import { SimplePlusAccountFactory } from "../src/SimplePlusAccountFactory.sol"; | ||
|
||
contract SimplePlusAccountFactoryTest is Test { | ||
address public constant OWNER_ADDRESS = address(0x100); | ||
SimplePlusAccountFactory public factory; | ||
EntryPoint public entryPoint; | ||
|
||
function setUp() public { | ||
entryPoint = new EntryPoint(); | ||
factory = new SimplePlusAccountFactory(entryPoint); | ||
} | ||
|
||
function testReturnsAddressWhenAccountAlreadyExists() public { | ||
SimplePlusAccount account = factory.createAccount(OWNER_ADDRESS, 1); | ||
SimplePlusAccount otherAccount = factory.createAccount(OWNER_ADDRESS, 1); | ||
assertEq(address(account), address(otherAccount)); | ||
} | ||
|
||
function testGetAddress() public { | ||
address counterfactual = factory.getAddress(OWNER_ADDRESS, 1); | ||
assertEq(counterfactual.codehash, bytes32(0)); | ||
SimplePlusAccount factual = factory.createAccount(OWNER_ADDRESS, 1); | ||
assertTrue(address(factual).codehash != bytes32(0)); | ||
assertEq(counterfactual, address(factual)); | ||
} | ||
|
||
/// @dev Receive funds from withdraw. | ||
receive() external payable { } | ||
} |