From 7f57dade9f927ed024a13cfd3e3b54fbb1e35350 Mon Sep 17 00:00:00 2001 From: Haythem Sellami <17862704+haythemsellami@users.noreply.github.com> Date: Tue, 7 May 2024 17:44:54 +0100 Subject: [PATCH] test: removeStrategy() --- test/unit/RemoveStrategy.t.sol | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/unit/RemoveStrategy.t.sol diff --git a/test/unit/RemoveStrategy.t.sol b/test/unit/RemoveStrategy.t.sol new file mode 100644 index 00000000..cb9e2fa6 --- /dev/null +++ b/test/unit/RemoveStrategy.t.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity ^0.8.0; + +import {FourSixTwoSixAggBase, FourSixTwoSixAgg} from "./FourSixTwoSixAggBase.t.sol"; + +contract RemoveStrategyTest is FourSixTwoSixAggBase { + uint256 strategyAllocationPoints; + + function setUp() public virtual override { + super.setUp(); + + strategyAllocationPoints = type(uint120).max; + _addStrategy(manager, address(eTST), strategyAllocationPoints); + } + + function testRemoveStrategy() public { + uint256 totalAllocationPointsBefore = fourSixTwoSixAgg.totalAllocationPoints(); + uint256 withdrawalQueueLengthBefore = fourSixTwoSixAgg.withdrawalQueueLength(); + + vm.prank(manager); + fourSixTwoSixAgg.removeStrategy(address(eTST)); + + FourSixTwoSixAgg.Strategy memory strategyAfter = fourSixTwoSixAgg.getStrategy(address(eTST)); + + assertEq(strategyAfter.active, false); + assertEq(strategyAfter.allocationPoints, 0); + assertEq(fourSixTwoSixAgg.totalAllocationPoints(), totalAllocationPointsBefore - strategyAllocationPoints); + assertEq(fourSixTwoSixAgg.withdrawalQueueLength(), withdrawalQueueLengthBefore - 1); + } + + function testRemoveStrategy_fromUnauthorized() public { + vm.prank(deployer); + vm.expectRevert(); + fourSixTwoSixAgg.removeStrategy(address(eTST)); + } + + function testRemoveStrategy_AlreadyRemoved() public { + vm.prank(manager); + vm.expectRevert(); + fourSixTwoSixAgg.removeStrategy(address(eTST2)); + } +}