-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Echidna fuzzing with CI support (#8)
* echidna config * echidna-action * echidna vault with seeding * better abstraction for invariants * move to echidna folder * corpus caching + coverage upload as artifact * limit test to 30000 a pop
- Loading branch information
Showing
7 changed files
with
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Echidna Test | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test: | ||
- Echidna_Deposit_Withdraw | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
cache: 'yarn' | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- run: yarn install | ||
- run: yarn run hardhat compile | ||
|
||
- name: Cache ${{ matrix.test }} corpus | ||
uses: actions/cache@v2 | ||
with: | ||
path: corpus | ||
key: abi-${{ matrix.test }}-v2 | ||
|
||
- name: Run Echidna | ||
uses: crytic/echidna-action@v1 | ||
with: | ||
solc-version: 0.8.10 | ||
files: . | ||
contract: ${{ matrix.test }} | ||
crytic-args: --hardhat-ignore-compile | ||
config: contracts/echidna/${{ matrix.test }}.yml | ||
|
||
- name: Upload ${{ matrix.test }} coverage | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: coverage-${{ matrix.test }} | ||
path: corpus/covered.* |
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 |
---|---|---|
|
@@ -14,3 +14,5 @@ deployments/hardhat | |
deployments/docker | ||
subgraph/generated | ||
subgraph/tests/.bin/* | ||
crytic-export/ | ||
corpus/ |
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,10 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity =0.8.10; | ||
|
||
import "../Vault.sol"; | ||
import "../test/TestERC20.sol"; | ||
|
||
contract Addresses { | ||
Vault vault = Vault(0x6A4A62E5A7eD13c361b176A5F62C2eE620Ac0DF8); | ||
TestERC20 underlying = TestERC20(0x1dC4c1cEFEF38a777b15aA20260a54E584b16C48); | ||
} |
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,19 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity =0.8.10; | ||
import "./Helper.sol"; | ||
|
||
contract Echidna_Deposit_Withdraw is Helper { | ||
|
||
// zero address should always revert | ||
function withdraw_zero_address_recipient(uint256[] memory _ids) public { | ||
withdraw_should_revert(address(0), _ids); | ||
} | ||
|
||
function withdraw_should_revert(address recipient, uint256[] memory _ids) internal { | ||
try vault.withdraw(recipient, _ids) { | ||
assert(false); | ||
} catch { | ||
assert(true); | ||
} | ||
} | ||
} |
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,6 @@ | ||
initialize: contracts/echidna/init.json | ||
coverage: true | ||
testMode: assertion | ||
testLimit: 30000 | ||
corpusDir: 'corpus' | ||
codeSize: 0xfffffffffff |
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,8 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity =0.8.10; | ||
import "./Addresses.sol"; | ||
|
||
contract Helper is Addresses { | ||
|
||
|
||
} |
Large diffs are not rendered by default.
Oops, something went wrong.