forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: configure medusa with two basic fuzz tests
- used --foundry-compile-all to ensure the test contract under `test/properties` is compiled (otherwise it is not compiled and medusa crashes when it can't find it's compiled representation) - set src,test,script to test/properties/medusa to not waste time compiling contracts that are not required for the medusa campaign
- Loading branch information
1 parent
d469a49
commit cfb3f68
Showing
4 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"fuzzing": { | ||
"workers": 10, | ||
"workerResetLimit": 50, | ||
"timeout": 0, | ||
"testLimit": 500, | ||
"callSequenceLength": 100, | ||
"corpusDirectory": "", | ||
"coverageEnabled": true, | ||
"targetContracts": ["SuperchainERC20FactoryFuzz"], | ||
"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": false, | ||
"panicCodeConfig": { | ||
"failOnCompilerInsertedPanic": false, | ||
"failOnAssertion": true, | ||
"failOnArithmeticUnderflow": false, | ||
"failOnDivideByZero": false, | ||
"failOnEnumTypeConversionOutOfBounds": false, | ||
"failOnIncorrectStorageAccess": false, | ||
"failOnPopEmptyArray": false, | ||
"failOnOutOfBoundsArrayAccess": false, | ||
"failOnAllocateTooMuchMemory": false, | ||
"failOnCallUninitializedVariable": false | ||
} | ||
}, | ||
"propertyTesting": { | ||
"enabled": false, | ||
"testPrefixes": [ | ||
"property_" | ||
] | ||
}, | ||
"optimizationTesting": { | ||
"enabled": false, | ||
"testPrefixes": [ | ||
"optimize_" | ||
] | ||
}, | ||
"targetFunctionSignatures": [], | ||
"excludeFunctionSignatures": [] | ||
}, | ||
"chainConfig": { | ||
"codeSizeCheckDisabled": true, | ||
"cheatCodes": { | ||
"cheatCodesEnabled": true, | ||
"enableFFI": false | ||
} | ||
} | ||
}, | ||
"compilation": { | ||
"platform": "crytic-compile", | ||
"platformConfig": { | ||
"target": ".", | ||
"solcVersion": "", | ||
"exportDirectory": "", | ||
"args": ["--foundry-out-directory", "artifacts","--foundry-compile-all"] | ||
} | ||
}, | ||
"logging": { | ||
"level": "info", | ||
"logDirectory": "", | ||
"noColor": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/contracts-bedrock/test/properties/medusa/SuperchainERC20Factory.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
import {Test} from "forge-std/Test.sol"; | ||
|
||
import { SuperchainERC20Factory } from "src/L2/SuperchainERC20Factory.sol"; | ||
|
||
contract SuperchainERC20FactoryFuzz is Test{ | ||
struct DeployParams { | ||
address remoteToken; | ||
string name; | ||
string symbol; | ||
uint8 decimals; | ||
} | ||
|
||
SuperchainERC20Factory internal factory; | ||
|
||
constructor() { | ||
factory = new SuperchainERC20Factory(); | ||
} | ||
|
||
// this is a stateless check, so halmos will probably supersede it | ||
function testContractAddressDependsOnParams(DeployParams memory left, DeployParams memory right) external { | ||
require( | ||
left.remoteToken != right.remoteToken | ||
|| keccak256(bytes(left.name)) != keccak256(bytes(right.name)) | ||
|| keccak256(bytes(left.symbol)) != keccak256(bytes(right.symbol)) | ||
|| left.decimals != right.decimals | ||
); | ||
address superc20Left = factory.deploy(left.remoteToken, left.name, left.symbol, left.decimals); | ||
address superc20Right = factory.deploy(right.remoteToken, right.name, right.symbol, right.decimals); | ||
assert(superc20Left != superc20Right); | ||
} | ||
|
||
function testContractAddressDoesNotDependOnChainId(DeployParams memory params, uint256 chainIdLeft, uint256 chainIdRight) external { | ||
vm.chainId(chainIdLeft); | ||
address superc20Left = factory.deploy(params.remoteToken, params.name, params.symbol, params.decimals); | ||
vm.chainId(chainIdRight); | ||
address superc20Right = factory.deploy(params.remoteToken, params.name, params.symbol, params.decimals); | ||
assert(superc20Left == superc20Right); | ||
} | ||
} |