Skip to content

Commit

Permalink
feat: invariant target interfaces (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard-wagner authored Aug 31, 2023
1 parent fac7bd8 commit 1d9650e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/StdInvariant.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ abstract contract StdInvariant {
bytes4[] selectors;
}

struct FuzzInterface {
address addr;
string[] artifacts;
}

address[] private _excludedContracts;
address[] private _excludedSenders;
address[] private _targetedContracts;
Expand All @@ -20,6 +25,8 @@ abstract contract StdInvariant {
FuzzSelector[] private _targetedArtifactSelectors;
FuzzSelector[] private _targetedSelectors;

FuzzInterface[] private _targetedInterfaces;

// Functions for users:
// These are intended to be called in tests.

Expand Down Expand Up @@ -55,6 +62,10 @@ abstract contract StdInvariant {
_targetedSenders.push(newTargetedSender_);
}

function targetInterface(FuzzInterface memory newTargetedInterface_) internal {
_targetedInterfaces.push(newTargetedInterface_);
}

// Functions for forge:
// These are called by forge to run invariant tests and don't need to be called in tests.

Expand Down Expand Up @@ -89,4 +100,8 @@ abstract contract StdInvariant {
function targetSenders() public view returns (address[] memory targetedSenders_) {
targetedSenders_ = _targetedSenders;
}

function targetInterfaces() public view returns (FuzzInterface[] memory targetedInterfaces_) {
targetedInterfaces_ = _targetedInterfaces;
}
}

0 comments on commit 1d9650e

Please sign in to comment.