diff --git a/test/unit/concrete/container/deposit-erc20/depositERC20.t.sol b/test/unit/concrete/container/deposit-erc20/depositERC20.t.sol deleted file mode 100644 index d65fc97..0000000 --- a/test/unit/concrete/container/deposit-erc20/depositERC20.t.sol +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.26; - -import { Container_Unit_Concrete_Test } from "../Container.t.sol"; -import { Errors } from "../../../../utils/Errors.sol"; -import { Events } from "../../../../utils/Events.sol"; -import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol"; - -contract DepositERC20_Unit_Concrete_Test is Container_Unit_Concrete_Test { - function setUp() public virtual override { - Container_Unit_Concrete_Test.setUp(); - - // Make Bob the caller for this test suite as anyone can deposit ERC-20 assets - vm.startPrank({ msgSender: users.bob }); - - // Approve the {Container} contract to spend USDT tokens on behalf of Bob - usdt.approve({ spender: address(container), amount: 1000000e6 }); - } - - function test_RevertWhen_AssetZeroAddress() external { - // Expect the next call to revert with the {InvalidAssetZeroAddress} error - vm.expectRevert(Errors.InvalidAssetZeroAddress.selector); - - // Run the test - container.depositERC20({ asset: IERC20(address(0x0)), amount: 100e6 }); - } - - modifier whenAssetNonZeroAddress() { - _; - } - - function test_RevertWhen_AssetZeroAmount() external whenAssetNonZeroAddress { - // Expect the next call to revert with the {InvalidAssetZeroAmount} error - vm.expectRevert(Errors.InvalidAssetZeroAmount.selector); - - // Run the test - container.depositERC20({ asset: IERC20(address(usdt)), amount: 0 }); - } - - modifier whenAssetGtZeroAmount() { - _; - } - - function test_DepositERC20() external whenAssetNonZeroAddress whenAssetGtZeroAmount { - // Store the USDT balance of Bob before the deposit - uint256 balanceOfBobBefore = usdt.balanceOf(users.bob); - - // Expect the {AssetDeposited} event to be emitted - vm.expectEmit(); - emit Events.AssetDeposited({ sender: users.bob, asset: address(usdt), amount: 100e6 }); - - // Run the test - container.depositERC20({ asset: IERC20(address(usdt)), amount: 100e6 }); - - // Assert the USDT balance of the {Container} contract - uint256 actualBalanceOfContainer = usdt.balanceOf(address(container)); - assertEq(actualBalanceOfContainer, 100e6); - - // Assert the USDT balance of Bob after the deposit - uint256 actualBalanceOfBob = usdt.balanceOf(users.bob); - assertEq(actualBalanceOfBob, balanceOfBobBefore - 100e6); - } -} diff --git a/test/unit/concrete/container/deposit-erc20/depositERC20.tree b/test/unit/concrete/container/deposit-erc20/depositERC20.tree deleted file mode 100644 index bbab4c6..0000000 --- a/test/unit/concrete/container/deposit-erc20/depositERC20.tree +++ /dev/null @@ -1,9 +0,0 @@ -depositERC20.t.sol -├── when the address is the zero address -│ └── it should revert with the {InvalidAssetZeroAddress} error -└── when the address is not the zero address - ├── when the amount is zero - │ └── it should revert with the {InvalidAssetZeroAmount} error - └── when the amount is greater than zero - ├── it should transfer the tokens to the container - └── it should emit an {AssetDeposited} event diff --git a/test/unit/concrete/container/receive/receive.t.sol b/test/unit/concrete/container/receive/receive.t.sol index 30a0006..f281a51 100644 --- a/test/unit/concrete/container/receive/receive.t.sol +++ b/test/unit/concrete/container/receive/receive.t.sol @@ -13,9 +13,9 @@ contract Receive_Unit_Concrete_Test is Container_Unit_Concrete_Test { // Make Bob the caller for this test suite vm.startPrank({ msgSender: users.bob }); - // Expect the {AssetDeposited} event to be emitted upon ETH deposit + // Expect the {NativeDeposited} event to be emitted upon ETH deposit vm.expectEmit(); - emit Events.AssetDeposited({ sender: users.bob, asset: address(0), amount: 1 ether }); + emit Events.NativeDeposited({ sender: users.bob, amount: 1 ether }); // Run the test (bool success, ) = address(container).call{ value: 1 ether }(""); diff --git a/test/unit/concrete/container/receive/receive.tree b/test/unit/concrete/container/receive/receive.tree index fe01de0..8f16c0d 100644 --- a/test/unit/concrete/container/receive/receive.tree +++ b/test/unit/concrete/container/receive/receive.tree @@ -1,2 +1,2 @@ receive.t.sol -└── it should emit an {AssetDeposited} event \ No newline at end of file +└── it should emit an {NativeDeposited} event \ No newline at end of file diff --git a/test/unit/concrete/container/withdraw-erc20/withdrawERC20.t.sol b/test/unit/concrete/container/withdraw-erc20/withdrawERC20.t.sol index bc47f1d..97084de 100644 --- a/test/unit/concrete/container/withdraw-erc20/withdrawERC20.t.sol +++ b/test/unit/concrete/container/withdraw-erc20/withdrawERC20.t.sol @@ -40,8 +40,8 @@ contract WithdrawERC20_Unit_Concrete_Test is Container_Unit_Concrete_Test { // Approve the {Container} contract to spend USDT tokens on behalf of Eve usdt.approve({ spender: address(container), amount: 100e6 }); - // Deposit sufficient ERC-20 tokens into the container to enable the withdrawal - container.depositERC20({ asset: IERC20(address(usdt)), amount: 100e6 }); + // Deposit enough ERC-20 tokens into the container to enable the withdrawal + usdt.transfer({ recipient: address(container), amount: 100e6 }); _; } diff --git a/test/utils/Events.sol b/test/utils/Events.sol index cecbb8c..410f9bf 100644 --- a/test/utils/Events.sol +++ b/test/utils/Events.sol @@ -9,11 +9,10 @@ abstract contract Events { CONTAINER //////////////////////////////////////////////////////////////////////////*/ - /// @notice Emitted when an `amount` amount of `asset` ERC-20 asset is deposited on the container + /// @notice Emitted when an `amount` amount of `asset` native tokens (ETH) is deposited on the container /// @param sender The address of the depositor - /// @param asset The address of the deposited ERC-20 token /// @param amount The amount of the deposited ERC-20 token - event AssetDeposited(address indexed sender, address indexed asset, uint256 amount); + event NativeDeposited(address indexed sender, uint256 amount); /// @notice Emitted when an `amount` amount of `asset` ERC-20 asset is withdrawn from the container /// @param sender The address to which the tokens were transferred