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