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 gitmodules & update test cases #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "lib/foundry-huff"]
path = lib/foundry-huff
url = https://github.com/huff-language/foundry-huff
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 978ac6
1 change: 1 addition & 0 deletions lib/foundry-huff
Submodule foundry-huff added at 7d1ce1
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at dbb610
22 changes: 19 additions & 3 deletions test/BatchTransferTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "foundry-huff/HuffDeployer.sol";
import "forge-std/Test.sol";
import "forge-std/console.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract BatchTransferTest is Test {
IBatchTransfer iBatch;
Expand All @@ -27,7 +28,7 @@ contract BatchTransferTest is Test {
iBatch = IBatchTransfer(HuffDeployer.deploy("BatchTransfer"));
disperse = new Disperse();

for(uint i; i < 1000; i++){
for(uint i = 1; i < 1000; i++){
recipients.push(address(uint160(address0)+uint160(i)));
amounts.push(i);
total += i;
Expand All @@ -51,12 +52,27 @@ contract BatchTransferTest is Test {
vm.prank(address0);
//console.log(address0.balance);
iBatch.batchTransferETH{value: total}(recipients, amounts);

// check balance
for (uint256 i = 0; i < recipients.length; i++){
assertEq(recipients[i].balance, amounts[i]);
}
assertEq(address0.balance, 1000 ether - total);
}

function testBatchTransferERC20() public {
uint256 balanceBefore = IERC20(token0).balanceOf(address0);

vm.prank(address0);
//console.log(address0.balance);
iBatch.batchTransferERC20(address(token0), total, recipients, amounts);

// check balance
for (uint256 i = 0; i < recipients.length; i++){
assertEq(IERC20(token0).balanceOf(recipients[i]), amounts[i]);
}

uint256 balanceAfter = IERC20(token0).balanceOf(address0);
assertEq(balanceAfter, balanceBefore - total);
}

function testDisperseDeploy() public {
Expand Down Expand Up @@ -136,4 +152,4 @@ contract Disperse {
for (uint256 i = 0; i < recipients.length; i++)
require(token.transferFrom(msg.sender, recipients[i], values[i]));
}
}
}