Skip to content
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 code coverage for contracts #200

Merged
merged 6 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ L2VaultTest:testL2ToL1Rebalance() (gas: 148043)
L2VaultTest:testLockedProfit() (gas: 339357)
L2VaultTest:testManagementFee() (gas: 426060)
L2VaultTest:testMinDeposit() (gas: 185217)
L2VaultTest:testMint(uint128) (runs: 256, μ: 189392, ~: 189626)
L2VaultTest:testMint(uint128) (runs: 256, μ: 189315, ~: 189626)
L2VaultTest:testReceiveTVL() (gas: 137333)
L2VaultTest:testSettingFees() (gas: 49261)
L2VaultTest:testSettingForwarder() (gas: 40951)
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,21 @@ jobs:
- name: Run forge tests.
run: yarn test

# Snapshots are buggy https://github.com/foundry-rs/foundry/issues/2959
# Fuzz tests are included by default
# - name: Check gas snapshots.
# run: yarn snap --check
- name: Check gas snapshots.
run: yarn snap --check

- name: Generate coverage report
run: forge coverage --report lcov

- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v1
with:
coverage-files: lcov.info
minimum-coverage: 10
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./

- name: Run hardhat tests.
run: yarn test-hh -eth mainnet -p mainnet
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ docs/
# Foundry
out
cache
lcov.info

# Address Book
addressbook.json

# Other
.DS_Store

# Openzappelin
# Openzeppelin
# Note: Not needed in testing phase, but in prod, probably
# worth keeping openzap files in VCS.
# worth keeping openzep files in VCS.
.openzeppelin
10 changes: 1 addition & 9 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@
src = 'src'
test = 'test'
out = 'out'
libs = ['lib']
remappings = [
'@opengsn/=node_modules/@opengsn/',
'@openzeppelin/=node_modules/@openzeppelin/',
'@uniswap/=node_modules/@uniswap/',
'solmate/=node_modules/solmate/',
'forge-std/=node_modules/forge-std/src/',
'ds-test/=node_modules/ds-test/src/'
]
libs = ['lib', 'node_modules']
libraries = []
cache = true
force = false
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"description": "Alpine Ethereum and Matic smart contracts",
"main": "index.js",
"scripts": {
"test": "eval $(egrep -v '^#' .env) forge test",
"snap": "eval $(egrep -v '^#' .env) forge snapshot",
"env": "eval $(egrep -v '^#' .env)",
"test": "yarn env && forge test",
"snap": "yarn env && forge snapshot",
"cov": "yarn env && forge coverage",
"test-hh": "ts-node scripts/fork.ts test",
"clean": "forge clean",
"script": "ts-node scripts/fork.ts script",
Expand Down
4 changes: 0 additions & 4 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
@openzeppelin/=node_modules/@openzeppelin/
solmate/=node_modules/solmate/
@uniswap/=node_modules/@uniswap/
@opengsn/=node_modules/@opengsn/
forge-std/=node_modules/forge-std/src/
ds-test/=node_modules/ds-test/src/