Skip to content

Commit

Permalink
chore(invariant) - rename TargetAbiSelector (#7850)
Browse files Browse the repository at this point in the history
* chore(invariant) - rename TargetAbiSelector

* Rename contract_abi to artifact
  • Loading branch information
grandizzy authored May 4, 2024
1 parent d65c65f commit aa333c6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
10 changes: 5 additions & 5 deletions crates/evm/evm/src/executors/invariant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ sol! {
}

#[derive(Default)]
struct FuzzAbiSelector {
string contract_abi;
struct FuzzArtifactSelector {
string artifact;
bytes4[] selectors;
}

Expand All @@ -77,7 +77,7 @@ sol! {
function targetArtifacts() public view returns (string[] memory targetedArtifacts);

#[derive(Default)]
function targetArtifactSelectors() public view returns (FuzzAbiSelector[] memory targetedArtifactSelectors);
function targetArtifactSelectors() public view returns (FuzzArtifactSelector[] memory targetedArtifactSelectors);

#[derive(Default)]
function targetContracts() public view returns (address[] memory targetedContracts);
Expand Down Expand Up @@ -400,10 +400,10 @@ impl<'a> InvariantExecutor<'a> {
.call_sol_default(invariant_address, &IInvariantTest::targetArtifactSelectorsCall {});

// Insert them into the executor `targeted_abi`.
for IInvariantTest::FuzzAbiSelector { contract_abi, selectors } in
for IInvariantTest::FuzzArtifactSelector { artifact, selectors } in
result.targetedArtifactSelectors
{
let identifier = self.validate_selected_contract(contract_abi, &selectors)?;
let identifier = self.validate_selected_contract(artifact, &selectors)?;
self.artifact_filters.targeted.entry(identifier).or_default().extend(selectors);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity 0.8.18;

import "ds-test/test.sol";

struct FuzzAbiSelector {
string contract_abi;
struct FuzzArtifactSelector {
string artifact;
bytes4[] selectors;
}

Expand All @@ -27,11 +27,12 @@ contract TargetArtifactSelectors is DSTest {
hello = new Hi();
}

function targetArtifactSelectors() public returns (FuzzAbiSelector[] memory) {
FuzzAbiSelector[] memory targets = new FuzzAbiSelector[](1);
function targetArtifactSelectors() public returns (FuzzArtifactSelector[] memory) {
FuzzArtifactSelector[] memory targets = new FuzzArtifactSelector[](1);
bytes4[] memory selectors = new bytes4[](1);
selectors[0] = Hi.no_change.selector;
targets[0] = FuzzAbiSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol:Hi", selectors);
targets[0] =
FuzzArtifactSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors.t.sol:Hi", selectors);
return targets;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity 0.8.18;

import "ds-test/test.sol";

struct FuzzAbiSelector {
string contract_abi;
struct FuzzArtifactSelector {
string artifact;
bytes4[] selectors;
}

Expand Down Expand Up @@ -46,18 +46,20 @@ contract TargetArtifactSelectors2 is DSTest {
parent = new Parent();
}

function targetArtifactSelectors() public returns (FuzzAbiSelector[] memory) {
FuzzAbiSelector[] memory targets = new FuzzAbiSelector[](2);
function targetArtifactSelectors() public returns (FuzzArtifactSelector[] memory) {
FuzzArtifactSelector[] memory targets = new FuzzArtifactSelector[](2);
bytes4[] memory selectors_child = new bytes4[](1);

selectors_child[0] = Child.change_parent.selector;
targets[0] =
FuzzAbiSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Child", selectors_child);
targets[0] = FuzzArtifactSelector(
"default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Child", selectors_child
);

bytes4[] memory selectors_parent = new bytes4[](1);
selectors_parent[0] = Parent.create.selector;
targets[1] =
FuzzAbiSelector("default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Parent", selectors_parent);
targets[1] = FuzzArtifactSelector(
"default/fuzz/invariant/targetAbi/TargetArtifactSelectors2.t.sol:Parent", selectors_parent
);
return targets;
}

Expand Down

0 comments on commit aa333c6

Please sign in to comment.