Skip to content

Commit

Permalink
fixes in README and configs
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrieco-tob committed May 29, 2024
1 parent 2dfdb56 commit 4f3ca42
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,18 @@ 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:

```json
{
"fuzzing": {
"testLimit": 100000,
"corpusDirectory": "tests/medusa-corpus",
"deployerAddress": "0x10000",
"senderAddresses": [
Expand All @@ -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": {
Expand All @@ -176,15 +173,17 @@ 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**

- 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`
Expand Down
2 changes: 1 addition & 1 deletion tests/ERC20/foundry/medusa-config-ext.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"stopOnFailedTest": true,
"stopOnFailedContractMatching": false,
"stopOnNoTests": true,
"testAllContracts": false,
"testAllContracts": true,
"traceAll": false,
"assertionTesting": {
"enabled": true,
Expand Down
31 changes: 24 additions & 7 deletions tests/ERC20/hardhat/medusa-config-ext.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"callSequenceLength": 100,
"corpusDirectory": "tests/medusa-corpus-ext",
"coverageEnabled": true,
"deploymentOrder": [],
"targetContracts": [],
"targetContractsBalances": [],
"constructorArgs": {},
"deployerAddress": "0x10000",
"senderAddresses": [
Expand All @@ -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": {
Expand All @@ -59,5 +71,10 @@
"exportDirectory": "",
"args": []
}
},
"logging": {
"level": "info",
"logDirectory": "",
"noColor": false
}
}
}

0 comments on commit 4f3ca42

Please sign in to comment.