Skip to content

Support inline configuration in Solidity tests #7355

@michalbrabec

Description

@michalbrabec

Foundry supports inline configuration per Solidity Test file, where the config is set in the comment of the test function:

/// forge-config: default.fuzz.runs = 512
function testEncodeBytesArray(bytes[] memory input) external pure {
    bytes[] memory list = new bytes[](1);
    list[0] = RLP.encode(input);

    assertEq(RLP.encoder().push(input).encode(), RLP.encode(list));
}

See https://www.getfoundry.sh/config/reference/inline-test-config#in-line-test-configuration

Note comments can be either /// or block comments /** ... */.

Support for per test configuration has been included in EDR. Hardhat needs to parse the Solidity test files to find test functions with comments that include inline config.

The first suggestion for an approach is:

  • compile the test contracts
  • read the solc artifacts for the test contracts pulling out the AST
  • find the comment against each test function in each test contract
  • parse each comment and pass any config per test into EDR for Solidity Test

Metadata

Metadata

Assignees

Labels

_priority:P1High prioritytype:KREnd-to-end implementation of a KR

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions