diff --git a/test/CoinbaseSmartWalletFactory.t.sol b/test/CoinbaseSmartWalletFactory.t.sol index 54f3514..693a5f1 100644 --- a/test/CoinbaseSmartWalletFactory.t.sol +++ b/test/CoinbaseSmartWalletFactory.t.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.0; import {Test, console2} from "forge-std/Test.sol"; -import {CoinbaseSmartWallet} from "../src/CoinbaseSmartWallet.sol"; +import {CoinbaseSmartWallet, MultiOwnable} from "../src/CoinbaseSmartWallet.sol"; import {CoinbaseSmartWalletFactory} from "../src/CoinbaseSmartWalletFactory.sol"; +import {LibClone} from "solady/utils/LibClone.sol"; contract CoinbaseSmartWalletFactoryTest is Test { CoinbaseSmartWalletFactory factory; @@ -32,6 +33,20 @@ contract CoinbaseSmartWalletFactoryTest is Test { factory.createAccount{value: 1e18}(owners, 0); } + function test_exitIfAccountIsAlreadyInitialized() public { + CoinbaseSmartWallet a = factory.createAccount(owners, 0); + vm.expectCall(address(a), abi.encodeCall(CoinbaseSmartWallet.initialize, (owners)), 0); + CoinbaseSmartWallet a2 = factory.createAccount(owners, 0); + assertEq(address(a), address(a2)); + } + + function test_RevertsIfLength32ButLargerThanAddress() public { + bytes memory badOwner = abi.encode(uint256(type(uint160).max) + 1); + owners.push(badOwner); + vm.expectRevert(abi.encodeWithSelector(MultiOwnable.InvalidEthereumAddressOwner.selector, badOwner)); + factory.createAccount{value: 1e18}(owners, 0); + } + function test_createAccountDeploysToPredeterminedAddress() public { address p = factory.getAddress(owners, 0); CoinbaseSmartWallet a = factory.createAccount{value: 1e18}(owners, 0); @@ -55,4 +70,10 @@ contract CoinbaseSmartWalletFactoryTest is Test { function test_implementation_returnsExpectedAddress() public { assertEq(factory.implementation(), address(account)); } + + function test_initCodeHash() public { + bytes32 execptedHash = LibClone.initCodeHashERC1967(address(account)); + bytes32 factoryHash = factory.initCodeHash(); + assertEq(factoryHash, execptedHash); + } } diff --git a/test/ERC1271.t.sol b/test/ERC1271.t.sol index e457eaf..1a4dda5 100644 --- a/test/ERC1271.t.sol +++ b/test/ERC1271.t.sol @@ -21,9 +21,18 @@ contract ERC1271Test is Test { } function test_returnsExpectedDomainHashWhenProxy() public { - (, string memory name, string memory version, uint256 chainId, address verifyingContract,,) = - account.eip712Domain(); + ( + , + string memory name, + string memory version, + uint256 chainId, + address verifyingContract, + bytes32 salt, + uint256[] memory extensions + ) = account.eip712Domain(); assertEq(verifyingContract, address(account)); + assertEq(abi.encode(extensions), abi.encode(new uint256[](0))); + assertEq(salt, bytes32(0)); bytes32 expected = keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),