diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2458e60 --- /dev/null +++ b/.gitmodules @@ -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 diff --git a/lib/forge-std b/lib/forge-std new file mode 160000 index 0000000..978ac6f --- /dev/null +++ b/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 978ac6fadb62f5f0b723c996f64be52eddba6801 diff --git a/lib/foundry-huff b/lib/foundry-huff new file mode 160000 index 0000000..7d1ce15 --- /dev/null +++ b/lib/foundry-huff @@ -0,0 +1 @@ +Subproject commit 7d1ce15ccf92bd68458c7e28e0ae847b64b4fc74 diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts new file mode 160000 index 0000000..dbb6104 --- /dev/null +++ b/lib/openzeppelin-contracts @@ -0,0 +1 @@ +Subproject commit dbb6104ce834628e473d2173bbc9d47f81a9eec3 diff --git a/test/BatchTransferTest.t.sol b/test/BatchTransferTest.t.sol index a1de2f3..128f4c1 100644 --- a/test/BatchTransferTest.t.sol +++ b/test/BatchTransferTest.t.sol @@ -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; @@ -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; @@ -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 { @@ -136,4 +152,4 @@ contract Disperse { for (uint256 i = 0; i < recipients.length; i++) require(token.transferFrom(msg.sender, recipients[i], values[i])); } -} \ No newline at end of file +}