-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Echidna fuzzing with CI support #8
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
87d4f23
yarn.lock update
coolhill 10fbc8b
echidna config
coolhill 9e9e438
echidna ci + EchidnaPercentMath
coolhill 6e71231
echidna-action
coolhill cab3905
echidna ci fix
coolhill a25e2ab
echidna vault with seeding
coolhill 88277fd
echidnavault config
coolhill 2721d09
wip
coolhill 6fb0dcd
Merge branch 'main' of github.com:sandclock-org/solidity_contracts in…
coolhill b63c5bc
Merge branch 'main' of github.com:sandclock-org/solidity_contracts in…
coolhill 08dd9f2
better abstraction for invariants
coolhill cb4dc2a
move to echidna folder
coolhill 19bd450
corpus caching + coverage upload as artifact
coolhill 062e7d7
rm percentmath test
coolhill d513a65
limit tests to 3000 a pop
coolhill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more interesting ones will be added in another PR