From 634baee683fab3025d08989d4e4ec657ca3a28c3 Mon Sep 17 00:00:00 2001 From: teddy Date: Wed, 24 Jul 2024 10:35:53 -0300 Subject: [PATCH] test: missing case for joinswapPoolAmountOut --- test/unit/BPool/BPool_JoinswapPoolAmountOut.t.sol | 7 +++++++ test/unit/BPool/BPool_JoinswapPoolAmountOut.tree | 2 ++ 2 files changed, 9 insertions(+) diff --git a/test/unit/BPool/BPool_JoinswapPoolAmountOut.t.sol b/test/unit/BPool/BPool_JoinswapPoolAmountOut.t.sol index 98c22e0d..78ef1fbb 100644 --- a/test/unit/BPool/BPool_JoinswapPoolAmountOut.t.sol +++ b/test/unit/BPool/BPool_JoinswapPoolAmountOut.t.sol @@ -52,6 +52,13 @@ contract BPoolJoinswapPoolAmountOut is BPoolBase, BNum { bPool.joinswapPoolAmountOut(makeAddr('unknown token'), poolAmountOut, maxTokenIn); } + function test_RevertWhen_TokenAmountInIsZero() external { + // it should revert + vm.expectRevert(IBPool.BPool_InvalidTokenAmountIn.selector); + // using a small amount that rounds to zero + bPool.joinswapPoolAmountOut(tokenIn, 20, type(uint256).max); + } + function test_RevertWhen_TokenAmountInExceedsMaxRatio() external { // it should revert vm.expectRevert(IBPool.BPool_TokenAmountInAboveMaxRatio.selector); diff --git a/test/unit/BPool/BPool_JoinswapPoolAmountOut.tree b/test/unit/BPool/BPool_JoinswapPoolAmountOut.tree index ec19a013..b795f4b7 100644 --- a/test/unit/BPool/BPool_JoinswapPoolAmountOut.tree +++ b/test/unit/BPool/BPool_JoinswapPoolAmountOut.tree @@ -5,6 +5,8 @@ BPool::JoinswapPoolAmountOut │ └── it should revert ├── when token in is not bound │ └── it should revert +├── when token amount in is zero +│ └── it should revert ├── when token amount in exceeds max ratio │ └── it should revert ├── when calculated token amount in is more than expected