forked from WTFAcademy/WTF-CTF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGatekeeperTwo.t.sol
36 lines (26 loc) · 944 Bytes
/
GatekeeperTwo.t.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "forge-std/Test.sol";
import "./GatekeeperTwoFactory.sol";
contract GatekeeperOneTest is Test {
GatekeeperTwoFactory factory;
function setUp() public {
factory = new GatekeeperTwoFactory();
}
function testGatekeeperTwo() public {
address player = vm.addr(uint256(keccak256("player")));
vm.startPrank(address(this), player);
{
address gatekeeperTwo = factory.createInstance(player);
new GatebreakerTwo(gatekeeperTwo);
assertTrue(factory.validateInstance(payable(address(gatekeeperTwo)), player));
}
vm.stopPrank();
}
}
contract GatebreakerTwo {
constructor(address gatekeeperTwo) {
uint64 _gateKey = type(uint64).max ^ uint64(bytes8(keccak256(abi.encodePacked(address(this)))));
GatekeeperTwo(gatekeeperTwo).enter(bytes8(_gateKey));
}
}