-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
A-testingArea: testingArea: testingC-forgeCommand: forgeCommand: forgeCmd-forge-testCommand: forge testCommand: forge testD-hardDifficulty: hardDifficulty: hardP-highPriority: highPriority: highT-bugType: bugType: bug
Milestone
Description
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
forge 0.2.0 (233ab70 2022-04-01T00:51:18.292928+00:00)
What command(s) is the bug in?
forge test
Operating System
macOS (amd)
Describe the bug
Below is a contract and test that have very little state, so you'd expect both tests to fail relatively quickly because the fuzzer should try using each owner address as input. However, this does not happen, and most of the time these tests pass, whether I use 100 or 100k fuzz runs. I have not yet investigated this, but potential causes:
- Values are not actually being added to the dictionary
- Values improperly encoded/formatted before being added
- All random fuzz inputs (or other useless state, such as nonces, gas used, etc.) are being added to the dictionary, blowing up its size and making it less likely for the owner addresses to be used
pragma solidity 0.8.13;
import "ds-test/test.sol";
import "forge-std/Vm.sol";
contract FuzzerDict {
// Immutables should get added to the dictionary.
address public immutable immutableOwner;
// Regular storage variables should also get added to the dictionary.
address public storageOwner;
constructor(address _immutableOwner, address _storageOwner) {
immutableOwner = _immutableOwner;
storageOwner = _storageOwner;
}
}
contract FuzzerDictTest is DSTest {
FuzzerDict fuzzerDict;
Vm vm = Vm(HEVM_ADDRESS);
function setUp() public {
fuzzerDict = new FuzzerDict(address(100), address(200));
}
// Fuzzer should try `fuzzerDict.immutableOwner()` as input, causing this to fail
function testImmutableOwner(address who) public {
assertTrue(who != fuzzerDict.immutableOwner());
}
// Fuzzer should try `fuzzerDict.storageOwner()` as input, causing this to fail
function testStorageOwner(address who) public {
assertTrue(who != fuzzerDict.storageOwner());
}
}
Metadata
Metadata
Assignees
Labels
A-testingArea: testingArea: testingC-forgeCommand: forgeCommand: forgeCmd-forge-testCommand: forge testCommand: forge testD-hardDifficulty: hardDifficulty: hardP-highPriority: highPriority: highT-bugType: bugType: bug
Type
Projects
Status
Done