From f890214f5b565ff8ab301a30cf0b032342c5e6a0 Mon Sep 17 00:00:00 2001 From: smol-ninja Date: Tue, 24 Dec 2024 10:34:46 +0530 Subject: [PATCH] chore: polish batch comments and tests Co-authored-by: andreivladbrg --- src/abstracts/Batch.sol | 3 +-- tests/integration/concrete/batch/batch.t.sol | 26 ++++++++++---------- tests/unit/concrete/batch/batch.t.sol | 4 +-- tests/unit/concrete/batch/batch.tree | 4 +-- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/abstracts/Batch.sol b/src/abstracts/Batch.sol index b0cbd0bf2..129d108ad 100644 --- a/src/abstracts/Batch.sol +++ b/src/abstracts/Batch.sol @@ -6,7 +6,6 @@ import { IBatch } from "../interfaces/IBatch.sol"; /// @title Batch /// @notice See the documentation in {IBatch}. -/// @dev Forked from: https://github.com/boringcrypto/BoringSolidity/blob/master/contracts/BoringBatchable.sol abstract contract Batch is IBatch { /*////////////////////////////////////////////////////////////////////////// USER-FACING NON-CONSTANT FUNCTIONS @@ -22,7 +21,7 @@ abstract contract Batch is IBatch { for (uint256 i = 0; i < count; ++i) { (bool success, bytes memory result) = address(this).delegatecall(calls[i]); - // Check: If the delegate call failed, load and bubble up the revert data. + // Check: If the delegatecall failed, load and bubble up the revert data. if (!success) { assembly { // Get the length of the result stored in the first 32 bytes. diff --git a/tests/integration/concrete/batch/batch.t.sol b/tests/integration/concrete/batch/batch.t.sol index 087afba87..c231a2be6 100644 --- a/tests/integration/concrete/batch/batch.t.sol +++ b/tests/integration/concrete/batch/batch.t.sol @@ -53,10 +53,10 @@ contract Batch_Integration_Concrete_Test is Integration_Test { assertEq(results.length, 6, "batch results length"); assertTrue(abi.decode(results[0], (bool)), "batch results[0]"); assertEq(abi.decode(results[1], (uint128)), defaults.WITHDRAW_AMOUNT(), "batch results[1]"); - assertEq(results[2], hex"", "batch results[2]"); + assertEq(results[2], "", "batch results[2]"); assertEq(abi.decode(results[3], (uint256)), expectedNextStreamId, "batch results[3]"); assertEq(abi.decode(results[4], (uint256)), expectedNextStreamId, "batch results[4]"); - assertEq(results[5], hex"", "batch results[5]"); + assertEq(results[5], "", "batch results[5]"); } /// @dev The batch call includes: @@ -93,7 +93,7 @@ contract Batch_Integration_Concrete_Test is Integration_Test { assertEq(abi.decode(results[3], (uint256)), expectedNextStreamId + 3, "batch results[3]"); assertEq(abi.decode(results[4], (uint256)), expectedNextStreamId + 4, "batch results[4]"); assertEq(abi.decode(results[5], (uint256)), expectedNextStreamId + 5, "batch results[5]"); - assertEq(address(lockup).balance, initialEthBalance + 1 wei, "batch contract balance"); + assertEq(address(lockup).balance, initialEthBalance + 1 wei, "lockup contract balance"); } /// @dev The batch call includes: @@ -119,12 +119,12 @@ contract Batch_Integration_Concrete_Test is Integration_Test { bytes[] memory results = lockup.batch{ value: 1 wei }(calls); - assertEq(results.length, 4); - assertEq(results[0], hex""); - assertEq(results[1], hex""); - assertEq(results[2], hex""); - assertEq(results[3], hex""); - assertEq(address(lockup).balance, initialEthBalance + 1 wei); + assertEq(results.length, 4, "batch results length"); + assertEq(results[0], "", "batch results[0]"); + assertEq(results[1], "", "batch results[1]"); + assertEq(results[2], "", "batch results[2]"); + assertEq(results[3], "", "batch results[3]"); + assertEq(address(lockup).balance, initialEthBalance + 1 wei, "lockup contract balance"); } /// @dev The batch call includes: @@ -155,11 +155,11 @@ contract Batch_Integration_Concrete_Test is Integration_Test { bytes[] memory results = lockup.batch{ value: 1 wei }(calls); assertEq(results.length, 5, "batch results length"); - assertEq(results[0], hex"", "batch results[0]"); + assertEq(results[0], "", "batch results[0]"); assertEq(abi.decode(results[1], (uint128)), defaults.DEPOSIT_AMOUNT() - 1, "batch results[1]"); - assertEq(results[2], hex"", "batch results[2]"); + assertEq(results[2], "", "batch results[2]"); assertEq(abi.decode(results[3], (uint128)), defaults.DEPOSIT_AMOUNT() - 2, "batch results[3]"); - assertEq(results[4], hex"", "batch results[4]"); - assertEq(address(lockup).balance, initialEthBalance + 1 wei, "batch contract balance"); + assertEq(results[4], "", "batch results[4]"); + assertEq(address(lockup).balance, initialEthBalance + 1 wei, "lockup contract balance"); } } diff --git a/tests/unit/concrete/batch/batch.t.sol b/tests/unit/concrete/batch/batch.t.sol index 11eb9a2ee..a32bc5f67 100644 --- a/tests/unit/concrete/batch/batch.t.sol +++ b/tests/unit/concrete/batch/batch.t.sol @@ -82,7 +82,7 @@ contract Batch_Unit_Concrete_Test is Base_Test { // It should return the empty string. assertEq(results.length, 1, "batch results length"); - assertEq(results[0], hex"", "batch results[0]"); + assertEq(results[0], "", "batch results[0]"); } modifier whenPayable() { @@ -134,6 +134,6 @@ contract Batch_Unit_Concrete_Test is Base_Test { // It should return an empty value. assertEq(results.length, 1, "batch results length"); - assertEq(results[0], hex"", "batch results[0]"); + assertEq(results[0], "", "batch results[0]"); } } diff --git a/tests/unit/concrete/batch/batch.tree b/tests/unit/concrete/batch/batch.tree index f42cca878..35501ea18 100644 --- a/tests/unit/concrete/batch/batch.tree +++ b/tests/unit/concrete/batch/batch.tree @@ -2,12 +2,12 @@ Batch_Unit_Concrete_Test ├── when function does not exist │ └── it should revert └── when function exists - ├── when non state-changing function + ├── when non state changing function │ ├── when function reverts │ │ └── it should revert │ └── when function not revert │ └── it should return expected value - └── when state-changing function + └── when state changing function ├── when not payable │ ├── when batch includes ETH value │ │ └── it should revert