Skip to content

Commit

Permalink
fewer fuzz runs
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Sep 12, 2024
1 parent e595b15 commit b5df403
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ contract RainterpreterReferenceExternNPE2IntIncTest is OpTest {
}

/// Directly test the subparsing of the reference extern opcode.
/// forge-config: default.fuzz.runs = 100
function testRainterpreterReferenceExternNPE2IntIncSubParseKnownWord(uint16 constantsHeight, bytes1 ioByte)
external
{
Expand Down Expand Up @@ -107,6 +108,7 @@ contract RainterpreterReferenceExternNPE2IntIncTest is OpTest {
/// Directly test the subparsing of the reference extern opcode. Check that
/// we get a false for success if the subparser doesn't recognize the word
/// but the data is otherwise valid.
/// forge-config: default.fuzz.runs = 100
function testRainterpreterReferenceExternNPE2IntIncSubParseUnknownWord(
uint16 constantsHeight,
bytes1 ioByte,
Expand All @@ -129,6 +131,7 @@ contract RainterpreterReferenceExternNPE2IntIncTest is OpTest {

/// Test the inc library directly. The run function should increment every
/// value it is passed by 1.
/// forge-config: default.fuzz.runs = 100
function testRainterpreterReferenceExternNPE2IntIncRun(Operand operand, uint256[] memory inputs) external pure {
uint256[] memory expectedOutputs = new uint256[](inputs.length);
for (uint256 i = 0; i < inputs.length; i++) {
Expand All @@ -147,6 +150,7 @@ contract RainterpreterReferenceExternNPE2IntIncTest is OpTest {

/// Test the inc library directly. The integrity function should return the
/// same inputs and outputs.
/// forge-config: default.fuzz.runs = 100
function testRainterpreterReferenceExternNPE2IntIncIntegrity(Operand operand, uint256 inputs, uint256 outputs)
external
pure
Expand Down
7 changes: 5 additions & 2 deletions test/src/concrete/RainterpreterStoreNPE2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ contract RainterpreterStoreNPE2Test is Test {

/// Ensure the store gives a decent error message when an odd number of
/// arguments is passed to `set`.
/// forge-config: default.fuzz.runs = 100
function testRainterpreterStoreNPE2SetOddLength(StateNamespace namespace, uint256[] memory kvs) external {
vm.assume(kvs.length % 2 != 0);

Expand All @@ -45,6 +46,7 @@ contract RainterpreterStoreNPE2Test is Test {

/// Store should set and get values correctly.
/// This test assumes no dupes.
/// forge-config: default.fuzz.runs = 100
function testRainterpreterStoreNPE2SetGetNoDupesSingle(StateNamespace namespace, uint256[] memory kvs) external {
// Truncate to even length.
uint256 newLength = kvs.length - (kvs.length % 2);
Expand All @@ -71,7 +73,8 @@ contract RainterpreterStoreNPE2Test is Test {
uint256[] kvs;
}

/// Store should get and set values correctly across many namespaces.
/// Store should get and set values correctly across many namespaces.j
/// forge-config: default.fuzz.runs = 100
function testRainterpreterStoreNPE2SetGetNoDupesMany(Set[] memory sets) external {
uint256 setsLength = sets.length >= 10 ? 10 : sets.length;
uint256[] memory refs;
Expand Down Expand Up @@ -115,7 +118,7 @@ contract RainterpreterStoreNPE2Test is Test {
/// previous writes to the same key (i.e. like a k/v store). The assumption
/// is that the fuzzer will generate some dupes just randomly, so there's
/// no special logic to make that happen.

/// forge-config: default.fuzz.runs = 100
function testRainterpreterStoreNPE2SetGetDupes(Set11[] memory sets) external {
vm.assume(sets.length < 20);

Expand Down
1 change: 1 addition & 0 deletions test/src/lib/op/00/LibOpStackNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ contract LibOpStackNPTest is OpTest {

/// Directly test the runtime logic of LibOpStackNP. This tests that the
/// operand always puts a single value on the stack.
/// forge-config: default.fuzz.runs = 100
function testOpStackNPRun(uint256[][] memory stacks, uint256 stackIndex) external view {
InterpreterStateNP memory state = opTestDefaultInterpreterState();
uint256 stackValue;
Expand Down
3 changes: 3 additions & 0 deletions test/src/lib/op/bitwise/LibOpShiftBitsRightNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ contract LibOpShiftBitsRightNPTest is OpTest {
/// Directly test the integrity logic of LibOpShiftBitsRightNP. Tests the
/// happy path where the integrity check does not error due to an unsupported
/// shift amount.
/// forge-config: default.fuzz.runs = 100
function testOpShiftBitsRightNPIntegrityHappy(
IntegrityCheckStateNP memory state,
uint8 inputs,
Expand All @@ -40,6 +41,7 @@ contract LibOpShiftBitsRightNPTest is OpTest {
/// Directly test the execution logic of LibOpShiftBitsRightNP. Tests that
/// any shift amount that always results in an output of 0 will error as
/// an unsupported shift amount.
/// forge-config: default.fuzz.runs = 100
function testOpShiftBitsRightNPIntegrityZero(IntegrityCheckStateNP memory state, uint8 inputs, uint16 shiftAmount16)
external
{
Expand All @@ -53,6 +55,7 @@ contract LibOpShiftBitsRightNPTest is OpTest {
/// Directly test the execution logic of LibOpShiftBitsRightNP. Tests that
/// any shift amount that is a noop (0) will error as an unsupported shift
/// amount.
/// forge-config: default.fuzz.runs = 100
function testOpShiftBitsRightNPIntegrityNoop(IntegrityCheckStateNP memory state, uint8 inputs) external {
Operand operand = Operand.wrap(uint256(inputs) << 0x10);
vm.expectRevert(abi.encodeWithSelector(UnsupportedBitwiseShiftAmount.selector, 0));
Expand Down
5 changes: 5 additions & 0 deletions test/src/lib/parse/LibParse.literalString.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ contract LibParseLiteralStringTest is Test {

/// Any ASCII printable string shorter than 32 bytes should be parsed
/// correctly.
/// forge-config: default.fuzz.runs = 100
function testParseStringLiteralShortASCII(string memory str) external view {
vm.assume(bytes(str).length < 0x20);
LibLiteralString.conformValidPrintableStringContent(str);
Expand All @@ -75,6 +76,7 @@ contract LibParseLiteralStringTest is Test {
}

/// Can parse 2 valid strings.
/// forge-config: default.fuzz.runs = 100
function testParseStringLiteralTwo(string memory strA, string memory strB) external view {
vm.assume(bytes(strA).length < 0x20);
LibLiteralString.conformValidPrintableStringContent(strA);
Expand All @@ -99,6 +101,7 @@ contract LibParseLiteralStringTest is Test {
}

/// Valid ASCII printable strings 32 bytes or longer should error.
/// forge-config: default.fuzz.runs = 100
function testParseStringLiteralLongASCII(string memory str) external {
vm.assume(bytes(str).length >= 0x20);
LibLiteralString.conformValidPrintableStringContent(str);
Expand All @@ -110,6 +113,7 @@ contract LibParseLiteralStringTest is Test {

/// Invalid chars beyond the 31 byte valid range will not be parsed. Instead
/// a `StringTooLong` error will be thrown.
/// forge-config: default.fuzz.runs = 100
function testParseStringLiteralInvalidCharAfter(string memory strA, string memory strB) external {
vm.assume(bytes(strA).length >= 0x20);
LibLiteralString.conformValidPrintableStringContent(strA);
Expand All @@ -126,6 +130,7 @@ contract LibParseLiteralStringTest is Test {

/// Invalid chars anywhere in the parsed string will cause an unclosed
/// string literal error.
/// forge-config: default.fuzz.runs = 100
function testParseStringLiteralInvalidCharWithin(string memory str, uint256 badIndex) external {
vm.assume(bytes(str).length > 0);
LibLiteralString.conformValidPrintableStringContent(str);
Expand Down
6 changes: 6 additions & 0 deletions test/src/lib/parse/LibParseOperand.parseOperand.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ contract LibParseOperandParseOperandTest is Test {

// Test that parsing a string that doesn't start with the operand opening
// character always results in a zero length operand values array.
/// forge-config: default.fuzz.runs = 100
function testParseOperandNoOpeningCharacter(string memory s) external pure {
vm.assume(bytes(s).length > 0);
vm.assume(bytes(s)[0] != "<");
Expand All @@ -53,6 +54,7 @@ contract LibParseOperandParseOperandTest is Test {
// Test that parsing an empty "<>" operand results in a zero length operand
// values array. The cursor moves past both the opening and closing
// characters.
/// forge-config: default.fuzz.runs = 100
function testParseOperandEmptyOperand(string memory s) external pure {
vm.assume(bytes(s).length > 2);
bytes(s)[0] = "<";
Expand All @@ -62,6 +64,7 @@ contract LibParseOperandParseOperandTest is Test {
}

// Test that we can parse a single literal.
/// forge-config: default.fuzz.runs = 100
function testParseOperandSingleDecimalLiteral(
bool asHex,
int256 value,
Expand Down Expand Up @@ -89,6 +92,7 @@ contract LibParseOperandParseOperandTest is Test {
}

// Test that we can parse two literals.
/// forge-config: default.fuzz.runs = 100
function testParseOperandTwoDecimalLiterals(
bool asHexA,
bool asHexB,
Expand Down Expand Up @@ -131,6 +135,7 @@ contract LibParseOperandParseOperandTest is Test {
}

// Test that we can parse three literals.
/// forge-config: default.fuzz.runs = 100
function testParseOperandThreeDecimalLiterals(
bool asHexA,
bool asHexB,
Expand Down Expand Up @@ -191,6 +196,7 @@ contract LibParseOperandParseOperandTest is Test {
}

// Test that we can parse four literals.
/// forge-config: default.fuzz.runs = 100
function testParseOperandFourDecimalLiterals(
bool[4] memory asHex,
int256[4] memory values,
Expand Down
5 changes: 5 additions & 0 deletions test/src/lib/parse/LibParsePragma.keyword.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ contract LibParsePragmaKeywordTest is Test {
}

/// Anything that DOES NOT start with the keyword should be a noop.
/// forge-config: default.fuzz.runs = 100
function testPragmaKeywordNoop(ParseState memory state, string calldata calldataStr) external pure {
if (bytes(calldataStr).length >= PRAGMA_KEYWORD_BYTES_LENGTH) {
bytes memory prefix = bytes(calldataStr)[0:PRAGMA_KEYWORD_BYTES_LENGTH];
Expand All @@ -82,6 +83,7 @@ contract LibParsePragmaKeywordTest is Test {

/// Anything that DOES start with the keyword but WITHOUT whitespace should
/// error.
/// forge-config: default.fuzz.runs = 100
function testPragmaKeywordNoWhitespace(uint256 seed, string memory str) external {
bytes1 notWhitespace = LibLiteralString.charFromMask(seed, ~CMASK_WHITESPACE);
string memory fullString =
Expand All @@ -93,6 +95,7 @@ contract LibParsePragmaKeywordTest is Test {
/// Anything that DOES start with the keyword and WITH whitespace BUT NOT
/// hex values should more the cursor forward exactly the length of the
/// keyword + the whitespace char.
/// forge-config: default.fuzz.runs = 100
function testPragmaKeywordWhitespaceNoHex(uint256 seed, string calldata calldataStr) external pure {
seed = bound(seed, 0, type(uint256).max - 1);
bytes1 whitespace = LibLiteralString.charFromMask(seed, CMASK_WHITESPACE);
Expand All @@ -117,6 +120,7 @@ contract LibParsePragmaKeywordTest is Test {

/// Anything that DOES start with the keyword and WITH whitespace then some
/// hex address should push the hex address to the state as a sub parser.
/// forge-config: default.fuzz.runs = 100
function testPragmaKeywordParseSubParser(
string memory whitespace,
address subParser,
Expand Down Expand Up @@ -153,6 +157,7 @@ contract LibParsePragmaKeywordTest is Test {
}

/// Can parse a couple of addresses cleanly.
/// forge-config: default.fuzz.runs = 100
function testPragmaKeywordParseSubParserCoupleOfAddresses(
string memory whitespace0,
string memory whitespace1,
Expand Down

0 comments on commit b5df403

Please sign in to comment.