Skip to content

Commit

Permalink
test: Add additional Foundry test coverage (#322)
Browse files Browse the repository at this point in the history
* chore: add Foundry initial test environment mocks

* chore: remove mint at test

* chore: add tests and borrow fuzz to GhoVariableDebtToken

* chore: add initial test engine for gho borrow

* chore: add percent calc function

* fix: Remove discount lock period mechanism (#293)

* fix: remove discount lock period from GhoDebtToken

* test: Update tests for new rebalance behaviour

* fix: Optimize gho debt balanceof (#297)

* fix: Simplify GhoToken.addFacilitator function (#295)

* fix: Remove Facilitator struct from addFacilitator function

* test: Adjusts test for new addFacilitator parameters

* fix: Make facilitatorLabel calldata-like parameter

* feat: Add helper contract to manage risk params of GHO reserve (#291)

* setup modifier

* setup gho manager and tests

* remove atoken changes

* use interfaces

* adds test for ghomanager as pooladmin

* fix: Remove updateLockDiscountPeriod calls from GhoManager (#298)

* chore: initial repay engine

* chore: add makefile with coverage html report and ignore mocks, add rebalance discount tests and onbehalf borrow

* chore: add 100% coverage for GhoVariableDebtToken contract

* chore: add GhoAToken.sol tests

* fix: Stop prettier formatting dependencies and cache

* feat: Initial flashminter setup

* misc: Slight optimisation

* test: Add Gho FlashMinter unit tests

* test: Add flash minter unit tests

* fix: Resolve VSCode import callback issue with forge-std/ds-test

* test: Add GhoAToken tests for transfer and self-rescue reverts

* fix: exclude foundry-test for hardhat coverage tests

* test: Add initial GhoToken unit tests

* fix: remove stkAave mocks, replace with BGD repo and update impacted tests

* fix: resolved error in testUpdateDiscountTokenToZero test

* fix: increase node testrunner heap alloc to avoid OOM

* fix: setup stkAave behind proxy

* test: add GhoOracle unit tests

* test: add GhoDiscountRateStrategy unit/fuzz tests

* test: add GhoInterestRateStrategy fuzz test

* test: add GhoManager unit tests, mocked PoolConfigurator

* fix: remove unnecessary stopPranks that fail in latest forge

* test: added nonce/domain sep unit tests for GhoAToken

* test: add GhoStableDebtToken unit tests

* feat: add combined coverage from hardhat/foundry

* fix: refactor initial foundry tests

* fix: move MockFlashBorrower to common location

* feat: add EmptyDiscountRateStrategy fuzz test

* feat: add UiGhoDataProvider unit tests

* feat: complete GhoToken unit tests

* feat: complete GhoVariableDebtToken unit tests

* feat: add last unit test for GhoVariableDebtToken

* fix: update ordering in constant/event test files

* fix: remove unnecessary prank on proxy init

* fix: naming of fuzz tests to be more descriptive

* fix: re-remove old tests that got re-merged

* fix: Remove hardhat unitTests folder

* fix: Fix constants value of tests

* test: Add couple of test cases

* test: Rename test titles

* fix: Rename EmptyDiscountRateStrategy to ZeroDiscountRateStrategy

* fix: Remove unneeded import

* feat: add genhtml back to combined coverage

* fix: add error messages on test reverts

* fix: Fix package scripts

* fix: Fix deploy script of GhoStableDebtToken

---------

Co-authored-by: David Racero <[email protected]>
Co-authored-by: miguelmtz <[email protected]>
Co-authored-by: Mark Hinschberger <[email protected]>
Co-authored-by: Zer0dot <[email protected]>
Co-authored-by: miguelmtzinf <[email protected]>
  • Loading branch information
6 people authored May 10, 2023
1 parent 639031f commit 31eccec
Show file tree
Hide file tree
Showing 32 changed files with 1,241 additions and 527 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
.DS_Store
forge-cache
/report
lcov.info
lcov.info
combined-lcov.info
4 changes: 0 additions & 4 deletions Makefile

This file was deleted.

35 changes: 35 additions & 0 deletions combined-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

#!/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

genhtml ./combined-lcov.info -o report --branch-coverage
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[profile.default]
src = 'src/contracts'
out = 'out'
test = 'src/contracts/foundry-test'
test = 'src/contracts/test'
cache_path = 'forge-cache'
libs = ["node_modules", "lib"]
remappings = [
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"prettier:write": "prettier --write .",
"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",
"test": ". ./setup-test-env.sh && NODE_OPTIONS=--max-old-space-size=4096 hardhat test ./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",
"test:stkAave": ". ./setup-test-env.sh && NODE_OPTIONS=--max-old-space-size=4096 hardhat test ./src/test/__setup.test.ts ./src/test/stkAave-upgrade.test.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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ pragma solidity ^0.8.10;

import {IGhoDiscountRateStrategy} from '../interestStrategy/interfaces/IGhoDiscountRateStrategy.sol';

contract EmptyDiscountRateStrategy is IGhoDiscountRateStrategy {
/**
* @title ZeroDiscountRateStrategy
* @author Aave
* @notice Discount Rate Strategy that always return zero discount rate.
*/
contract ZeroDiscountRateStrategy is IGhoDiscountRateStrategy {
/**
* @dev Calculates the interest rates depending on the reserve's state and configurations
* @param debtBalance The address of the reserve
Expand Down
137 changes: 0 additions & 137 deletions src/contracts/foundry-test/TestEnv.sol

This file was deleted.

Loading

0 comments on commit 31eccec

Please sign in to comment.