forked from WTFAcademy/WTF-CTF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NicknameChallenge.t.sol
36 lines (29 loc) · 1.1 KB
/
NicknameChallenge.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: MIT
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "./NicknameChallenge.sol";
contract NicknameChallengeTest is Test {
CaptureTheEther public captureTheEther;
NicknameChallenge public nicknameChallenge;
address hacker = makeAddr("hacker");
function setUp() public {
captureTheEther = new CaptureTheEther();
vm.startPrank(address(captureTheEther));
nicknameChallenge = new NicknameChallenge(hacker);
vm.stopPrank();
}
function testNickname() public {
emit log_named_string(
"before change the name, the isComplete's value", nicknameChallenge.isComplete() ? "true" : "false"
);
assertFalse(nicknameChallenge.isComplete());
vm.startPrank(hacker);
// set my name to UINT256_MAX
captureTheEther.setNickname(bytes32(UINT256_MAX));
vm.stopPrank();
emit log_named_string(
"after change the name, the isComplete's value", nicknameChallenge.isComplete() ? "true" : "false"
);
assertTrue(nicknameChallenge.isComplete());
}
}