12
votes
Accepted
What's the difference between invariant and fuzz testing?
Summary
Fuzz testing, also known as fuzzing, involves providing random data as inputs during testing.
Invariant tests are tests that focus on verifying the conditions that must always hold in a system....
3
votes
Accepted
Foundry Fuzzing How to increase the runs to be more than default 256
Ok, I found how to increase fuzz runs:
Inside the foundry.toml
Add this
[fuzz]
runs = 1000000
But I don't know whether that is correct solution.
3
votes
Accepted
Symbolic Execution vs Fuzz Testing - What's the difference?
Summary
Fuzzing & Symbolic execution accomplish similar goals of finding cases where code breaks, but have tradeoffs in speed vs. precision, and take very different approaches.
Fuzzing: Much ...
2
votes
Fuzz Testing for Solidity Smart Contract
Foundry and Echidna are the two main fuzz testing tools I know of. There's also been research and development with Symbolic Execution, essentially a way to mathematically determine branches in your ...
2
votes
Foundry invariant tests: targetArtifact not seemed to be working
I had the same problem. It turns out they renamed InvariantTest to StdInvariant. So, you have to import StdInvariant contract and extend your test contract for property-based fuzzing. For example:
...
1
vote
Why does this afterInvariant test revert?
It’s failing because the assertEq condition(s) inside the afterInvariant() function are not being fulfilled.
It would show the reason of failure in the console like:
[FAIL: assertion failed: false != ...
1
vote
Accepted
why am I getting this <{FAIL. Reason: panic: arithmetic underflow or overflow (0x11)]> error
As, dscEngine.redeemCollateral() is not pranked by msg.sender, therefore it's getting called by the address of the StopOnRevertHandler contract itself.
And since, the StopOnRevertHandler hasn't ...
1
vote
Foundry "afterAll" method?
You can potentially use the afterInvariant function of the Invariant Testing (i.e., Stateful Fuzz Testing).
Here's the minimal example showcasing the invariant testing of the Counter contract (i.e., ...
1
vote
Accepted
Can you Fuzz test with random parameters in the setUp() function in Forge?
I was looking to do this as well, but the setUp() function does not take any parameter, thus making fuzzing impossible.
This was requested as a functionality in this issue : https://github.com/foundry-...
1
vote
How do I test for two conditions at the same time in Foundry while running a fuzz test?
How about codes below?
function testAddition(uint256 a, uint256 b) public {
assert(a <= (type(uint256).max - b));
}
1
vote
Accepted
What is the best way of setting limits of fuzz test input parameters in Foundry?
Foundry implements function bound(uint256 x, uint256 min, uint256 max), which bounds a variable parameter to a certain range. To bound an input parameter, you can do something like this:
function ...
1
vote
Between writing fuzzing tests with echidna vs writing fuzzing tests with foundry, are there any advantages one has over the other?
For seeing the quick difference between both foundry and echidna, I prefer cloning this repo and testing it yourself: https://github.com/skpkss/Unhackable_Contracts . Now, let's deep dive into some ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
fuzz-test × 19foundry × 16
solidity × 8
invariant-test × 6
forge × 5
testing × 3
logs × 3
echidna × 2
evm × 1
library × 1
solidity-0.8.x × 1
stablecoins × 1
solidity-coverage × 1
symbolic-execution × 1