-
Notifications
You must be signed in to change notification settings - Fork 28
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
chore: use medusa instead of echidna #87
Changes from all commits
6752564
2453dd6
c0b5131
92d1d9e
dd7ea8d
b993e92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"fuzzing": { | ||
"workers": 10, | ||
"workerResetLimit": 50, | ||
"timeout": 0, | ||
"testLimit": 0, | ||
"shrinkLimit": 5000, | ||
"callSequenceLength": 100, | ||
"corpusDirectory": "", | ||
"coverageEnabled": true, | ||
"coverageFormats": [ | ||
"html", | ||
"lcov" | ||
], | ||
"targetContracts": ["FuzzTest"], | ||
"predeployedContracts": {}, | ||
"targetContractsBalances": [], | ||
"constructorArgs": {}, | ||
"deployerAddress": "0x30000", | ||
"senderAddresses": [ | ||
"0x10000", | ||
"0x20000", | ||
"0x30000" | ||
], | ||
"blockNumberDelayMax": 60480, | ||
"blockTimestampDelayMax": 604800, | ||
"blockGasLimit": 125000000, | ||
"transactionGasLimit": 12500000, | ||
"testing": { | ||
"stopOnFailedTest": true, | ||
"stopOnFailedContractMatching": false, | ||
"stopOnNoTests": true, | ||
"testAllContracts": false, | ||
"traceAll": false, | ||
"assertionTesting": { | ||
"enabled": true, | ||
"testViewMethods": true, | ||
"panicCodeConfig": { | ||
"failOnCompilerInsertedPanic": false, | ||
"failOnAssertion": true, | ||
"failOnArithmeticUnderflow": false, | ||
"failOnDivideByZero": false, | ||
"failOnEnumTypeConversionOutOfBounds": false, | ||
"failOnIncorrectStorageAccess": false, | ||
"failOnPopEmptyArray": false, | ||
"failOnOutOfBoundsArrayAccess": false, | ||
"failOnAllocateTooMuchMemory": false, | ||
"failOnCallUninitializedVariable": false | ||
} | ||
}, | ||
"propertyTesting": { | ||
"enabled": false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. true by default (avoiding incidents)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the idea is for the boilerplate to closely resemble what we run in production, and afaik we are disabling property testing in all projects to reduce complexity (2 kinds of tests vs 1) and help avoid mistakes where the property testing mode is disabled down the line and property tests are executed as assertion tests, causing a false negative, since that false negative would be present when the test is initially developed, making it evident |
||
"testPrefixes": [ | ||
"property_" | ||
] | ||
}, | ||
"optimizationTesting": { | ||
"enabled": false, | ||
"testPrefixes": [ | ||
"optimize_" | ||
] | ||
}, | ||
"targetFunctionSignatures": [], | ||
"excludeFunctionSignatures": [] | ||
}, | ||
"chainConfig": { | ||
"codeSizeCheckDisabled": true, | ||
"cheatCodes": { | ||
"cheatCodesEnabled": true, | ||
"enableFFI": false | ||
}, | ||
"skipAccountChecks": true | ||
} | ||
}, | ||
"compilation": { | ||
"platform": "crytic-compile", | ||
"platformConfig": { | ||
"target": "test/invariants/fuzz/FuzzTest.t.sol", | ||
"solcVersion": "", | ||
"exportDirectory": "", | ||
"args": [] | ||
} | ||
}, | ||
"logging": { | ||
"level": "info", | ||
"logDirectory": "", | ||
"noColor": false | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
| Properties | Type | | ||
|---------------------------------------------------|------------| | ||
| Greeting should never be empty | Valid state | | ||
| Only the owner can set the greeting | State transition | | ||
| Id | Properties | Type | | ||
| --- | --------------------------------------------------- | ------------ | | ||
| 1 | Greeting should never be empty | Valid state | | ||
| 2 | Only the owner can set the greeting | State transition | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {GreeterGuidedHandlers} from './handlers/guided/Greeter.t.sol'; | ||
import {GreeterUnguidedHandlers} from './handlers/unguided/Greeter.t.sol'; | ||
import {GreeterProperties} from './properties/Greeter.t.sol'; | ||
|
||
contract FuzzTest is GreeterGuidedHandlers, GreeterUnguidedHandlers, GreeterProperties {} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {GreeterSetup} from '../../setup/Greeter.t.sol'; | ||
|
||
contract GreeterGuidedHandlers is GreeterSetup { | ||
function handler_setGreeting(string memory _newGreeting) external { | ||
// no need to prank since this contract deployed the greeter and is therefore its owner | ||
try _targetContract.setGreeting(_newGreeting) { | ||
assert(keccak256(bytes(_targetContract.greeting())) == keccak256(bytes(_newGreeting))); | ||
} catch { | ||
assert(keccak256(bytes(_newGreeting)) == keccak256('')); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {GreeterSetup} from '../../setup/Greeter.t.sol'; | ||
|
||
contract GreeterUnguidedHandlers is GreeterSetup { | ||
/// @custom:property-id 2 | ||
/// @custom:property Only the owner can set the greeting | ||
function handler_setGreeting(address _caller, string memory _newGreeting) external { | ||
vm.prank(_caller); | ||
try _targetContract.setGreeting(_newGreeting) { | ||
assert(keccak256(bytes(_targetContract.greeting())) == keccak256(bytes(_newGreeting))); | ||
assert(_caller == _targetContract.OWNER()); | ||
} catch { | ||
assert(_caller != _targetContract.OWNER() || keccak256(bytes(_newGreeting)) == keccak256('')); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {GreeterSetup} from '../setup/Greeter.t.sol'; | ||
|
||
contract GreeterProperties is GreeterSetup { | ||
/// @custom:property-id 1 | ||
/// @custom:property Greeting should never be empty | ||
function property_greetingIsNeverEmpty() external view { | ||
assert(keccak256(bytes(_targetContract.greeting())) != keccak256('')); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {Greeter, IERC20} from 'contracts/Greeter.sol'; | ||
import {CommonBase} from 'forge-std/Base.sol'; | ||
|
||
contract GreeterSetup is CommonBase { | ||
Greeter internal _targetContract; | ||
|
||
constructor() { | ||
_targetContract = new Greeter('a', IERC20(address(1))); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are not using these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are not taking advantage of the various sender addresses in the simple boilerplate example, but they are usually later used in our actor setups for bigger projects, so I lean on leaving them in
what should be the alternative? using only one? I believe medusa wont run if they key is deleted or has an empty array as a value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use just one only if somehow it enhance the performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik having one vs many doesnt affect performance (as long as having many users doesnt make the domain of possible states grow at a relevant rate, which is not the case for the humble greeter)