You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Bug reports and feature suggestions can be submitted to our issue tracker. For b
10
10
11
11
## Questions
12
12
13
-
Questions can be submitted to the issue tracker, but you may get a faster response if you ask in our [chat room](https://slack.empirehacking.nyc/) (in the #ethereum channel).
13
+
Questions can be submitted to the issue tracker, but you may get a faster response if you ask in our [chat room](https://slack.empirehacking.nyc) (in the #ethereum channel).
Copy file name to clipboardExpand all lines: README.md
+54-11
Original file line number
Diff line number
Diff line change
@@ -33,11 +33,11 @@ The goals of these properties are to:
33
33
- Ensure adherence to relevant standards
34
34
- Provide educational guidance for writing invariants
35
35
36
-
The properties can be used through unit tests or through fuzzing with [Echidna](https://github.com/crytic/echidna).
36
+
The properties can be used through unit tests or through fuzzing with [Echidna](https://github.com/crytic/echidna) or [Medusa](https://github.com/crytic/medusa).
1. Install [Echidna](https://github.com/crytic/echidna#installation) or [Medusa](https://github.com/crytic/medusa/blob/master/docs/src/getting_started/installation.md#installation).
41
41
2. Import the properties into to your project:
42
42
43
43
- In case of using Hardhat, use: `npm install https://github.com/crytic/properties.git` or `yarn add https://github.com/crytic/properties.git`
@@ -118,6 +118,8 @@ contract CryticTokenMock is MyToken, PropertiesConstants {
118
118
119
119
#### Configuration
120
120
121
+
**Echidna**
122
+
121
123
Create the following Echidna config file
122
124
123
125
```yaml
@@ -126,26 +128,67 @@ testMode: assertion
126
128
testLimit: 100000
127
129
deployer: "0x10000"
128
130
sender: ["0x10000", "0x20000", "0x30000"]
131
+
# Uncomment the following line for external testing
132
+
#allContracts: true
129
133
```
130
134
131
-
If you're using external testing, you will also need to specify:
132
-
133
-
```yaml
134
-
allContracts: true
135
+
**Medusa**
136
+
137
+
Create the following Medusa config file:
138
+
139
+
```json
140
+
{
141
+
"fuzzing": {
142
+
"testLimit": 100000,
143
+
"corpusDirectory": "tests/medusa-corpus",
144
+
"deployerAddress": "0x10000",
145
+
"senderAddresses": [
146
+
"0x10000",
147
+
"0x20000",
148
+
"0x30000"
149
+
],
150
+
"assertionTesting": {
151
+
"enabled": true
152
+
},
153
+
"propertyTesting": {
154
+
"enabled": false
155
+
},
156
+
"optimizationTesting": {
157
+
"enabled": false,
158
+
},
159
+
},
160
+
// Uncomment the following lines for external testing
161
+
// "testing": {
162
+
// "testAllContracts": true
163
+
// },
164
+
"compilation": {
165
+
"platform": "crytic-compile",
166
+
"platformConfig": {
167
+
"target": ".",
168
+
"solcVersion": "",
169
+
"exportDirectory": "",
170
+
"args": ["--foundry-compile-all"]
171
+
}
172
+
}
173
+
}
135
174
```
136
175
137
-
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.
176
+
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.
138
177
139
-
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.
178
+
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.
140
179
141
180
#### Run
142
181
143
-
Run Echidna:
182
+
**Echidna**
144
183
145
184
- For internal testing: `echidna . --contract CryticERC20InternalHarness --config tests/crytic/erc20/echidna-internal.yaml`
146
185
- For external testing: `echidna . --contract CryticERC20ExternalHarness --config tests/crytic/erc20/echidna-external.yaml`
147
186
148
-
Finally, inspect the coverage report in `tests/crytic/erc20/echidna-corpus-internal` or `tests/crytic/erc20/echidna-corpus-external` when it finishes.
187
+
**Medusa**
188
+
189
+
- Go to the directory `cd tests/crytic/erc20`
190
+
- For internal testing: `medusa fuzz --target-contracts CryticERC20InternalHarness --config medusa-internal.yaml`
191
+
- For external testing: `medusa fuzz --target-contracts CryticERC20ExternalHarness --config medusa-external.yaml`
149
192
150
193
#### Example: Output for a compliant token
151
194
@@ -417,7 +460,7 @@ Run the test suite using `echidna . --contract CryticABDKMath64x64Harness --seq-
0 commit comments