-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathcrytic_complex_example.sol
More file actions
57 lines (47 loc) · 1.26 KB
/
crytic_complex_example.sol
File metadata and controls
57 lines (47 loc) · 1.26 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// adapted from https://github.com/crytic/building-secure-contracts/blob/f6fa9ee43409db911341cdc15658f20edb8f915e/program-analysis/echidna/filtering-functions.md
contract CryticComplexExample {
bool state1 = false;
bool state2 = false;
bool state3 = false;
bool state4 = false;
function f(uint256 x) public payable {
require(x == 12);
state1 = true;
}
function g(uint256 x) public payable {
require(state1);
require(x == 8);
state2 = true;
}
function h(uint256 x) public payable {
require(state2);
require(x == 42);
state3 = true;
}
function i() public payable {
require(state3);
state4 = true;
}
function reset1() public {
state1 = false;
state2 = false;
state3 = false;
return;
}
function reset2() public {
state1 = false;
state2 = false;
state3 = false;
return;
}
function echidna_state4() public view returns (bool) {
return (!state4);
}
function selfdestruct_oracle() public payable {
// allows efcf to discover the path
if (state4) {
selfdestruct(msg.sender);
}
}
function deposit() public payable {}
}