Skip to content

Commit

Permalink
test for amount is zero (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
doerfli committed Jul 3, 2024
1 parent 65fdd19 commit f87b2b7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contracts/pool/PoolService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
29 changes: 29 additions & 0 deletions test/TestBundle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f87b2b7

Please sign in to comment.