Skip to content
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

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open

Add invariant tests #461

wants to merge 16 commits into from

Conversation

bin-57blocks
Copy link
Contributor

Copy link

height bot commented Feb 6, 2024

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

seniorTranche.addApprovedLender(initLender, true);
vm.stopPrank();

// A lender deposits some liquidity in senior tranche to solve a tiny issue of epoch close
Copy link
Contributor

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 {
Copy link
Contributor

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;
Copy link
Contributor

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 {
Copy link
Contributor

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]]
Copy link
Contributor

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) {
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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,
Copy link
Contributor

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lenders_.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants