Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cheatcode variants that allow introduction of custom K variable names. #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/IKontrolCheatsBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ interface KontrolCheatsBase {
function expectCreate2(address,uint256,bytes calldata) external;
// Makes the storage of the given address completely symbolic.
function symbolicStorage(address) external;
// Makes the storage of the given address completely symbolic with specified K variable name.
function symbolicStorage(address, string calldata) external;
// From now on, whenever a call is made to callee with calldata data, instead call calledContract with the same calldata.
function mockFunction(address callee, address calledContract, bytes calldata data) external;
// Adds an address to the whitelist.
Expand All @@ -31,10 +33,18 @@ interface KontrolCheatsBase {
function setGas(uint256) external;
// Returns a symbolic unsigned integer
function freshUInt(uint8) external returns (uint256);
// Returns a symbolic unsigned integer with specified K variable name.
function freshUInt(uint8, string calldata) external returns (uint256);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it make sense to add a similar variant for cheatcodes generating a fresh uint of a specific size, such as this one?

function freshUInt256() internal returns (uint256) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I added these now. However I found I had to make the string arguments for those memory as opposed to calldata. I was wondering, should these all be memory type, including the ones in IKontrolCheatsBase.sol?

// Returns a symbolic boolean value
function freshBool() external returns (uint256);
// Returns a symbolic boolean value with specified K variable name.
function freshBool(string calldata) external returns (uint256);
// Returns a symbolic byte array
function freshBytes(uint256) external returns (bytes memory);
// Returns a symbolic byte array with specified K variable name.
function freshBytes(uint256, string calldata) external returns (bytes memory);
// Returns a symbolic address
function freshAddress() external returns (address);
// Returns a symbolic address with specified K variable name.
function freshAddress(string calldata) external returns (address);
}