Skip to content

Instantly share code, notes, and snippets.

@vdparikh
Created August 9, 2022 16:55
Show Gist options
  • Save vdparikh/4243312cca90f244042877710b1742bc to your computer and use it in GitHub Desktop.
Save vdparikh/4243312cca90f244042877710b1742bc to your computer and use it in GitHub Desktop.
// 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