Skip to content

Commit

Permalink
feat: pr reviews and added test for roles removed
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaquinBattilana committed Feb 23, 2024
1 parent 6fe257b commit 9b4e8cb
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions src/test/TestGhoStewardV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.0;

import './TestGhoBase.t.sol';
import '@openzeppelin/contracts/utils/Strings.sol';

contract TestGhoStewardV2 is TestGhoBase {
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
Expand Down Expand Up @@ -141,14 +140,10 @@ contract TestGhoStewardV2 is TestGhoBase {
function testRevertUpdateFacilitatorBucketCapacityIfStewardLostBucketManagerRole() public {
(uint256 currentBucketCapacity, ) = GHO_TOKEN.getFacilitatorBucket(address(GHO_ATOKEN));
GHO_TOKEN.revokeRole(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(GHO_STEWARD_V2));
vm.prank(RISK_COUNCIL);
bytes memory revertMsg = abi.encodePacked(
'AccessControl: account ',
Strings.toHexString(address(GHO_STEWARD_V2)),
' is missing role ',
Strings.toHexString(uint256(GHO_TOKEN_BUCKET_MANAGER_ROLE), 32)
vm.expectRevert(
AccessControlErrorsLib.MISSING_ROLE(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(GHO_STEWARD_V2))
);
vm.expectRevert(revertMsg);
vm.prank(RISK_COUNCIL);
GHO_STEWARD_V2.updateFacilitatorBucketCapacity(
address(GHO_ATOKEN),
uint128(currentBucketCapacity) + 1
Expand Down Expand Up @@ -447,6 +442,16 @@ contract TestGhoStewardV2 is TestGhoBase {
GHO_STEWARD_V2.updateGsmExposureCap(address(GHO_GSM), oldExposureCap * 2 + 1);
}

function testRevertUpdateGsmExposureCapIfStewardLostConfiguratorRole() public {
uint128 oldExposureCap = GHO_GSM.getExposureCap();
GHO_GSM.revokeRole(GSM_CONFIGURATOR_ROLE, address(GHO_STEWARD_V2));
vm.expectRevert(
AccessControlErrorsLib.MISSING_ROLE(GSM_CONFIGURATOR_ROLE, address(GHO_STEWARD_V2))
);
vm.prank(RISK_COUNCIL);
GHO_STEWARD_V2.updateGsmExposureCap(address(GHO_GSM), oldExposureCap + 1);
}

function testUpdateGsmBuySellFeesBuyFee() public {
address feeStrategy = GHO_GSM.getFeeStrategy();
uint256 buyFee = IGsmFeeStrategy(feeStrategy).getBuyFee(1e4);
Expand Down Expand Up @@ -672,7 +677,19 @@ contract TestGhoStewardV2 is TestGhoBase {
);
}

function testSetControlledFacilitatorTrue() public {
function testRevertUpdateGsmBuySellFeesIfStewardLostConfiguratorRole() public {
address feeStrategy = GHO_GSM.getFeeStrategy();
uint256 buyFee = IGsmFeeStrategy(feeStrategy).getBuyFee(1e4);
uint256 sellFee = IGsmFeeStrategy(feeStrategy).getSellFee(1e4);
GHO_GSM.revokeRole(GSM_CONFIGURATOR_ROLE, address(GHO_STEWARD_V2));
vm.expectRevert(
AccessControlErrorsLib.MISSING_ROLE(GSM_CONFIGURATOR_ROLE, address(GHO_STEWARD_V2))
);
vm.prank(RISK_COUNCIL);
GHO_STEWARD_V2.updateGsmBuySellFees(address(GHO_GSM), buyFee + 1, sellFee + 1);
}

function testSetControlledFacilitatorAdd() public {
address[] memory oldControlledFacilitators = GHO_STEWARD_V2.getControlledFacilitators();
address[] memory newGsmList = new address[](1);
newGsmList[0] = address(GHO_GSM_4626);
Expand All @@ -683,7 +700,7 @@ contract TestGhoStewardV2 is TestGhoBase {
assertTrue(_contains(newControlledFacilitators, address(GHO_GSM_4626)));
}

function testSetControlledFacilitatorsFalse() public {
function testSetControlledFacilitatorsRemove() public {
address[] memory oldControlledFacilitators = GHO_STEWARD_V2.getControlledFacilitators();
address[] memory disableGsmList = new address[](1);
disableGsmList[0] = address(GHO_GSM);
Expand Down

0 comments on commit 9b4e8cb

Please sign in to comment.