-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathTargetFunctions.sol
More file actions
54 lines (45 loc) · 1.71 KB
/
Copy pathTargetFunctions.sol
File metadata and controls
54 lines (45 loc) · 1.71 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
// SPDX-License-Identifier: GPL-2.0
pragma solidity ^0.8.0;
// Chimera deps
import {vm} from "@chimera/Hevm.sol";
// Helpers
import {Panic} from "@recon/Panic.sol";
// Targets
// NOTE: Always import and apply them in alphabetical order, so much easier to debug!
import {AdminTargets} from "./targets/AdminTargets.sol";
import {DoomsdayTargets} from "./targets/DoomsdayTargets.sol";
import {ManagersTargets} from "./targets/ManagersTargets.sol";
abstract contract TargetFunctions is
AdminTargets,
DoomsdayTargets,
ManagersTargets
{
function counter_increment() public updateGhosts asActor {
counter.increment();
}
function counter_setNumber1(uint256 newNumber) public updateGhosts asActor {
// example assertion test replicating testFuzz_SetNumber
try counter.setNumber(newNumber) {
if (newNumber != 0) {
t(counter.number() == newNumber, "number != newNumber");
}
} catch (bytes memory err) {
bool expectedError;
// checks for custom errors and panics
expectedError =
checkError(err, "abc") || // error string from require statement
checkError(err, "CustomError()") || // custom error
checkError(err, Panic.arithmeticPanic); // compiler panic errors
t(expectedError, "unexpected error");
}
}
function counter_setNumber2(uint256 newNumber) public asActor {
// same example assertion test as counter_setNumber1 using ghost variables
__before();
counter.setNumber(newNumber);
__after();
if (newNumber != 0) {
t(_after.counter_number == newNumber, "number != newNumber");
}
}
}