From f87b2b7af9b465d899d53083f59caed01bfd6274 Mon Sep 17 00:00:00 2001 From: Marc Doerflinger Date: Wed, 3 Jul 2024 13:43:34 +0000 Subject: [PATCH] test for amount is zero (#418) --- contracts/pool/PoolService.sol | 4 +++- test/TestBundle.t.sol | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/contracts/pool/PoolService.sol b/contracts/pool/PoolService.sol index 04400426a..3b9a6ea8b 100644 --- a/contracts/pool/PoolService.sol +++ b/contracts/pool/PoolService.sol @@ -539,12 +539,14 @@ contract PoolService is if (allowance < amount.toInt()) { revert ErrorPoolServiceWalletAllowanceTooSmall(bundleOwner, address(tokenHandler), allowance, amount.toInt()); } - + // TODO: centralize token handling (issue #471) tokenHandler.transfer( bundleOwner, poolWallet, amount); + } else { + revert ErrorPoolServiceAmountIsZero(); } } diff --git a/test/TestBundle.t.sol b/test/TestBundle.t.sol index 19248d923..7c2080bc0 100644 --- a/test/TestBundle.t.sol +++ b/test/TestBundle.t.sol @@ -114,6 +114,35 @@ contract TestBundle is GifTest { pool.stake(bundleNftId, stakeAmount); } + /// @dev test staking of an existing bundle + function test_Bundle_stakeBundle_amountIsZero() public { + // GIVEN + initialStakingFee = FeeLib.percentageFee(4); + _prepareProduct(false); + + IComponents.ComponentInfo memory poolComponentInfo = instanceReader.getComponentInfo(poolNftId); + + vm.startPrank(investor); + token.approve(address(pool.getTokenHandler()), 2000); + + Seconds lifetime = SecondsLib.toSeconds(604800); + bundleNftId = pool.createBundle( + FeeLib.zero(), + 1000, + lifetime, + "" + ); + + Amount stakeAmount = AmountLib.toAmount(0); + + // THEN + vm.expectRevert(abi.encodeWithSelector( + IPoolService.ErrorPoolServiceAmountIsZero.selector)); + + // WHEN - pool is staked with another 1000 tokens + pool.stake(bundleNftId, stakeAmount); + } + function _fundInvestor(uint256 amount) internal { vm.startPrank(registryOwner); token.transfer(investor, amount);