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

Change hardcoded tests into fuzztests. #20

Open
5 of 10 tasks
a-t-0 opened this issue Apr 30, 2024 · 1 comment
Open
5 of 10 tasks

Change hardcoded tests into fuzztests. #20

a-t-0 opened this issue Apr 30, 2024 · 1 comment

Comments

@a-t-0
Copy link
Member

a-t-0 commented Apr 30, 2024

Where possible, change the tests from hardcoded tests, to fuzztests with random variables over ranges. For example see: https://book.getfoundry.sh/forge/fuzz-testing

  • Visualise the hit rate of each branch in the fuzz test.
  • Assert each branch of the fuzz test is hit.
  • Write a test that is able to generate arbitrary tiers.
  • Restore Slither by including the ViaIR=true in the json or the --via-ir flag in the CLI via precommit.
  • Create expect reverts for runs in which the initialisation is not valid.
  • Merge can Initialise and initialise by returning a boolean, and the actual object or dummy object as tupple.
  • Move getRandomMultiplesAndCeilings into a separate file and import the constants from somewhere. #25
  • Find out how to exclude initialisation function from coverage but how to include consequtive function that is called.
  • Find out how to visualise the test case ratio through emit log.
  • randomize number of investments. #27
@a-t-0
Copy link
Member Author

a-t-0 commented May 27, 2024

// Assume requirements on contract initialisation by project lead are valid.
    // vm.assume(projectLeadFracDenominator > 0);
    // vm.assume(firstCeiling > 0);
    // vm.assume(additionalWaitPeriod > 0);
    // vm.assume(raisePeriod > 0);
    // vm.assume(investmentTarget > 0);
    // vm.assume(firstCeiling < secondCeiling);
    // vm.assume(secondCeiling < thirdCeiling);
    // vm.assume(investmentTarget <= thirdCeiling);
    // vm.assume(projectLeadFracNumerator <= projectLeadFracDenominator);
    // vm.assume(firstMultiple > 1);
    // vm.assume(secondMultiple > 1);
    // vm.assume(thirdMultiple > 1);

    // Assume an investor tries to invest at least 1 wei.
    // vm.assume(firstInvestmentAmount > 0);
    
    // Store multiples in an array to assert they do not lead to an overflow when computing the investor return.
    // uint8[] memory multiples = new uint8[](3);
    // multiples[0] = firstMultiple;
    // multiples[1] = secondMultiple;
    // multiples[2] = thirdMultiple;
    // vm.assume(!_testHelper.sumOfNrsThrowsOverFlow({ numbers: multiples }));
    // vm.assume(
    // !_testHelper.yieldsOverflowMultiply({
    // a: firstMultiple + secondMultiple + thirdMultiple,
    // b: firstInvestmentAmount
    // })
    // );

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

No branches or pull requests

1 participant