Skip to content

Commit

Permalink
feat: deleted not used libraries and added setFacilitators tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaquinBattilana committed Feb 19, 2024
1 parent e40f895 commit d548248
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/contracts/misc/GhoStewardV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {IPoolAddressesProvider} from '@aave/core-v3/contracts/interfaces/IPoolAd
import {IPoolConfigurator} from '@aave/core-v3/contracts/interfaces/IPoolConfigurator.sol';
import {IPool} from '@aave/core-v3/contracts/interfaces/IPool.sol';
import {DataTypes} from '@aave/core-v3/contracts/protocol/libraries/types/DataTypes.sol';
import {ReserveConfiguration} from '@aave/core-v3/contracts/protocol/libraries/configuration/ReserveConfiguration.sol';
import {PercentageMath} from '@aave/core-v3/contracts/protocol/libraries/math/PercentageMath.sol';
import {GhoInterestRateStrategy} from '../facilitators/aave/interestStrategy/GhoInterestRateStrategy.sol';
import {FixedFeeStrategy} from '../facilitators/gsm/feeStrategy/FixedFeeStrategy.sol';
import {IGhoToken} from '../gho/interfaces/IGhoToken.sol';
Expand All @@ -28,8 +26,6 @@ import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet
* @dev GhoInterestRateStrategy is used when creating a new borrow rate strategy for GHO
*/
contract GhoStewardV2 is Ownable, IGhoStewardV2 {
using PercentageMath for uint256;
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
using EnumerableSet for EnumerableSet.AddressSet;

/// @inheritdoc IGhoStewardV2
Expand Down
39 changes: 39 additions & 0 deletions src/test/TestGhoStewardV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -580,4 +580,43 @@ contract TestGhoStewardV2 is TestGhoBase {
address newStrategy = GHO_GSM.getFeeStrategy();
assertEq(oldStrategy, newStrategy);
}

function testRevertSetControlledFacilitatorIfUnauthorized() public {
vm.expectRevert('Ownable: caller is not the owner');
vm.prank(RISK_COUNCIL);
address[] memory newGsmList = new address[](1);
newGsmList[0] = address(GHO_GSM_4626);
GHO_STEWARD_V2.setControlledFacilitator(newGsmList, true);
}

function testSetControlledFacilitatorTrue() public {
address[] memory oldControlledFacilitators = GHO_STEWARD_V2.getControlledFacilitators();
address[] memory newGsmList = new address[](1);
newGsmList[0] = address(GHO_GSM_4626);
vm.prank(SHORT_EXECUTOR);
GHO_STEWARD_V2.setControlledFacilitator(newGsmList, true);
address[] memory newControlledFacilitators = GHO_STEWARD_V2.getControlledFacilitators();
assertEq(newControlledFacilitators.length, oldControlledFacilitators.length + 1);
assertTrue(_contains(newControlledFacilitators, address(GHO_GSM_4626)));
}

function testSetControlledFacilitatorsFalse() public {
address[] memory oldControlledFacilitators = GHO_STEWARD_V2.getControlledFacilitators();
address[] memory disableGsmList = new address[](1);
disableGsmList[0] = address(GHO_GSM);
vm.prank(SHORT_EXECUTOR);
GHO_STEWARD_V2.setControlledFacilitator(disableGsmList, false);
address[] memory newControlledFacilitators = GHO_STEWARD_V2.getControlledFacilitators();
assertEq(newControlledFacilitators.length, oldControlledFacilitators.length - 1);
assertFalse(_contains(newControlledFacilitators, address(GHO_GSM)));
}

function _contains(address[] memory list, address item) internal returns (bool) {
for (uint256 i = 0; i < list.length; i++) {
if (list[i] == item) {
return true;
}
}
return false;
}
}

0 comments on commit d548248

Please sign in to comment.