Skip to content

Commit

Permalink
Merge pull request #651 from liquity/fix_coverage
Browse files Browse the repository at this point in the history
Fix coverage
  • Loading branch information
bingen authored Dec 13, 2024
2 parents 7b11776 + a6bb9cb commit f8e21ae
Show file tree
Hide file tree
Showing 105 changed files with 197 additions and 201 deletions.
82 changes: 37 additions & 45 deletions .github/workflows/contracts-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ jobs:
NODE_OPTIONS: --max-old-space-size=4096

coverage:
if: false
name: Coverage
runs-on: ubuntu-latest
continue-on-error: true
Expand Down Expand Up @@ -136,61 +135,54 @@ jobs:
- name: Install lcov
run: sudo apt-get -y install lcov

#- name: Filter out tests from coverage
# run: |
# lcov --remove lcov_foundry.info -o lcov_foundry.info 'src/test/*'

# Hardhat
- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 8

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache: "pnpm"
cache-dependency-path: "pnpm-lock.yaml"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: harhdat coverage
run: pnpm coverage
continue-on-error: true
timeout-minutes: 30
env:
NODE_OPTIONS: --max-old-space-size=8192
# - name: Install pnpm
# uses: pnpm/[email protected]
# with:
# version: 8

# - name: Install Node.js
# uses: actions/setup-node@v4
# with:
# node-version-file: ".node-version"
# cache: "pnpm"
# cache-dependency-path: "pnpm-lock.yaml"

# - name: Install dependencies
# run: pnpm install --frozen-lockfile

# - name: harhdat coverage
# run: pnpm coverage
# continue-on-error: true
# timeout-minutes: 30
# env:
# NODE_OPTIONS: --max-old-space-size=8192

# Merge
- name: ls
run: |
ls && ls coverage
- name: Remove path from contract names in Hardhat
run: |
sed -i "s/SF:.*src/SF:src/g" coverage/lcov.info
- name: Merge coverage reports
# - name: Remove path from contract names in Hardhat
# run: |
# sed -i "s/SF:.*src/SF:src/g" coverage/lcov.info

# - name: Merge coverage reports
# run: |
# lcov \
# --rc lcov_branch_coverage=1 \
# --add-tracefile lcov_foundry.info \
# --add-tracefile coverage/lcov.info \
# --output-file lcov_merged.info

# Instead of merge
- name: Rename coverage file
run: |
lcov \
--rc lcov_branch_coverage=1 \
--add-tracefile lcov_foundry.info \
--add-tracefile coverage/lcov.info \
--output-file lcov_merged.info
mv lcov_foundry.info lcov_merged.info
# Filter
- name: Filter out tests from coverage
- name: Filter out from coverage
run: |
lcov --remove lcov_merged.info -o lcov_merged.info \
'src/test/*' \
'src/TestContracts/*' \
'src/OldTestContracts/*' \
'src/Dependencies/*' \
'src/Interfaces/*' \
'src/Types/*' \
'src/scripts/*' \
'src/MultiTroveGetter.sol' \
'src/deployment.sol'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract AnchoredSPInvariantsTest is DevTestSetup {
priceFeed: contracts.priceFeed,
stabilityPool: contracts.stabilityPool,
troveManager: contracts.troveManager,
collSurplusPool: contracts.collSurplusPool
collSurplusPool: contracts.pools.collSurplusPool
}),
hintHelpers
);
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ pragma solidity 0.8.24;
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol";
import {Math} from "openzeppelin-contracts/contracts/utils/math/Math.sol";
import {BatchId} from "../Types/BatchId.sol";
import {LatestBatchData} from "../Types/LatestBatchData.sol";
import {LatestTroveData} from "../Types/LatestTroveData.sol";
import {ISortedTroves} from "../Interfaces/ISortedTroves.sol";
import {IStabilityPool} from "../Interfaces/IStabilityPool.sol";
import {ITroveManager} from "../Interfaces/ITroveManager.sol";
import {BatchId} from "src/Types/BatchId.sol";
import {LatestBatchData} from "src/Types/LatestBatchData.sol";
import {LatestTroveData} from "src/Types/LatestTroveData.sol";
import {ISortedTroves} from "src/Interfaces/ISortedTroves.sol";
import {IStabilityPool} from "src/Interfaces/IStabilityPool.sol";
import {ITroveManager} from "src/Interfaces/ITroveManager.sol";
import {BatchIdSet} from "./Utils/BatchIdSet.sol";
import {Logging} from "./Utils/Logging.sol";
import {StringFormatting} from "./Utils/StringFormatting.sol";
Expand Down Expand Up @@ -134,9 +134,9 @@ contract InvariantsTest is Assertions, Logging, BaseInvariantTest, BaseMultiColl
36,
"Wrong batch management fee accrual"
);
assertEqDecimal(weth.balanceOf(address(c.gasPool)), handler.getGasPool(i), 18, "Wrong GasPool");
assertEqDecimal(weth.balanceOf(address(c.pools.gasPool)), handler.getGasPool(i), 18, "Wrong GasPool");
assertApproxEqAbsDecimal(
c.collSurplusPool.getCollBalance(), handler.collSurplus(i), 10, 18, "Wrong CollSurplusPool"
c.pools.collSurplusPool.getCollBalance(), handler.collSurplus(i), 10, 18, "Wrong CollSurplusPool"
);
assertApproxEqAbsDecimal(
c.stabilityPool.getTotalBoldDeposits(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

pragma solidity 0.8.24;

import "../PriceFeeds/WSTETHPriceFeed.sol";
import "../PriceFeeds/MainnetPriceFeedBase.sol";
import "../PriceFeeds/RETHPriceFeed.sol";
import "../PriceFeeds/WETHPriceFeed.sol";
import "src/PriceFeeds/WSTETHPriceFeed.sol";
import "src/PriceFeeds/MainnetPriceFeedBase.sol";
import "src/PriceFeeds/RETHPriceFeed.sol";
import "src/PriceFeeds/WETHPriceFeed.sol";

import "./TestContracts/Accounts.sol";
import "./TestContracts/ChainlinkOracleMock.sol";
import "./TestContracts/RETHTokenMock.sol";
import "./TestContracts/WSTETHTokenMock.sol";
import "./TestContracts/Deployment.t.sol";

import "../Dependencies/AggregatorV3Interface.sol";
import "../Interfaces/IRETHPriceFeed.sol";
import "../Interfaces/IWSTETHPriceFeed.sol";
import "src/Dependencies/AggregatorV3Interface.sol";
import "src/Interfaces/IRETHPriceFeed.sol";
import "src/Interfaces/IWSTETHPriceFeed.sol";

import "../Interfaces/IRETHToken.sol";
import "../Interfaces/IWSTETH.sol";
import "src/Interfaces/IRETHToken.sol";
import "src/Interfaces/IWSTETH.sol";

import "forge-std/Test.sol";
import "lib/forge-std/src/console2.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {IBoldToken} from "../Interfaces/IBoldToken.sol";
import {IStabilityPool} from "../Interfaces/IStabilityPool.sol";
import {HintHelpers} from "../HintHelpers.sol";
import {IBoldToken} from "src/Interfaces/IBoldToken.sol";
import {IStabilityPool} from "src/Interfaces/IStabilityPool.sol";
import {HintHelpers} from "src/HintHelpers.sol";
import {Assertions} from "./TestContracts/Assertions.sol";
import {BaseInvariantTest} from "./TestContracts/BaseInvariantTest.sol";
import {TestDeployer} from "./TestContracts/Deployment.t.sol";
Expand All @@ -29,7 +29,7 @@ contract SPInvariantsTest is Assertions, BaseInvariantTest {
priceFeed: contracts.priceFeed,
stabilityPool: contracts.stabilityPool,
troveManager: contracts.troveManager,
collSurplusPool: contracts.collSurplusPool
collSurplusPool: contracts.pools.collSurplusPool
}),
hintHelpers
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity 0.8.24;

import "forge-std/Test.sol";
import "../SortedTroves.sol";
import "../AddressesRegistry.sol";
import "../Types/TroveId.sol";
import "src/SortedTroves.sol";
import "src/AddressesRegistry.sol";
import "src/Types/TroveId.sol";

uint256 constant FUZZ_INPUT_LENGTH = 9;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import "../../Dependencies/AddRemoveManagers.sol";
import "src/Dependencies/AddRemoveManagers.sol";

contract AddRemoveManagersTester is AddRemoveManagers {
constructor(IAddressesRegistry _addressesRegistry) AddRemoveManagers(_addressesRegistry) {}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
pragma solidity 0.8.24;

import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {IBoldToken} from "../../Interfaces/IBoldToken.sol";
import {ICollateralRegistry} from "../../Interfaces/ICollateralRegistry.sol";
import {IWETH} from "../../Interfaces/IWETH.sol";
import {HintHelpers} from "../../HintHelpers.sol";
import {IBoldToken} from "src/Interfaces/IBoldToken.sol";
import {ICollateralRegistry} from "src/Interfaces/ICollateralRegistry.sol";
import {IWETH} from "src/Interfaces/IWETH.sol";
import {HintHelpers} from "src/HintHelpers.sol";
import {TestDeployer} from "./Deployment.t.sol";

contract BaseMultiCollateralTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
pragma solidity 0.8.24;

import "./Accounts.sol";
import "../../Interfaces/IActivePool.sol";
import "../../Interfaces/IBoldToken.sol";
import "../../Interfaces/ICollSurplusPool.sol";
import "../../Interfaces/IDefaultPool.sol";
import "../../Interfaces/IPriceFeed.sol";
import "../../Interfaces/ISortedTroves.sol";
import "../../Interfaces/IStabilityPool.sol";
import "src/Interfaces/IActivePool.sol";
import "src/Interfaces/IBoldToken.sol";
import "src/Interfaces/ICollSurplusPool.sol";
import "src/Interfaces/IDefaultPool.sol";
import "src/Interfaces/IPriceFeed.sol";
import "src/Interfaces/ISortedTroves.sol";
import "src/Interfaces/IStabilityPool.sol";
import "./BorrowerOperationsTester.t.sol";
import "./TroveManagerTester.t.sol";
import "../../Interfaces/ICollateralRegistry.sol";
import "src/Interfaces/ICollateralRegistry.sol";
import "./PriceFeedTestnet.sol";
import "../../Interfaces/IInterestRouter.sol";
import "../../GasPool.sol";
import "../../HintHelpers.sol";
import "../../Zappers/WETHZapper.sol";
import "../../Zappers/GasCompZapper.sol";
import "../../Zappers/LeverageLSTZapper.sol";
import "src/Interfaces/IInterestRouter.sol";
import "src/GasPool.sol";
import "src/HintHelpers.sol";
import "src/Zappers/WETHZapper.sol";
import "src/Zappers/GasCompZapper.sol";
import "src/Zappers/LeverageLSTZapper.sol";
import {mulDivCeil} from "../Utils/Math.sol";
import {Logging} from "../Utils/Logging.sol";
import {StringFormatting} from "../Utils/StringFormatting.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity 0.8.24;

import "../../BoldToken.sol";
import "src/BoldToken.sol";

contract BoldTokenTester is BoldToken {
constructor(address _owner) BoldToken(_owner) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pragma solidity 0.8.24;

import "../../Interfaces/IAddressesRegistry.sol";
import "../../BorrowerOperations.sol";
import "src/Interfaces/IAddressesRegistry.sol";
import "src/BorrowerOperations.sol";
import "./Interfaces/IBorrowerOperationsTester.sol";

/* Tester contract inherits from BorrowerOperations, and provides external functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity 0.8.24;

import "../../Dependencies/AggregatorV3Interface.sol";
import "src/Dependencies/AggregatorV3Interface.sol";

// Mock Chainlink oracle that returns a stale price answer.
// this contract code is etched over mainnet oracle addresses in mainnet fork tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity 0.8.24;

import "../../CollateralRegistry.sol";
import "src/CollateralRegistry.sol";

/* Tester contract inherits from CollateralRegistry, and provides external functions
for testing the parent's internal functions. */
Expand Down
Loading

0 comments on commit f8e21ae

Please sign in to comment.