pragma solidity 0.8.20; import {Test} from "forge-std/Test.sol"; import "../../src/Gatekeeper.sol"; contract GatekeeperTest is Test { address constant alice = 0x0000000000000000000000000000000000000001; address constant bob = 0x0000000000000000000000000000000000000002; uint256 constant initAmount = 69 * 1e18; Gatekeeper gatekeeper; event Ghosted(bytes32 indexed receiver, uint256 indexed amount); function setUp() public { gatekeeper = new Gatekeeper(alice, 0); } function test_correctInitialization() public { assertEq(gatekeeper.staking(), alice); assertEq(gatekeeper.ghostedSupply(), 0); Gatekeeper anotherGatekeeper = new Gatekeeper(bob, initAmount); assertEq(anotherGatekeeper.staking(), bob); assertEq(anotherGatekeeper.ghostedSupply(), initAmount); } function test_ghostTokensWork(uint256 ghostAmount) public { vm.assume(ghostAmount > 0); bytes32 receiver = bytes32(abi.encodePacked(alice)); uint256 ghostedSupply = gatekeeper.ghostedSupply(); vm.prank(alice); gatekeeper.ghost(receiver, ghostAmount); assertEq(gatekeeper.ghostedSupply(), ghostedSupply + ghostAmount); } function test_couldNotGhostTokensFromArbitraryAddress(address someone) public { vm.assume(someone != alice); bytes32 receiver = bytes32(abi.encodePacked(alice)); vm.expectRevert(); vm.prank(someone); gatekeeper.ghost(receiver, 69); assertEq(gatekeeper.ghostedSupply(), 0); } function test_ghostTokensEmitsEvent(uint256 ghostAmount) public { vm.assume(ghostAmount > 0); bytes32 receiver = bytes32(abi.encodePacked(alice)); vm.expectEmit(true, true, true, false, address(gatekeeper)); emit Ghosted(receiver, ghostAmount); vm.prank(alice); gatekeeper.ghost(receiver, ghostAmount); } function test_materializeWork(uint256 ghostAmount) public { vm.expectRevert(); gatekeeper.materialize(alice, ghostAmount, 0, 0); } function test_rotateWork(uint256 aggregatedPublicKey) public { vm.expectRevert(); gatekeeper.rotate(aggregatedPublicKey, 0, 0); } }