Skip to content

Commit 1d9650e

Browse files
feat: invariant target interfaces (#445)
1 parent fac7bd8 commit 1d9650e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/StdInvariant.sol

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ abstract contract StdInvariant {
99
bytes4[] selectors;
1010
}
1111

12+
struct FuzzInterface {
13+
address addr;
14+
string[] artifacts;
15+
}
16+
1217
address[] private _excludedContracts;
1318
address[] private _excludedSenders;
1419
address[] private _targetedContracts;
@@ -20,6 +25,8 @@ abstract contract StdInvariant {
2025
FuzzSelector[] private _targetedArtifactSelectors;
2126
FuzzSelector[] private _targetedSelectors;
2227

28+
FuzzInterface[] private _targetedInterfaces;
29+
2330
// Functions for users:
2431
// These are intended to be called in tests.
2532

@@ -55,6 +62,10 @@ abstract contract StdInvariant {
5562
_targetedSenders.push(newTargetedSender_);
5663
}
5764

65+
function targetInterface(FuzzInterface memory newTargetedInterface_) internal {
66+
_targetedInterfaces.push(newTargetedInterface_);
67+
}
68+
5869
// Functions for forge:
5970
// These are called by forge to run invariant tests and don't need to be called in tests.
6071

@@ -89,4 +100,8 @@ abstract contract StdInvariant {
89100
function targetSenders() public view returns (address[] memory targetedSenders_) {
90101
targetedSenders_ = _targetedSenders;
91102
}
103+
104+
function targetInterfaces() public view returns (FuzzInterface[] memory targetedInterfaces_) {
105+
targetedInterfaces_ = _targetedInterfaces;
106+
}
92107
}

0 commit comments

Comments
 (0)