Skip to content

Conversation

@lucas-manuel
Copy link
Contributor

Incorporating feedback from #261

@gakonst gakonst merged commit 53331f4 into foundry-rs:master Jan 3, 2023
Copy link
Collaborator

@mds1 mds1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Collaborator

@mds1 mds1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more thoughts that came to mind

Comment on lines 14 to 22
address[] private _targetedContracts;
address[] private _targetedSenders;

string[] private _excludedArtifacts;
string[] private _targetedArtifacts;

FuzzSelector[] internal _targetedArtifactSelectors;
FuzzSelector[] internal _targetedSelectors;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these vars are private and others are internal. Is there a reason for this difference? Wondering which we should prefer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call out, I don't really see any advantage to private, what do you think? Who know someone might want access to these values in the inherited contracts.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think I lean towards keeping it private until someone has a use case for needing access to the array directly, just a bit safer / more clear API that way since you can't accidentally overwrite it / directly set it

Comment on lines +50 to +52
function targetArtifact(string memory newTargetedArtifact_) internal {
_targetedArtifacts.push(newTargetedArtifact_);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshieDo do all of these methods dedupe the arrays in forge or should we check for duplicates when adding to the array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they're deduped yeah.... but to be honest if we're talking about targetArtifactSelector they might be getting replaced instead of appended for the same artifact. i'll have to check it out.

}

function targetArtifacts() public view returns (string[] memory targetedArtifacts_) {
require(_targetedArtifacts.length != uint256(0), "NO_TARGETED_ARTIFACTS");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come the artifact handlers have require statements to ensure non-zero length but others don't? Feels like they should be consistent. Maybe a @joshieDo question

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik there's no need for that

Comment on lines +59 to +66
function targetArtifactSelector(FuzzSelector memory newTargetedArtifactSelector_) internal {
_targetedArtifactSelectors.push(newTargetedArtifactSelector_);
}

function targetArtifactSelectors() public view returns (FuzzSelector[] memory targetedArtifactSelectors_) {
require(targetedArtifactSelectors_.length != uint256(0), "NO_TARGETED_ARTIFACT_SELECTORS");
targetedArtifactSelectors_ = _targetedArtifactSelectors;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two UX improvement suggestions, lmk what you think:

  1. Re-ordering the contract so the methods user's are intended to call (e.g. targetContract) are at the top, and ones forge calls (e.g. targetContracts, plural), are at the bottom. Maybe with some comments indicating this difference, to make it easier to learn how to use this file
  2. Renaming targetContract to addTargetContract so it's more clear and descriptive

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with both of these.

I remember asking about updating the naming conventions here a few months ago. I agree that its confusing that targetContract adds a target contract and targetContracts returns all targetedContracts.

I'm good with addTargetContract naming convention. Will make that change if people agree with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to do 1) but hesitated because I didn't know which section label convention to use 😆 I'll use whichever you guys like.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to do 1) but hesitated because I didn't know which section label convention to use 😆 I'll use whichever you guys like.

Heh, what about something like this:

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

// Functions for forge: These are called by forge to run invariant tests. You
// do not need to use these or worry about them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants