Skip to content

Commit

Permalink
Merge pull request #68 from liquity/old_tests_initial_fix_2
Browse files Browse the repository at this point in the history
Initial fixes for old tests (deployment setup, ripping out fees, "LUSD" -> "Bold", etc) (2)
  • Loading branch information
RickGriff committed Feb 1, 2024
2 parents 6607ae8 + 376855d commit 0a8219a
Show file tree
Hide file tree
Showing 30 changed files with 6,764 additions and 12,897 deletions.
134 changes: 92 additions & 42 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
name: Foundry tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -48,14 +48,58 @@ jobs:
forge test -vvv
id: test

coverage-foundry:
name: Foundry coverage
console-logs:
name: Check we didn’t forget to remove console imports
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Git checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Check console imports
working-directory: contracts
run: >-
! grep -R console src | grep import | grep -v "://" | grep -v TestContracts | grep -v ExternalContracts | grep -v "\.t\.sol"
test-hardhat:
name: Hardhat tests
runs-on: ubuntu-latest

steps:
- name: Git checkout
uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-node@v3
with:
node-version: 16

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

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Test contracts
run: yarn test

coverage:
name: Coverage
runs-on: ubuntu-latest
continue-on-error: true

steps:
- name: Git checkout
uses: actions/checkout@v4
with:
submodules: recursive

# Foundry
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand All @@ -69,57 +113,63 @@ jobs:

- name: Run Forge coverage
run: |
forge coverage --report lcov
forge coverage --report lcov --report-file lcov_foundry.info
id: coverage

- 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/*'
# id: coverage_filter

# Hardhat
- uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
cache-dependency-path: "./contracts/yarn.lock"
env:
# Workaround for https://github.com/actions/setup-node/issues/317
FORCE_COLOR: 0

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

- name: harhdat coverage
run: yarn coverage
continue-on-error: true
env:
NODE_OPTIONS: --max-old-space-size=4096

# Merge
- name: Merge coverage reports
id: coverage_merge
run: |
lcov \
--rc lcov_branch_coverage=1 \
--add-tracefile lcov_foundry.info \
--add-tracefile coverage/lcov.info \
--output-file lcov_merged.info
# Filter
- name: Filter out tests from coverage
run: |
lcov --remove lcov.info -o lcov.info 'src/test/*'
lcov --remove lcov_merged.info -o lcov_merged.info \
'src/test/*' \
'src/TestContracts/*' \
'src/OldTestContracts/*' \
'src/Dependencies/*' \
'src/Interfaces/*'
id: coverage_filter

# Send to coveralls
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: ./contracts/
# Potential improvement to include merge with hardhat tests: https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/e91c3100c29d2913d175df4b3d1790d6a057d36e/solidity/coverage.sh
path-to-lcov: ./contracts/lcov.info
path-to-lcov: ./contracts/lcov_merged.info
debug: true

console-logs:
name: Check we didn’t forget to remove console imports
runs-on: ubuntu-latest

steps:
- name: Git checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Check console imports
working-directory: contracts
run: >-
! grep -R console src | grep import | grep -v "://" | grep -v TestContracts | grep -v ExternalContracts | grep -v "\.t\.sol"
test-hardhat:
name: Hardhat tests
runs-on: ubuntu-latest

steps:
- name: Git checkout
uses: actions/checkout@v3
with:
submodules: recursive

- uses: actions/setup-node@v3
with:
node-version: 16

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

- name: Test contracts
run: yarn test
34 changes: 0 additions & 34 deletions contracts/.github/workflows/test.yml

This file was deleted.

3 changes: 2 additions & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"lib": "lib"
},
"scripts": {
"test": "hardhat test"
"test": "hardhat test",
"coverage": "hardhat coverage"
},
"repository": {
"type": "git",
Expand Down
15 changes: 3 additions & 12 deletions contracts/src/BorrowerOperations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import "./Interfaces/ITroveManager.sol";
import "./Interfaces/IBoldToken.sol";
import "./Interfaces/ICollSurplusPool.sol";
import "./Interfaces/ISortedTroves.sol";
import "./Interfaces/ILQTYStaking.sol";
import "./Dependencies/LiquityBase.sol";
import "./Dependencies/Ownable.sol";
import "./Dependencies/CheckContract.sol";

//import "forge-std/console.sol";
// import "forge-std/console.sol";


contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOperations {
Expand All @@ -28,9 +27,6 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe

ICollSurplusPool collSurplusPool;

ILQTYStaking public lqtyStaking;
address public lqtyStakingAddress;

IBoldToken public boldToken;

// A doubly linked list of Troves, sorted by their collateral ratios
Expand Down Expand Up @@ -89,7 +85,6 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe
event PriceFeedAddressChanged(address _newPriceFeedAddress);
event SortedTrovesAddressChanged(address _sortedTrovesAddress);
event BoldTokenAddressChanged(address _boldTokenAddress);
event LQTYStakingAddressChanged(address _lqtyStakingAddress);

event TroveCreated(address indexed _borrower, uint arrayIndex);
event TroveUpdated(address indexed _borrower, uint _debt, uint _coll, uint stake, BorrowerOperation operation);
Expand All @@ -106,8 +101,7 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe
address _collSurplusPoolAddress,
address _priceFeedAddress,
address _sortedTrovesAddress,
address _boldTokenAddress,
address _lqtyStakingAddress
address _boldTokenAddress
)
external
override
Expand Down Expand Up @@ -135,9 +129,7 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe
priceFeed = IPriceFeed(_priceFeedAddress);
sortedTroves = ISortedTroves(_sortedTrovesAddress);
boldToken = IBoldToken(_boldTokenAddress);
lqtyStakingAddress = _lqtyStakingAddress;
lqtyStaking = ILQTYStaking(_lqtyStakingAddress);


emit TroveManagerAddressChanged(_troveManagerAddress);
emit ActivePoolAddressChanged(_activePoolAddress);
emit DefaultPoolAddressChanged(_defaultPoolAddress);
Expand All @@ -147,7 +139,6 @@ contract BorrowerOperations is LiquityBase, Ownable, CheckContract, IBorrowerOpe
emit PriceFeedAddressChanged(_priceFeedAddress);
emit SortedTrovesAddressChanged(_sortedTrovesAddress);
emit BoldTokenAddressChanged(_boldTokenAddress);
emit LQTYStakingAddressChanged(_lqtyStakingAddress);

_renounceOwnership();
}
Expand Down
3 changes: 1 addition & 2 deletions contracts/src/Interfaces/IBorrowerOperations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ interface IBorrowerOperations is ILiquityBase {
address _collSurplusPoolAddress,
address _priceFeedAddress,
address _sortedTrovesAddress,
address _boldTokenAddress,
address _lqtyStakingAddress
address _boldTokenAddress
) external;

function openTrove(uint _maxFee, uint _boldAmount, address _upperHint, address _lowerHint) external payable;
Expand Down
9 changes: 1 addition & 8 deletions contracts/src/Interfaces/ITroveManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import "./ILiquityBase.sol";
import "./IStabilityPool.sol";
import "./IBoldToken.sol";
import "./ISortedTroves.sol";
import "./ILQTYToken.sol";
import "./ILQTYStaking.sol";


// Common interface for the Trove Manager.
interface ITroveManager is ILiquityBase {
Expand All @@ -21,15 +18,11 @@ interface ITroveManager is ILiquityBase {
address _collSurplusPoolAddress,
address _priceFeedAddress,
address _boldTokenAddress,
address _sortedTrovesAddress,
address _lqtyTokenAddress,
address _lqtyStakingAddress
address _sortedTrovesAddress
) external;

function stabilityPool() external view returns (IStabilityPool);
function boldToken() external view returns (IBoldToken);
function lqtyToken() external view returns (ILQTYToken);
function lqtyStaking() external view returns (ILQTYStaking);
function sortedTroves() external view returns(ISortedTroves);
function borrowerOperationsAddress() external view returns (address);

Expand Down
Loading

0 comments on commit 0a8219a

Please sign in to comment.