Skip to content

Commit

Permalink
Use Echidna Action (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
naszam authored Mar 23, 2022
1 parent a4e42ab commit 90188d2
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 40 deletions.
61 changes: 39 additions & 22 deletions .github/workflows/echidna.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,52 @@ jobs:
- DssVestTransferrableEchidnaTest

steps:
- uses: actions/checkout@v2

- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 12
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: 3.8

- name: Install pip3
run: |
python -m pip install --upgrade pip
- name: Install slither
run: |
pip3 install slither-analyzer
- name: Install crytic-compile
run: pip3 install crytic-compile

- name: Install solc-select
run: |
pip3 install solc-select
- name: Set solc v0.6.12
run: pip3 install solc-select

- name: Solc Select 0.6.12
run: |
solc-select install 0.6.12
solc-select use 0.6.12
- name: Install echidna
- name: Crytic Compile ${{ matrix.testName }}
run: |
sudo wget -O /tmp/echidna-test.tar.gz https://github.com/crytic/echidna/releases/download/v1.7.3/echidna-test-1.7.3-Ubuntu-18.04.tar.gz
sudo tar -xf /tmp/echidna-test.tar.gz -C /usr/bin
sudo chmod +x /usr/bin/echidna-test
- name: Run ${{ matrix.testName }}
run: echidna-test echidna/${{ matrix.testName }}.sol --contract ${{ matrix.testName }} --config echidna.config.ci.yml
crytic-compile echidna/${{ matrix.testName }}.sol --solc-args "--optimize --optimize-runs 200" --export-format solc
jq --sort-keys . crytic-export/combined_solc.json > sorted_crytic_solc.json
- name: Cache ${{ matrix.testName }} Corpus
uses: actions/cache@v2
with:
path: corpus
key: abi-${{ matrix.testName }}-${{ hashFiles('**/sorted_crytic_solc.json') }}-v3

- name: Fuzz ${{ matrix.testName }}
uses: crytic/echidna-action@v2
with:
files: echidna/${{ matrix.testName }}.sol
contract: ${{ matrix.testName }}
config: echidna.config.ci.yml
corpus-dir: corpus
test-mode: assertion
test-limit: 250000
seq-len: 100
solc-args: --optimize --optimize-runs 200
solc-version: 0.6.12
echidna-version: v2.0.0

- name: Upload ${{ matrix.testName }} Coverage
uses: actions/upload-artifact@v2
with:
name: coverage-${{ matrix.testName }}
path: corpus/covered.*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
all :; DAPP_BUILD_OPTIMIZE=1 DAPP_BUILD_OPTIMIZE_RUNS=200 dapp --use solc:0.6.12 build
clean :; dapp clean
clean :; dapp clean && rm -rf crytic-export corpus
test :; make && ./test.sh $(match)
echidna-mintable :; ./echidna/echidna.sh mintable
echidna-suckable :; ./echidna/echidna.sh suckable
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Allows governance to schedule a point in the future to end the vest. Used for pl
$ echidnup v1.7.3
```

### Run Echidna Tests
### Local Dependencies

- Install solc 0.6.12
```
Expand All @@ -123,16 +123,18 @@ Allows governance to schedule a point in the future to end the vest. Used for pl
```
$ duppsolc 0.6.12
```
- Run Echidna Tests:
* DssVestMintableEchidnaTest:

### Run Echidna Tests

- DssVestMintableEchidnaTest:
```
$ make echidna-mintable
```
* DssVestSuckableEchidnaTest:
- DssVestSuckableEchidnaTest:
```
$ make echidna-suckable
```
* DssVestTransferrableEchidnaTest:
- DssVestTransferrableEchidnaTest:
```
$ make echidna-transferrable
```
Expand Down
10 changes: 2 additions & 8 deletions echidna.config.ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#format can be "text" or "json" for different output (human or machine readable)
format: "text"
#checkAsserts checks assertions
checkAsserts: true
#coverage controls coverage guided testing
coverage: false
#maximum time between generated txs; default is one week
maxTimeDelay: 31556952 # approximately 1 year
#deployer is address of the contract deployer (who often is privileged owner, etc.)
deployer: '0x41414141'
deployer: "0x41414141"
#sender is set of addresses transactions may originate from
sender: ['0x42424242', '0x43434343']
sender: ["0x42424242", "0x43434343"]
10 changes: 6 additions & 4 deletions echidna.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
#format: "text"
#checkAsserts checks assertions
checkAsserts: true
#seqLen defines how many transactions are in a test sequence
seqLen: 200
#testLimit is the number of test sequences to run
testLimit: 1000000
#seqLen defines how many transactions are in a test sequence
seqLen: 200
#solcArgs allows special args to solc
solcArgs: "--optimize --optimize-runs 200"
#maximum time between generated txs; default is one week
maxTimeDelay: 15778800 # approximately 6 months
#directory to save the corpus; by default is disabled
corpusDir: "corpus"
#deployer is address of the contract deployer (who often is privileged owner, etc.)
deployer: '0x41414141'
deployer: "0x41414141"
#sender is set of addresses transactions may originate from
sender: ['0x42424242', '0x43434343']
sender: ["0x42424242", "0x43434343"]

0 comments on commit 90188d2

Please sign in to comment.