-
Notifications
You must be signed in to change notification settings - Fork 115
/
coinflip.sol
32 lines (26 loc) · 929 Bytes
/
coinflip.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 "forge-std/console.sol";
import "Ethernaut/coinflip_poc.sol";
contract CoinFlipTest is Test {
CoinFlip coinFlip;
CoinFlipPOC coinFlipPoc;
function setUp() public {
coinFlip = new CoinFlip();
coinFlipPoc = new CoinFlipPOC(address(coinFlip));
}
function test_ConsecutiveWinFlips() public {
while (coinFlip.consecutiveWins() < 10) {
vm.roll(block.number + 1);
// coinFlipPoc.flip();
try coinFlipPoc.flip() returns (bool result) {
console.log("flip result is", result);
} catch Error(string memory reason) {
console.log("flip failed with reason:", reason);
break;
}
}
assertEq(coinFlip.consecutiveWins(), 10, "Consecutive wins should be 10");
}
}