Skip to content

Commit

Permalink
WIP:unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fanhousanbu committed Oct 3, 2024
1 parent 0dad41e commit b96ba11
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 59 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

.deps/
cache/
2 changes: 1 addition & 1 deletion cache/solidity-files-cache.json

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions script/Counter.s.sol

This file was deleted.

5 changes: 4 additions & 1 deletion src/BLSLightAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ contract BLSLightAccount is LightAccount {

/// @dev keccak256(abi.encode(uint256(keccak256("bls_light_account_v1.storage")) - 1)) & ~bytes32(uint256(0xff));
bytes32 private constant _BLS_STORAGE_POSITION = 0x3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e00;
address public _owner;

event BLSPublicKeySet(bytes32 indexed blsPublicKey);

Expand All @@ -39,7 +40,9 @@ contract BLSLightAccount is LightAccount {
/// @param owner_ The initial owner of the account
/// @param blsPublicKey_ The BLS public key for this account
function initialize(address owner_, bytes32 blsPublicKey_) external initializer {
super._initialize(owner_);
// super._initialize(owner_);
require(_owner == address(0), "Already initialized");
_owner = owner_;
_setBlsPublicKey(blsPublicKey_);
}

Expand Down
14 changes: 0 additions & 14 deletions src/Counter.sol

This file was deleted.

33 changes: 33 additions & 0 deletions test/BLSLightAccount.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "forge-std/Test.sol";
import {EntryPoint} from "../lib/light-account/lib/account-abstraction/contracts/core/EntryPoint.sol";
import {BLSLightAccount, IEntryPoint} from "../src/BLSLightAccount.sol";
import {LightAccountFactory} from "../lib/light-account/src/LightAccountFactory.sol";
import {LightAccount} from "../lib/light-account/src/LightAccount.sol";

contract BLSLightAccountTest is Test {
address owner = address(this);
IEntryPoint entryPoint;
LightAccountFactory factory;
bytes32 blsPublicKey = keccak256(bytes("blsPublicKey"));
// BLSLightAccount account;
LightAccount public account;
address public eoaAddress;
uint256 public constant EOA_PRIVATE_KEY = 1;

function setUp() public {
eoaAddress = vm.addr(EOA_PRIVATE_KEY);
entryPoint = new EntryPoint();
factory = new LightAccountFactory(address(this), entryPoint);
account = factory.createAccount(eoaAddress, 1);
}

function testInitialize() public {
assertEq(entryPoint.getNonce(owner, 0), account.getNonce());
assertNotEq(account.owner(), owner);
// account.initialize(owner, blsPublicKey);
// account.setBlsPublicKey(blsPublicKey);
}
}
24 changes: 0 additions & 24 deletions test/Counter.t.sol

This file was deleted.

0 comments on commit b96ba11

Please sign in to comment.