Skip to content

Commit

Permalink
chore: add testCan_waterfallPushAndPull erc20 test case
Browse files Browse the repository at this point in the history
  • Loading branch information
samparsky committed Aug 2, 2023
1 parent 49b05cf commit 6afbcb8
Showing 1 changed file with 59 additions and 58 deletions.
117 changes: 59 additions & 58 deletions src/test/waterfall/WaterfallModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -602,87 +602,77 @@ contract WaterfallModuleTest is WaterfallTestHelper, Test {
assertEq(waterfallModuleETH.distributedFunds(), 2.5 ether);
assertEq(waterfallModuleETH.fundsPendingWithdrawal(), 0 ether);

// // test erc20
// address(mERC20).safeTransfer(address(waterfallModuleERC20_OR), 0.5 ether);
// assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 0.5 ether);
// TEST ERC20

// waterfallModuleERC20_OR.waterfallFunds();

// assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 0 ether);
// assertEq(mERC20.balanceOf(address(0)), 0.5 ether);
// assertEq(mERC20.balanceOf(address(1)), 0 ether);

// assertEq(waterfallModuleERC20_OR.getPullBalance(address(0)), 0 ether);
// assertEq(waterfallModuleERC20_OR.getPullBalance(address(1)), 0 ether);

// assertEq(waterfallModuleERC20_OR.distributedFunds(), 0.5 ether);
// assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 0 ether);
address(mERC20).safeTransfer(address(waterfallModuleERC20_OR), 0.5 ether);
assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 0.5 ether);

// address(mERC20).safeTransfer(address(waterfallModuleERC20_OR), 1 ether);
// assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 1 ether);
waterfallModuleERC20_OR.waterfallFunds();

// waterfallModuleERC20_OR.waterfallFundsPull();
assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 0 ether, "1/invalid waterfall balance");
assertEq(mERC20.balanceOf(trancheRecipients[0]), 0 ether, "2/invalid tranche 1 recipient balance");
assertEq(mERC20.balanceOf(trancheRecipients[1]), 0.5 ether, "3/invalid tranche 2 recipient balance - 1");

// assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 1 ether);
// assertEq(mERC20.balanceOf(address(0)), 0.5 ether);
// assertEq(mERC20.balanceOf(address(1)), 0 ether);
assertEq(waterfallModuleERC20_OR.getPullBalance(trancheRecipients[0]), 0 ether, "4/invalid pull balance");
assertEq(waterfallModuleERC20_OR.getPullBalance(trancheRecipients[1]), 0 ether, "5/invalid pull balance");

// assertEq(waterfallModuleERC20_OR.getPullBalance(address(0)), 0.5 ether);
// assertEq(waterfallModuleERC20_OR.getPullBalance(address(1)), 0.5 ether);
assertEq(waterfallModuleERC20_OR.distributedFunds(), 0.5 ether, "6/invalid distributed funds");
assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 0 ether, "7/invalid funds pending withdrawal");

// assertEq(waterfallModuleERC20_OR.distributedFunds(), 1.5 ether);
// assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 1 ether);
address(mERC20).safeTransfer(address(waterfallModuleERC20_OR), 1 ether);
assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 1 ether, "8/invalid waterfall balance");

// waterfallModuleERC20_OR.waterfallFundsPull();
waterfallModuleERC20_OR.waterfallFundsPull();

// assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 1 ether);
// assertEq(mERC20.balanceOf(address(0)), 0.5 ether);
// assertEq(mERC20.balanceOf(address(1)), 0 ether);
assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 1 ether, "9/invalid waterfall balance");
assertEq(mERC20.balanceOf(trancheRecipients[0]), 0 ether, "10/invalid recipeint balance");
assertEq(mERC20.balanceOf(trancheRecipients[1]), 0.5 ether, "11/invalid recipient balance");

// assertEq(waterfallModuleERC20_OR.getPullBalance(address(0)), 0.5 ether);
// assertEq(waterfallModuleERC20_OR.getPullBalance(address(1)), 0.5 ether);
assertEq(waterfallModuleERC20_OR.getPullBalance(trancheRecipients[0]), 0, "12/invalid recipient pull balance");
assertEq(waterfallModuleERC20_OR.getPullBalance(trancheRecipients[1]), 1 ether, "13/invalid recipient pull balance");

// assertEq(waterfallModuleERC20_OR.distributedFunds(), 1.5 ether);
// assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 1 ether);
assertEq(waterfallModuleERC20_OR.distributedFunds(), 1.5 ether, "14/invalid distributed funds balance");
assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 1 ether, "15/invalid funds pending balance");

// address(mERC20).safeTransfer(address(waterfallModuleERC20_OR), 1 ether);
// assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 2 ether);
waterfallModuleERC20_OR.waterfallFundsPull();

// waterfallModuleERC20_OR.waterfallFunds();
assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 1 ether, "16/invalid waterfall balance");
assertEq(mERC20.balanceOf(trancheRecipients[0]), 0 ether, "17/invalid recipient balance");
assertEq(mERC20.balanceOf(trancheRecipients[1]), 0.5 ether, "18/invalid recipient balance");

// assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 1 ether);
// assertEq(mERC20.balanceOf(address(0)), 0.5 ether);
// assertEq(mERC20.balanceOf(address(1)), 1 ether);
assertEq(waterfallModuleERC20_OR.getPullBalance(trancheRecipients[0]), 0 ether, "19/invalid pull balance");
assertEq(waterfallModuleERC20_OR.getPullBalance(trancheRecipients[1]), 1 ether, "20/invalid pull balance");

// assertEq(waterfallModuleERC20_OR.getPullBalance(address(0)), 0.5 ether);
// assertEq(waterfallModuleERC20_OR.getPullBalance(address(1)), 0.5 ether);
assertEq(waterfallModuleERC20_OR.distributedFunds(), 1.5 ether, "21/invalid distributed funds");
assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 1 ether, "22/invalid funds pending");

// assertEq(waterfallModuleERC20_OR.distributedFunds(), 2.5 ether);
// assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 1 ether);
/// 3
address(mERC20).safeTransfer(address(waterfallModuleERC20_OR), 32 ether);
assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 33 ether);

// waterfallModuleERC20_OR.withdraw(address(0));
waterfallModuleERC20_OR.waterfallFunds();

// assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 0.5 ether);
// assertEq(mERC20.balanceOf(address(0)), 1 ether);
// assertEq(mERC20.balanceOf(address(1)), 1 ether);
assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 1 ether);
assertEq(mERC20.balanceOf(trancheRecipients[0]), 32 ether);
assertEq(mERC20.balanceOf(trancheRecipients[1]), 0.5 ether);

// assertEq(waterfallModuleERC20_OR.getPullBalance(address(0)), 0 ether);
// assertEq(waterfallModuleERC20_OR.getPullBalance(address(1)), 0.5 ether);
assertEq(waterfallModuleERC20_OR.getPullBalance(trancheRecipients[0]), 0 ether);
assertEq(waterfallModuleERC20_OR.getPullBalance(trancheRecipients[1]), 1 ether);

// assertEq(waterfallModuleERC20_OR.distributedFunds(), 2.5 ether);
// assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 0.5 ether);
assertEq(waterfallModuleERC20_OR.distributedFunds(), 33.5 ether);
assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 1 ether);

// waterfallModuleERC20_OR.withdraw(address(1));
waterfallModuleERC20_OR.withdraw(trancheRecipients[1]));

// assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 0 ether);
// assertEq(mERC20.balanceOf(address(0)), 1 ether);
// assertEq(mERC20.balanceOf(address(1)), 1.5 ether);
assertEq(mERC20.balanceOf(address(waterfallModuleERC20_OR)), 0 ether);
assertEq(mERC20.balanceOf(trancheRecipients[0]), 32 ether);
assertEq(mERC20.balanceOf(trancheRecipients[1]), 1.5 ether);

// assertEq(waterfallModuleERC20_OR.getPullBalance(address(0)), 0 ether);
// assertEq(waterfallModuleERC20_OR.getPullBalance(address(1)), 0 ether);
assertEq(waterfallModuleERC20_OR.getPullBalance(trancheRecipients[0]), 0 ether);
assertEq(waterfallModuleERC20_OR.getPullBalance(trancheRecipients[1]), 0 ether);

// assertEq(waterfallModuleERC20_OR.distributedFunds(), 2.5 ether);
// assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 0 ether);
assertEq(waterfallModuleERC20_OR.distributedFunds(), 33.5 ether);
assertEq(waterfallModuleERC20_OR.fundsPendingWithdrawal(), 0 ether);
}

function testFuzz_waterfallDepositsToRecipients(
Expand Down Expand Up @@ -835,4 +825,15 @@ contract WaterfallModuleTest is WaterfallTestHelper, Test {
}
}

function testCan_waterfallPullDepositsToRecipients(
uint8 _numTranches,
uint256 _recipientsSeed,
uint256 _thresholdsSeed,
uint8 _numDeposits,
uint48 _ethAmount,
uint96 _erc20Amount
) public {

}

}

0 comments on commit 6afbcb8

Please sign in to comment.