forked from WTFAcademy/WTF-CTF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GuessTheNumberChallenge.t.sol
31 lines (22 loc) · 1008 Bytes
/
GuessTheNumberChallenge.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "./GuessTheNumberChallenge.sol";
contract GuessTheNumberChallengeTest is Test {
GuessTheNumberChallenge public guessTheNumberChallenge;
address hacker = makeAddr("hacker");
function setUp() public {
payable(hacker).transfer(1 ether);
guessTheNumberChallenge = new GuessTheNumberChallenge{value: 1 ether}();
}
function testGuessTheNumber() public {
emit log_named_uint("my balance", hacker.balance);
emit log_named_uint("guessTheNumberChallenge's balance", address(guessTheNumberChallenge).balance);
vm.startPrank(hacker);
guessTheNumberChallenge.guess{value: 1 ether}(42);
vm.stopPrank();
emit log_named_uint("my new balance", hacker.balance);
emit log_named_uint("guessTheNumberChallenge's new balance", address(guessTheNumberChallenge).balance);
assertTrue(guessTheNumberChallenge.isComplete());
}
}