From 4f3ca42a1756f51e7187fdb4ff4368e0fdef7448 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Wed, 29 May 2024 13:10:25 +0200 Subject: [PATCH] fixes in README and configs --- README.md | 23 ++++++++-------- tests/ERC20/foundry/medusa-config-ext.json | 2 +- tests/ERC20/hardhat/medusa-config-ext.json | 31 +++++++++++++++++----- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d121575..0c0cebf 100644 --- a/README.md +++ b/README.md @@ -128,18 +128,10 @@ testMode: assertion testLimit: 100000 deployer: "0x10000" sender: ["0x10000", "0x20000", "0x30000"] +# Uncomment the following line for external testing +#allContracts: true ``` -If you're using external testing, you will also need to specify: - -```yaml -allContracts: true -``` - -To perform more than one test, save the files with a descriptive path, to identify what test each file or corpus belongs to. For these examples, we use `tests/crytic/erc20/echidna-internal.yaml` and `tests/crytic/erc20/echidna-external.yaml` for the Echidna tests for ERC20. We recommended to modify the `corpusDir` for external tests accordingly. - -The above configuration will start Echidna in assertion mode. Contract will be deployed from address `0x10000`, and transactions will be sent from the owner and two different users (`0x20000` and `0x30000`). There is an initial limit of `100000` tests, but depending on the token code complexity, this can be increased. Finally, once Echidna finishes the fuzzing campaign, corpus and coverage results will be available in the `tests/crytic/erc20/echidna-corpus-internal` directory. - **Medusa** Create the following Medusa config file: @@ -147,6 +139,7 @@ Create the following Medusa config file: ```json { "fuzzing": { + "testLimit": 100000, "corpusDirectory": "tests/medusa-corpus", "deployerAddress": "0x10000", "senderAddresses": [ @@ -164,6 +157,10 @@ Create the following Medusa config file: "enabled": false, }, }, +// Uncomment the following lines for external testing +// "testing": { +// "testAllContracts": true +// }, "compilation": { "platform": "crytic-compile", "platformConfig": { @@ -176,6 +173,10 @@ Create the following Medusa config file: } ``` +To perform more than one test, save the files with a descriptive path, to identify what test each file or corpus belongs to. For instace, for these examples, we use `tests/crytic/erc20/echidna-internal.yaml` and `tests/crytic/erc20/echidna-external.yaml` for the Echidna tests for ERC20. We recommended to modify the corpus directory config opction for external tests accordingly. + +The above configuration will start Echidna or Medusa in assertion mode. The target contract(s) will be deployed from address `0x10000`, and transactions will be sent from the owner as well as two different users (`0x20000` and `0x30000`). There is an initial limit of `100000` tests, but depending on the token code complexity, this can be increased. Finally, once our fuzzing tools finish the fuzzing campaign, corpus and coverage results will be available in the specified corpus directory. + #### Run **Echidna** @@ -183,8 +184,6 @@ Create the following Medusa config file: - For internal testing: `echidna . --contract CryticERC20InternalHarness --config tests/crytic/erc20/echidna-internal.yaml` - For external testing: `echidna . --contract CryticERC20ExternalHarness --config tests/crytic/erc20/echidna-external.yaml` -Finally, inspect the coverage report in `tests/crytic/erc20/echidna-corpus-internal` or `tests/crytic/erc20/echidna-corpus-external` when it finishes. - **Medusa** - Go to the directory `cd tests/crytic/erc20` diff --git a/tests/ERC20/foundry/medusa-config-ext.json b/tests/ERC20/foundry/medusa-config-ext.json index 0a5a478..99b94fa 100644 --- a/tests/ERC20/foundry/medusa-config-ext.json +++ b/tests/ERC20/foundry/medusa-config-ext.json @@ -24,7 +24,7 @@ "stopOnFailedTest": true, "stopOnFailedContractMatching": false, "stopOnNoTests": true, - "testAllContracts": false, + "testAllContracts": true, "traceAll": false, "assertionTesting": { "enabled": true, diff --git a/tests/ERC20/hardhat/medusa-config-ext.json b/tests/ERC20/hardhat/medusa-config-ext.json index 2498b74..a77d593 100644 --- a/tests/ERC20/hardhat/medusa-config-ext.json +++ b/tests/ERC20/hardhat/medusa-config-ext.json @@ -7,7 +7,8 @@ "callSequenceLength": 100, "corpusDirectory": "tests/medusa-corpus-ext", "coverageEnabled": true, - "deploymentOrder": [], + "targetContracts": [], + "targetContractsBalances": [], "constructorArgs": {}, "deployerAddress": "0x10000", "senderAddresses": [ @@ -21,19 +22,30 @@ "transactionGasLimit": 12500000, "testing": { "stopOnFailedTest": true, - "stopOnFailedContractMatching": true, + "stopOnFailedContractMatching": false, "stopOnNoTests": true, - "testAllContracts": false, - "onlyCallFromDeploymentOrder": false, + "testAllContracts": true, "traceAll": false, "assertionTesting": { "enabled": true, - "testViewMethods": false + "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": [ - "fuzz_" + "property_" ] }, "optimizationTesting": { @@ -59,5 +71,10 @@ "exportDirectory": "", "args": [] } + }, + "logging": { + "level": "info", + "logDirectory": "", + "noColor": false } -} +} \ No newline at end of file