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

chore:(test) Add test scenario for calling directly by the investor #359

Merged
merged 5 commits into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions test/integration/Deposit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -713,4 +713,36 @@ contract DepositTest is BaseTest {
vault.mint(firstTranchePayout + secondTranchePayout, self);
assertEq(tranche.balanceOf(self), firstTranchePayout + secondTranchePayout);
}

function testDepositAsInvestorDirectly(uint256 amount) public {
amount = uint128(bound(amount, 4, MAX_UINT128));
vm.assume(amount % 2 == 0);

address vault_ = deploySimpleVault();
ERC7540Vault vault = ERC7540Vault(vault_);
ITranche tranche = ITranche(address(vault.share()));

assertEq(tranche.balanceOf(investor), 0);

erc20.mint(investor, amount);
centrifugeChain.updateMember(vault.poolId(), vault.trancheId(), investor, type(uint64).max); // add user as

vm.startPrank(investor);
erc20.approve(vault_, amount);
vault.requestDeposit(amount, investor, investor);
vm.stopPrank();

uint128 assetId = poolManager.assetToId(address(erc20));
centrifugeChain.isFulfilledDepositRequest(
vault.poolId(), vault.trancheId(), investor.toBytes32(), assetId, uint128(amount), uint128(amount)
);
vm.expectRevert(bytes("InvestmentManager/tranche-token-amount-is-zero"));
vault.deposit(amount, investor);

vm.prank(investor);
uint256 shares = vault.deposit(amount, investor);

assertEq(tranche.balanceOf(investor), amount);
assertEq(shares, amount);
}
}
Loading