Skip to content

Commit

Permalink
feat: added test for missing constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaquinBattilana committed Mar 1, 2024
1 parent c23dd42 commit 2de50ff
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
15 changes: 8 additions & 7 deletions src/contracts/misc/GhoStewardV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {IFixedRateStrategyFactory} from './interfaces/IFixedRateStrategyFactory.
* @dev Only the Aave DAO is able add or remove approved GSMs.
* @dev When updating GSM fee strategy the method asumes that the current strategy is FixedFeeStrategy for enforcing parameters
* @dev FixedFeeStrategy is used when creating a new strategy for GSM
* @dev GhoInterestRateStrategy is used when creating a new borrow rate strategy for GHO
* @dev FixedRateStrategyFactory is used when creating a new borrow rate strategy for GHO
*/
contract GhoStewardV2 is Ownable, IGhoStewardV2 {
using EnumerableSet for EnumerableSet.AddressSet;
Expand All @@ -50,10 +50,10 @@ contract GhoStewardV2 is Ownable, IGhoStewardV2 {
address public immutable GHO_TOKEN;

/// @inheritdoc IGhoStewardV2
address public immutable RISK_COUNCIL;
address public immutable FIXED_RATE_STRATEGY_FACTORY;

/// @inheritdoc IGhoStewardV2
address public immutable FIXED_RATE_STRATEGY_FACTORY;
address public immutable RISK_COUNCIL;

GhoDebounce internal _ghoTimelocks;
mapping(address => uint40) _facilitatorsBucketCapacityTimelocks;
Expand Down Expand Up @@ -86,25 +86,26 @@ contract GhoStewardV2 is Ownable, IGhoStewardV2 {
* @param owner The address of the owner of the contract
* @param addressesProvider The address of the PoolAddressesProvider of Aave V3 Ethereum Pool
* @param ghoToken The address of the GhoToken
* @param fixedRateStrategyFactory The address of the FixedRateStrategyFactory
* @param riskCouncil The address of the risk council
*/
constructor(
address owner,
address addressesProvider,
address ghoToken,
address riskCouncil,
address fixedRateStrategyFactory
address fixedRateStrategyFactory,
address riskCouncil
) {
require(owner != address(0), 'INVALID_OWNER');
require(addressesProvider != address(0), 'INVALID_ADDRESSES_PROVIDER');
require(ghoToken != address(0), 'INVALID_GHO_TOKEN');
require(riskCouncil != address(0), 'INVALID_RISK_COUNCIL');
require(fixedRateStrategyFactory != address(0), 'INVALID_FIXED_RATE_STRATEGY_FACTORY');
require(riskCouncil != address(0), 'INVALID_RISK_COUNCIL');

POOL_ADDRESSES_PROVIDER = addressesProvider;
GHO_TOKEN = ghoToken;
RISK_COUNCIL = riskCouncil;
FIXED_RATE_STRATEGY_FACTORY = fixedRateStrategyFactory;
RISK_COUNCIL = riskCouncil;

_transferOwnership(owner);
}
Expand Down
12 changes: 6 additions & 6 deletions src/contracts/misc/interfaces/IGhoStewardV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ interface IGhoStewardV2 {
*/
function GHO_TOKEN() external view returns (address);

/**
* @notice Returns the address of the risk council
* @return The address of the RiskCouncil
*/
function RISK_COUNCIL() external view returns (address);

/**
* @notice Returns the address of the fixed rate strategy factory
* @return The address of the FixedRateStrategyFactory
*/
function FIXED_RATE_STRATEGY_FACTORY() external view returns (address);

/**
* @notice Returns the address of the risk council
* @return The address of the RiskCouncil
*/
function RISK_COUNCIL() external view returns (address);

/**
* @notice Returns the list of controlled facilitators by this steward.
* @return An array of facilitator addresses
Expand Down
4 changes: 2 additions & 2 deletions src/test/TestGhoBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ contract TestGhoBase is Test, Constants, Events {
SHORT_EXECUTOR,
address(PROVIDER),
address(GHO_TOKEN),
RISK_COUNCIL,
address(FIXED_RATE_STRATEGY_FACTORY)
address(FIXED_RATE_STRATEGY_FACTORY),
RISK_COUNCIL
);
GHO_TOKEN.grantRole(GHO_TOKEN_BUCKET_MANAGER_ROLE, address(GHO_STEWARD_V2));
GHO_GSM.grantRole(GSM_CONFIGURATOR_ROLE, address(GHO_STEWARD_V2));
Expand Down
8 changes: 7 additions & 1 deletion src/test/TestGhoStewardV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contract TestGhoStewardV2 is TestGhoBase {
assertEq(GHO_STEWARD.owner(), SHORT_EXECUTOR);
assertEq(GHO_STEWARD_V2.POOL_ADDRESSES_PROVIDER(), address(PROVIDER));
assertEq(GHO_STEWARD_V2.GHO_TOKEN(), address(GHO_TOKEN));
assertEq(GHO_STEWARD_V2.FIXED_RATE_STRATEGY_FACTORY(), address(FIXED_RATE_STRATEGY_FACTORY));
assertEq(GHO_STEWARD_V2.RISK_COUNCIL(), RISK_COUNCIL);

IGhoStewardV2.GhoDebounce memory ghoTimelocks = GHO_STEWARD_V2.getGhoTimelocks();
Expand Down Expand Up @@ -53,9 +54,14 @@ contract TestGhoStewardV2 is TestGhoBase {
new GhoStewardV2(address(0x001), address(0x002), address(0), address(0x004), address(0x005));
}

function testRevertConstructorInvalidFixedRateStrategyFactory() public {
vm.expectRevert('INVALID_FIXED_RATE_STRATEGY_FACTORY');
new GhoStewardV2(address(0x001), address(0x002), address(0x003), address(0), address(0x005));
}

function testRevertConstructorInvalidRiskCouncil() public {
vm.expectRevert('INVALID_RISK_COUNCIL');
new GhoStewardV2(address(0x001), address(0x002), address(0x003), address(0), address(0x005));
new GhoStewardV2(address(0x001), address(0x002), address(0x003), address(0x005), address(0));
}

function testUpdateFacilitatorBucketCapacity() public {
Expand Down

0 comments on commit 2de50ff

Please sign in to comment.