diff --git a/test/gatekeeper/Gatekeeper.t.sol b/test/gatekeeper/Gatekeeper.t.sol new file mode 100644 index 0000000..0e392cf --- /dev/null +++ b/test/gatekeeper/Gatekeeper.t.sol @@ -0,0 +1,57 @@ +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_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); + } +}