diff --git a/test/gatekeepers/TokenGateKeeper.t.sol b/test/gatekeepers/TokenGateKeeper.t.sol index 7bfaa84a..3c3247c4 100644 --- a/test/gatekeepers/TokenGateKeeper.t.sol +++ b/test/gatekeepers/TokenGateKeeper.t.sol @@ -5,6 +5,7 @@ import { Test } from "../../lib/forge-std/src/Test.sol"; import { console } from "../../lib/forge-std/src/console.sol"; import { DummyERC20 } from "../DummyERC20.sol"; import { DummyERC721 } from "../DummyERC721.sol"; +import { DummyERC1155 } from "../DummyERC1155.sol"; import { TestUtils } from "../TestUtils.sol"; import { TokenGateKeeper } from "../../contracts/gatekeepers/TokenGateKeeper.sol"; import "../../contracts/utils/LibERC20Compat.sol"; @@ -13,8 +14,10 @@ contract TokenGateKeeperTest is Test, TestUtils { TokenGateKeeper gk; uint256 constant MIN_ERC20_BALANCE = 10e18; uint256 constant MIN_ERC721_BALANCE = 1; + uint256 constant MIN_ERC1155_BALANCE = 1; DummyERC20 dummyERC20 = new DummyERC20(); DummyERC721 dummyERC721 = new DummyERC721(); + DummyERC1155 dummyERC1155 = new DummyERC1155(); function setUp() public { gk = new TokenGateKeeper(address(0)); @@ -67,4 +70,25 @@ contract TokenGateKeeperTest is Test, TestUtils { assertFalse(gk.isAllowed(user1, ERC721gateId, "")); assertFalse(gk.isAllowed(user2, ERC20gateId, "")); } + + function test1155Gate() public { + bytes12 ERC1155gateId = gk.createGate(address(dummyERC1155), 1, MIN_ERC1155_BALANCE); + address user = _randomAddress(); + dummyERC1155.deal(user, 1, 1); + assertTrue(gk.isAllowed(user, ERC1155gateId, "")); + } + + function test1155Gate_wrongId() public { + bytes12 ERC1155gateId = gk.createGate(address(dummyERC1155), 1, MIN_ERC1155_BALANCE); + address user = _randomAddress(); + dummyERC1155.deal(user, 2, 1); + assertFalse(gk.isAllowed(user, ERC1155gateId, "")); + } + + function test1155Gate_notEnough() public { + bytes12 ERC1155gateId = gk.createGate(address(dummyERC1155), 1, 3); + address user = _randomAddress(); + dummyERC1155.deal(user, 1, 2); + assertFalse(gk.isAllowed(user, ERC1155gateId, "")); + } }