basic tests for the gatekeeper added
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
162b3e357a
commit
2a012ef8e2
57
test/gatekeeper/Gatekeeper.t.sol
Normal file
57
test/gatekeeper/Gatekeeper.t.sol
Normal file
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user