-
Notifications
You must be signed in to change notification settings - Fork 46
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 basic dev test setup #59
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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
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,7 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.18; | ||
|
||
interface IGasPool { | ||
// empty | ||
} |
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
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
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,16 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.18; | ||
|
||
import "../ActivePool.sol"; | ||
|
||
contract ActivePoolTester is ActivePool { | ||
|
||
function unprotectedIncreaseBoldDebt(uint _amount) external { | ||
boldDebt = boldDebt + _amount; | ||
} | ||
|
||
function unprotectedPayable() external payable { | ||
ETH = ETH + msg.value; | ||
} | ||
} |
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 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.18; | ||
|
||
import "../Interfaces/IBoldToken.sol"; | ||
|
||
contract BoldTokenCaller { | ||
IBoldToken Bold; | ||
|
||
function setBold(IBoldToken _bold) external { | ||
Bold = _bold; | ||
} | ||
|
||
function boldMint(address _account, uint _amount) external { | ||
Bold.mint(_account, _amount); | ||
} | ||
|
||
function boldBurn(address _account, uint _amount) external { | ||
Bold.burn(_account, _amount); | ||
} | ||
|
||
function boldSendToPool(address _sender, address _poolAddress, uint256 _amount) external { | ||
Bold.sendToPool(_sender, _poolAddress, _amount); | ||
} | ||
|
||
function boldReturnFromPool(address _poolAddress, address _receiver, uint256 _amount ) external { | ||
Bold.returnFromPool(_poolAddress, _receiver, _amount); | ||
} | ||
} |
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,66 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.18; | ||
|
||
import "../BoldToken.sol"; | ||
|
||
contract BoldTokenTester is BoldToken { | ||
|
||
bytes32 private immutable _PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; | ||
|
||
constructor( | ||
address _troveManagerAddress, | ||
address _stabilityPoolAddress, | ||
address _borrowerOperationsAddress | ||
) public BoldToken(_troveManagerAddress, | ||
_stabilityPoolAddress, | ||
_borrowerOperationsAddress) {} | ||
|
||
function unprotectedMint(address _account, uint256 _amount) external { | ||
// No check on caller here | ||
|
||
_mint(_account, _amount); | ||
} | ||
|
||
function unprotectedBurn(address _account, uint _amount) external { | ||
// No check on caller here | ||
|
||
_burn(_account, _amount); | ||
} | ||
|
||
function unprotectedSendToPool(address _sender, address _poolAddress, uint256 _amount) external { | ||
// No check on caller here | ||
|
||
_transfer(_sender, _poolAddress, _amount); | ||
} | ||
|
||
function unprotectedReturnFromPool(address _poolAddress, address _receiver, uint256 _amount ) external { | ||
// No check on caller here | ||
|
||
_transfer(_poolAddress, _receiver, _amount); | ||
} | ||
|
||
function callInternalApprove(address owner, address spender, uint256 amount) external returns (bool) { | ||
_approve(owner, spender, amount); | ||
} | ||
|
||
function getChainId() external view returns (uint256 chainID) { | ||
//return _chainID(); // it’s private | ||
assembly { | ||
chainID := chainid() | ||
} | ||
} | ||
|
||
function getDigest(address owner, address spender, uint amount, uint nonce, uint deadline) external view returns (bytes32) { | ||
return keccak256(abi.encodePacked( | ||
uint16(0x1901), | ||
domainSeparator(), | ||
keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, amount, nonce, deadline)) | ||
) | ||
); | ||
} | ||
|
||
function recoverAddress(bytes32 digest, uint8 v, bytes32 r, bytes32 s) external pure returns (address) { | ||
return ecrecover(digest, v, r, s); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
contracts/src/OldTestContracts/BorrowerOperationsTester.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,63 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.18; | ||
|
||
import "../BorrowerOperations.sol"; | ||
|
||
/* Tester contract inherits from BorrowerOperations, and provides external functions | ||
for testing the parent's internal functions. */ | ||
contract BorrowerOperationsTester is BorrowerOperations { | ||
|
||
function getNewICRFromTroveChange | ||
( | ||
uint _coll, | ||
uint _debt, | ||
uint _collChange, | ||
bool isCollIncrease, | ||
uint _debtChange, | ||
bool isDebtIncrease, | ||
uint _price | ||
) | ||
external | ||
pure | ||
returns (uint) | ||
{ | ||
return _getNewICRFromTroveChange(_coll, _debt, _collChange, isCollIncrease, _debtChange, isDebtIncrease, _price); | ||
} | ||
|
||
function getNewTCRFromTroveChange | ||
( | ||
uint _collChange, | ||
bool isCollIncrease, | ||
uint _debtChange, | ||
bool isDebtIncrease, | ||
uint _price | ||
) | ||
external | ||
view | ||
returns (uint) | ||
{ | ||
return _getNewTCRFromTroveChange(_collChange, isCollIncrease, _debtChange, isDebtIncrease, _price); | ||
} | ||
|
||
function getUSDValue(uint _coll, uint _price) external pure returns (uint) { | ||
return _getUSDValue(_coll, _price); | ||
} | ||
|
||
function callInternalAdjustLoan | ||
( | ||
address _borrower, | ||
uint _collWithdrawal, | ||
uint _debtChange, | ||
bool _isDebtIncrease, | ||
address _upperHint, | ||
address _lowerHint) | ||
external | ||
{ | ||
_adjustTrove(_borrower, _collWithdrawal, _debtChange, _isDebtIncrease, _upperHint, _lowerHint, 0); | ||
} | ||
|
||
|
||
// Payable fallback function | ||
receive() external payable { } | ||
} |
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,60 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.18; | ||
|
||
import "../TroveManager.sol"; | ||
|
||
/* Tester contract inherits from TroveManager, and provides external functions | ||
for testing the parent's internal functions. */ | ||
|
||
contract TroveManagerTester is TroveManager { | ||
|
||
function computeICR(uint _coll, uint _debt, uint _price) external pure returns (uint) { | ||
return LiquityMath._computeCR(_coll, _debt, _price); | ||
} | ||
|
||
function getCollGasCompensation(uint _coll) external pure returns (uint) { | ||
return _getCollGasCompensation(_coll); | ||
} | ||
|
||
function getBoldGasCompensation() external pure returns (uint) { | ||
return BOLD_GAS_COMPENSATION; | ||
} | ||
|
||
function getCompositeDebt(uint _debt) external pure returns (uint) { | ||
return _getCompositeDebt(_debt); | ||
} | ||
|
||
function unprotectedDecayBaseRateFromBorrowing() external returns (uint) { | ||
baseRate = _calcDecayedBaseRate(); | ||
assert(baseRate >= 0 && baseRate <= DECIMAL_PRECISION); | ||
|
||
_updateLastFeeOpTime(); | ||
return baseRate; | ||
} | ||
|
||
function minutesPassedSinceLastFeeOp() external view returns (uint) { | ||
return _minutesPassedSinceLastFeeOp(); | ||
} | ||
|
||
function setLastFeeOpTimeToNow() external { | ||
lastFeeOperationTime = block.timestamp; | ||
} | ||
|
||
function setBaseRate(uint _baseRate) external { | ||
baseRate = _baseRate; | ||
} | ||
|
||
function callGetRedemptionFee(uint _ETHDrawn) external view returns (uint) { | ||
_getRedemptionFee(_ETHDrawn); | ||
} | ||
|
||
function getActualDebtFromComposite(uint _debtVal) external pure returns (uint) { | ||
return _getNetDebt(_debtVal); | ||
} | ||
|
||
function callInternalRemoveTroveOwner(address _troveOwner) external { | ||
uint troveOwnersArrayLength = TroveOwners.length; | ||
_removeTroveOwner(_troveOwner, troveOwnersArrayLength); | ||
} | ||
} |
Oops, something went wrong.
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.
Curious: why is this needed?
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 that was to be consistent with declaring interfaces in BaseTest then deploying in DevTestSetup. I've changed this so we just declare the contract GasPool in BaseTest rather than the interface (and deleted the interface). An empty interface is awkward.