Created
August 9, 2022 16:55
-
-
Save vdparikh/4243312cca90f244042877710b1742bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.13; | |
import "forge-std/Test.sol"; | |
contract InvariantBreaker { | |
bool public flag0 = true; | |
bool public flag1 = true; | |
function set0(int val) public returns (bool){ | |
if (val % 100 == 0) | |
flag0 = false; | |
return flag0; | |
} | |
function set1(int val) public returns (bool){ | |
if (val % 10 == 0 && !flag0) | |
flag1 = false; | |
return flag1; | |
} | |
} | |
contract InvariantTest is Test { | |
InvariantBreaker inv; | |
function setUp() public { | |
inv = new InvariantBreaker(); | |
} | |
function invariant_neverFalse() public { | |
require(inv.flag1()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment