-
Notifications
You must be signed in to change notification settings - Fork 322
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
Increase coverage #149
Merged
Merged
Increase coverage #149
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3854a5c
contracts: Increase StabilityPool test coverage
bingen e955e32
contracts: Increase SortedTroves coverage
bingen 3ed5c9d
contracts: revert if reinserting a trove with zero ICR
bingen 9d1b7f0
contracts: Increase DefaultPool coverage
bingen e2d527f
contracts: Rename MultiCDPGetter to MultiTroveGetter
bingen e2618fc
contracts: Enhance NonPayable mock contract
bingen 98b7816
fixup! contracts: Increase DefaultPool coverage
bingen fb2025e
contracts: Increase coverage for SortedTroves
bingen b44e340
contracts: Tweak coverage config file
bingen ef045fc
contracts: Increase coverage for LiquityMath
bingen 8fe4268
contracts: Increase coverage for LiquitySafeMath128
bingen 3be6c28
contracts: Fix SortedTroves test title
bingen 12413d3
Revert "contracts: Increase coverage for LiquityMath"
bingen 4e8aa16
contracts: Increase coverage for LUSDToken
bingen 3878f32
contracts: Fix solcover accounts conf
bingen c0fdb88
contracts: Increase LUSDToken coverage
bingen a7dfc07
contracts: Undo SortedTroves.sol changes
bingen 7bb81a5
contracts: Undo LUSDToken.sol changes
bingen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/contracts/contracts/TestContracts/LiquitySafeMath128Tester.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.6.11; | ||
|
||
import "../Dependencies/LiquitySafeMath128.sol"; | ||
|
||
/* Tester contract for math functions in LiquitySafeMath128.sol library. */ | ||
|
||
contract LiquitySafeMath128Tester { | ||
using LiquitySafeMath128 for uint128; | ||
|
||
function add(uint128 a, uint128 b) external pure returns (uint128) { | ||
return a.add(b); | ||
} | ||
|
||
function sub(uint128 a, uint128 b) external pure returns (uint128) { | ||
return a.sub(b); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/contracts/contracts/TestContracts/SortedTrovesTester.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.6.11; | ||
|
||
import "../Interfaces/ISortedTroves.sol"; | ||
|
||
|
||
contract SortedTrovesTester { | ||
ISortedTroves sortedTroves; | ||
|
||
function setSortedTroves(address _sortedTrovesAddress) external { | ||
sortedTroves = ISortedTroves(_sortedTrovesAddress); | ||
} | ||
|
||
function insert(address _id, uint256 _ICR, uint _price, address _prevId, address _nextId) external { | ||
sortedTroves.insert(_id, _ICR, _price, _prevId, _nextId); | ||
} | ||
|
||
function remove(address _id) external { | ||
sortedTroves.remove(_id); | ||
} | ||
|
||
function reInsert(address _id, uint256 _newICR, uint _price, address _prevId, address _nextId) external { | ||
sortedTroves.reInsert(_id, _newICR, _price, _prevId, _nextId); | ||
} | ||
|
||
function getCurrentICR(address, uint) external pure returns (uint) { | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const testHelpers = require("../utils/testHelpers.js") | ||
const DefaultPool = artifacts.require("./DefaultPool.sol"); | ||
const NonPayable = artifacts.require('NonPayable.sol') | ||
|
||
const th = testHelpers.TestHelper | ||
const dec = th.dec | ||
|
||
contract('DefaultPool', async accounts => { | ||
let defaultPool | ||
let nonPayable | ||
|
||
let [owner] = accounts | ||
|
||
beforeEach('Deploy contracts', async () => { | ||
defaultPool = await DefaultPool.new() | ||
nonPayable = await NonPayable.new() | ||
await defaultPool.setAddresses(owner, owner) | ||
}) | ||
|
||
it('sendETH(): fails if receiver cannot receive ETH', async () => { | ||
const amount = dec(1, 'ether') | ||
|
||
await web3.eth.sendTransaction({ to: defaultPool.address, from: owner, value: amount }) | ||
|
||
await th.assertRevert(defaultPool.sendETH(nonPayable.address, amount, { from: owner }), 'DefaultPool: sending ETH failed') | ||
}) | ||
}) | ||
|
||
contract('Reset chain state', async accounts => { }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const testHelpers = require("../utils/testHelpers.js") | ||
const th = testHelpers.TestHelper | ||
|
||
const LiquitySafeMath128Tester = artifacts.require("LiquitySafeMath128Tester") | ||
|
||
contract('LiquitySafeMath128Tester', async accounts => { | ||
let mathTester | ||
|
||
beforeEach(async () => { | ||
mathTester = await LiquitySafeMath128Tester.new() | ||
}) | ||
|
||
it('add(): reverts if overflows', async () => { | ||
const MAX_UINT_128 = th.toBN(2).pow(th.toBN(128)).sub(th.toBN(1)) | ||
await th.assertRevert(mathTester.add(MAX_UINT_128, 1), 'LiquitySafeMath128: addition overflow') | ||
}) | ||
|
||
it('sub(): reverts if underflows', async () => { | ||
await th.assertRevert(mathTester.sub(1, 2), 'LiquitySafeMath128: subtraction overflow') | ||
}) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm does this revert because
defaultPool.sendETH
is only callableTroveManager
though? If so, it wouldn't hit the final_require(success, ...)
that we want to test hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, but no, because
owner
is theTroveManager
here 😉 :https://github.com/liquity/dev/pull/149/files#diff-ff756b67b4b4fded33dc971414822ef458d9dc958a1ee0bb38f11c99d6fc4daaR17
Anyway, this highlights again the importance of revert messages. While testing these PRs I restore the message check in testHelpers, but I may forget it sometimes. Hopefully we can have issue #99 fixed soon! 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, I see. Nice.
Definitely, thanks!