-
Notifications
You must be signed in to change notification settings - Fork 1
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 invariant tests #461
base: develop
Are you sure you want to change the base?
Add invariant tests #461
Conversation
|
dbf13c1
to
3104b75
Compare
82bae10
to
4115c70
Compare
seniorTranche.addApprovedLender(initLender, true); | ||
vm.stopPrank(); | ||
|
||
// A lender deposits some liquidity in senior tranche to solve a tiny issue of epoch close |
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.
What's the tiny issue?
// ); | ||
} | ||
|
||
function _createLenders(uint256 lenderNum) internal { |
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.
nit: numLenders
is much more common.
for (uint256 i; i < lenderNum; i++) { | ||
address lender = makeAddr(string(abi.encode("lender", i))); | ||
vm.startPrank(poolOperator); | ||
bool reinvesting = i % 2 == 0 ? true : false; |
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.
nit: can we just do bool reinvesting = i % 2 == 0
?
} | ||
} | ||
|
||
function _createBorrowers(uint256 borrowerNum) internal { |
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.
nit: numBorrowers
@@ -0,0 +1,43 @@ | |||
async function main() { | |||
const input = `sender=0x0000000000000000000000000000000a17B60033 addr=[test/invariant/handlers/LiquidityHandler.sol:LiquidityHandler]0x65c26fC57D9847cF8dF2E4ee0bf45D79cd86Ad96 calldata=withdrawProtocolFee(uint256,uint256) args=[6295442937 [6.295e9], 18189 [1.818e4]] |
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.
What does this script do?
names[selector] = name; | ||
} | ||
|
||
function increaselogCall(bytes4 selector) public returns (uint256) { |
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.
nit: increaseCalls
?
import {PoolConfig} from "contracts/common/PoolConfig.sol"; | ||
|
||
contract PoolFactoryForTest is PoolFactory { | ||
function addPoolOwner(uint256 _poolId, address poolOwner) public { |
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.
nit: poolId_
.
@@ -19,7 +19,7 @@ contract ReceivableTest is StdInvariant, Test { | |||
assertEq(receivableHandler.receivable().totalSupply(), 1); | |||
} | |||
|
|||
function invariant_supplyEqualsHandlerCount() public { | |||
function invariant_Receivable_supplyEqualsHandlerCount() public { |
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.
Should we make the name of this function consistent with other invariants?
_setUp( | ||
PoolDeployParameters({ | ||
tranchesPolicyType: FIXED_SENIOR_YIELD_TRANCHES_POLICY, | ||
// tranchesPolicyType: RISK_ADJUSTED_TRANCHES_POLICY, |
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.
nit: delete commented out code?
mapping(uint256 => address[]) investedLendersByTranche; | ||
mapping(uint256 => address[]) redeemedLendersByTranche; | ||
|
||
constructor(address[] memory _lenders) BaseHandler() { |
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.
nit: lenders_
.
Please refer to Huma Invariant Tests and Huma Invariants