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 additional Foundry test coverage #322

Merged
merged 60 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
fd73e2d
chore: add Foundry initial test environment mocks
kartojal Feb 14, 2023
7aa567d
chore: remove mint at test
kartojal Feb 14, 2023
63e8085
chore: add tests and borrow fuzz to GhoVariableDebtToken
kartojal Feb 20, 2023
05df7e1
chore: add initial test engine for gho borrow
kartojal Feb 21, 2023
d43701c
chore: add percent calc function
kartojal Feb 22, 2023
55aa0ca
fix: Remove discount lock period mechanism (#293)
miguelmtzinf Feb 20, 2023
ecdbc72
fix: Optimize gho debt balanceof (#297)
miguelmtzinf Feb 20, 2023
b6ad733
fix: Simplify GhoToken.addFacilitator function (#295)
miguelmtzinf Feb 20, 2023
1dc6f09
feat: Add helper contract to manage risk params of GHO reserve (#291)
foodaka Feb 20, 2023
e878746
fix: Remove updateLockDiscountPeriod calls from GhoManager (#298)
miguelmtzinf Feb 20, 2023
1cdea12
chore: initial repay engine
kartojal Feb 27, 2023
a789362
chore: add makefile with coverage html report and ignore mocks, add r…
kartojal Mar 1, 2023
28ffe9a
chore: add 100% coverage for GhoVariableDebtToken contract
kartojal Mar 1, 2023
68d9989
chore: add GhoAToken.sol tests
kartojal Mar 1, 2023
6bc762b
fix: Stop prettier formatting dependencies and cache
Zer0dot Apr 3, 2023
f1e960b
feat: Initial flashminter setup
Zer0dot Apr 12, 2023
4ceddc3
misc: Slight optimisation
Zer0dot Apr 13, 2023
cd82952
test: Add Gho FlashMinter unit tests
Zer0dot Apr 14, 2023
402271b
test: Add flash minter unit tests
Zer0dot Apr 18, 2023
dd0314f
fix: Resolve VSCode import callback issue with forge-std/ds-test
Apr 18, 2023
501c89c
test: Add GhoAToken tests for transfer and self-rescue reverts
Apr 18, 2023
8e25323
fix: exclude foundry-test for hardhat coverage tests
Apr 18, 2023
6c2dbc2
test: Add initial GhoToken unit tests
Apr 20, 2023
3e94649
fix: remove stkAave mocks, replace with BGD repo and update impacted …
Apr 25, 2023
89d1195
Merge branch 'main' into chore/foundry-test-suite
Apr 25, 2023
c17e3ba
fix: resolved error in testUpdateDiscountTokenToZero test
Apr 25, 2023
0457b93
fix: increase node testrunner heap alloc to avoid OOM
Apr 25, 2023
66f3f14
fix: setup stkAave behind proxy
Apr 26, 2023
d319705
test: add GhoOracle unit tests
Apr 26, 2023
888ebb5
test: add GhoDiscountRateStrategy unit/fuzz tests
Apr 26, 2023
caff728
test: add GhoInterestRateStrategy fuzz test
Apr 26, 2023
6f134f0
test: add GhoManager unit tests, mocked PoolConfigurator
Apr 27, 2023
ff332a4
fix: remove unnecessary stopPranks that fail in latest forge
Apr 27, 2023
9551aa7
test: added nonce/domain sep unit tests for GhoAToken
Apr 27, 2023
dc8b27a
test: add GhoStableDebtToken unit tests
Apr 27, 2023
00e2550
feat: add combined coverage from hardhat/foundry
Apr 28, 2023
db4ffae
fix: refactor initial foundry tests
May 1, 2023
4845e84
fix: move MockFlashBorrower to common location
May 1, 2023
68ce5ec
feat: add EmptyDiscountRateStrategy fuzz test
May 1, 2023
53b46c4
feat: add UiGhoDataProvider unit tests
May 1, 2023
f268ccd
feat: complete GhoToken unit tests
May 1, 2023
c3faa88
feat: complete GhoVariableDebtToken unit tests
May 1, 2023
95d3625
feat: add last unit test for GhoVariableDebtToken
May 2, 2023
25cefe8
fix: update ordering in constant/event test files
May 2, 2023
524fb1b
Merge pull request #323 from aave/feat/320-unified-coverage-gen
May 4, 2023
e4c6aa5
Merge pull request #324 from aave/fix/321-refactor-foundry-tests
May 4, 2023
5fcdf00
fix: remove unnecessary prank on proxy init
May 4, 2023
d34d73a
fix: naming of fuzz tests to be more descriptive
May 5, 2023
ae957d0
Merge branch 'main' into feat/319-additional-foundry-test-coverage
miguelmtzinf May 10, 2023
e447d7d
fix: re-remove old tests that got re-merged
May 10, 2023
76f1b30
fix: Remove hardhat unitTests folder
miguelmtzinf May 10, 2023
432886b
fix: Fix constants value of tests
miguelmtzinf May 10, 2023
81f3e4e
test: Add couple of test cases
miguelmtzinf May 10, 2023
e410417
test: Rename test titles
miguelmtzinf May 10, 2023
e8612b7
fix: Rename EmptyDiscountRateStrategy to ZeroDiscountRateStrategy
miguelmtzinf May 10, 2023
2eb10cf
fix: Remove unneeded import
miguelmtzinf May 10, 2023
5c8a258
feat: add genhtml back to combined coverage
May 10, 2023
298153f
fix: add error messages on test reverts
May 10, 2023
b814e60
fix: Fix package scripts
miguelmtzinf May 10, 2023
230a761
fix: Fix deploy script of GhoStableDebtToken
miguelmtzinf May 10, 2023
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: 2 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ jobs:
- name: Lint check
run: 'npm run prettier:check'
- name: Test
env:
NODE_OPTIONS: '--max_old_space_size=4096'
run: 'npm run test'
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@
/temp-artifacts
/src/contracts/hardhat-dependency-compiler

.DS_Store
.DS_Store
forge-cache
/report
lcov.info
combined-lcov.info
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.3.0
[submodule "lib/aave-stk-v1-5"]
path = lib/aave-stk-v1-5
url = https://github.com/bgd-labs/aave-stk-v1-5
6 changes: 4 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

artifacts
cache
node_modules
types
out
deployments
temp-artifacts
temp-artifacts
lib
coverage
forge-cache
33 changes: 33 additions & 0 deletions combined-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

#!/bin/bash

# @dev
# This bash script creates coverage reports via Hardhat and Foundry
# and then merges them, removing uninteresting files

export NODE_OPTIONS="--max_old_space_size=8192"

set -e

npm run hardhat coverage
forge coverage --report lcov

sed -i -e 's/\/.*gho-core.//g' coverage/lcov.info

lcov \
--rc lcov_branch_coverage=1 \
--add-tracefile coverage/lcov.info \
--add-tracefile lcov.info \
--output-file merged-lcov.info

lcov \
--rc lcov_branch_coverage=1 \
--remove merged-lcov.info \
--output-file combined-lcov.info \
"*node_modules*" "*test*" "*mock*"

rm merged-lcov.info

lcov \
--rc lcov_branch_coverage=1 \
--list combined-lcov.info
15 changes: 2 additions & 13 deletions deploy/07_deploy_stakedAave_upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ZERO_ADDRESS } from './../src/helpers/constants';
import { DeployFunction } from 'hardhat-deploy/types';
import { StakedTokenV2Rev4__factory } from '../types';
import { StakedTokenV2Rev3__factory, STAKE_AAVE_PROXY, waitForTx } from '@aave/deploy-v3';

const func: DeployFunction = async function ({ getNamedAccounts, deployments, ...hre }) {
Expand All @@ -11,29 +9,20 @@ const func: DeployFunction = async function ({ getNamedAccounts, deployments, ..
const stkAaveProxy = await deployments.get(STAKE_AAVE_PROXY);
const instance = StakedTokenV2Rev3__factory.connect(stkAaveProxy.address, deployerSigner);

const stakedAaveImpl = await deploy('StakedTokenV2Rev4Impl', {
const stakedAaveImpl = await deploy('StakedAaveV3Impl', {
from: deployer,
contract: 'StakedTokenV2Rev4',
contract: 'StakedAaveV3',
args: [
await instance.STAKED_TOKEN(),
await instance.REWARD_TOKEN(),
await instance.COOLDOWN_SECONDS(),
await instance.UNSTAKE_WINDOW(),
await instance.REWARDS_VAULT(),
await instance.EMISSION_MANAGER(),
'3153600000', // 100 years from the time of deployment
await instance.name(),
await instance.symbol(),
await instance.decimals(),
await instance._aaveGovernance(),
],
log: true,
});
console.log(`stakedAaveImpl Logic: ${stakedAaveImpl.address}`);

// Initialize implementation
const impl = await StakedTokenV2Rev4__factory.connect(stakedAaveImpl.address, deployerSigner);
await waitForTx(await impl.initialize(ZERO_ADDRESS));
};

func.id = 'StkAaveUpgrade';
Expand Down
20 changes: 20 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[profile.default]
src = 'src/contracts'
out = 'out'
test = 'src/contracts/test'
cache_path = 'forge-cache'
libs = ["node_modules", "lib"]
remappings = [
'@aave/=node_modules/@aave/',
'@aave/core-v3/=node_modules/@aave/core-v3',
'@aave/periphery-v3/=node_modules/@aave/periphery-v3',
'@openzeppelin/=node_modules/@openzeppelin/',
'aave-stk-v1-5/=lib/aave-stk-v1-5/',
'ds-test/=lib/forge-std/lib/ds-test/src/',
'eth-gas-reporter/=node_modules/eth-gas-reporter/',
'forge-std/=lib/forge-std/src/',
'hardhat-deploy/=node_modules/hardhat-deploy/',
'hardhat/=node_modules/hardhat/',
]

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
3 changes: 3 additions & 0 deletions hardhat-remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
aave-stk-v1-5/=lib/aave-stk-v1-5/
22 changes: 21 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { getCommonNetworkConfig, hardhatNetworkSettings } from './src/helpers/hardhat-config';
import {
getCommonNetworkConfig,
getRemappings,
hardhatNetworkSettings,
} from './src/helpers/hardhat-config';
import { config } from 'dotenv';
import { HardhatUserConfig } from 'hardhat/types';
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from 'hardhat/builtin-tasks/task-names';
Expand All @@ -9,6 +13,7 @@ import 'hardhat-deploy';
import 'hardhat-contract-sizer';
import 'hardhat-dependency-compiler';
import 'hardhat-tracer';
import 'hardhat-preprocessor';

config();

Expand Down Expand Up @@ -165,6 +170,21 @@ const hardhatConfig: HardhatUserConfig = {
tracer: {
nameTags: {},
},
preprocess: {
eachLine: (hre) => ({
transform: (line: string) => {
if (line.match(/^\s*import /i)) {
for (const [from, to] of getRemappings()) {
if (line.includes(from)) {
line = line.replace(from, to);
break;
}
}
}
return line;
},
}),
},
};

export default hardhatConfig;
1 change: 1 addition & 0 deletions lib/aave-stk-v1-5
Submodule aave-stk-v1-5 added at 0348eb
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 066ff1
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
"prepare": "husky install",
"compile": "rm -rf ./artifacts ./cache ./types && SKIP_LOAD=true hardhat compile",
"test": ". ./setup-test-env.sh && hardhat test ./src/test/*.ts ./src/test/**/*.ts",
"forge-test": "forge test -vvv --no-match-test 'skip'",
"test-goerli:fork": ". ./setup-test-env.sh && FORK=goerli npm run test --no-compile",
"test-goerli:fork:skip-deploy": ". ./setup-test-env.sh && FORK=goerli SKIP_DEPLOY=true npm run test",
"test:stkAave": ". ./setup-test-env.sh && hardhat test ./src/test/__setup.test.ts ./src/test/stkAave-upgrade.test.ts",
"test-unit": ". ./setup-test-env.sh && hardhat test ./src/test/unitTests/*.ts",
"coverage": ". ./setup-test-env.sh && hardhat coverage",
"combined-coverage": ". ./setup-test-env.sh && ./combined-coverage.sh",
"deploy-testnet": ". ./setup-test-env.sh && hardhat deploy-and-setup",
"deploy-testnet:goerli": "HARDHAT_NETWORK=goerli npm run deploy-testnet",
"deploy-testnet:goerli:fork": "FORK=goerli npm run deploy-testnet",
Expand Down Expand Up @@ -57,6 +59,7 @@
"hardhat-dependency-compiler": "^1.1.3",
"hardhat-deploy": "^0.11.22",
"hardhat-gas-reporter": "^1.0.9",
"hardhat-preprocessor": "^0.1.5",
"hardhat-tracer": "^1.2.1",
"husky": "^8.0.3",
"jsondiffpatch": "^0.4.1",
Expand Down
Loading