Skip to content

Commit fc3c5b0

Browse files
feat: More improvements to tests
1 parent 497c665 commit fc3c5b0

File tree

6 files changed

+102
-197
lines changed

6 files changed

+102
-197
lines changed

src/20250519_Multi_GHOAvalancheLaunch/abstraction/tests/AaveV3GHOLaneTest.sol

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {IGhoToken} from 'src/interfaces/IGhoToken.sol';
1313
import {ProtocolV3TestBase} from 'aave-helpers/src/ProtocolV3TestBase.sol';
1414
import {CCIPUtils} from '../../tests/utils/CCIPUtils.sol';
1515
import {GhoCCIPChains} from '../constants/GhoCCIPChains.sol';
16+
import {IGhoAaveSteward} from 'src/interfaces/IGhoAaveSteward.sol';
17+
import {IGhoBucketSteward} from 'src/interfaces/IGhoBucketSteward.sol';
18+
import {IGhoCcipSteward} from 'src/interfaces/IGhoCcipSteward.sol';
1619

1720
import {AaveV3GHOLane} from '../AaveV3GHOLane.sol';
1821

@@ -39,6 +42,9 @@ abstract contract AaveV3GHOLaneTest is ProtocolV3TestBase {
3942
IUpgradeableBurnMintTokenPool_1_5_1 internal immutable ETH_TOKEN_POOL;
4043
ITokenAdminRegistry internal immutable LOCAL_TOKEN_ADMIN_REGISTRY;
4144
IRouter internal immutable LOCAL_CCIP_ROUTER;
45+
IGhoAaveSteward internal immutable LOCAL_GHO_AAVE_CORE_STEWARD;
46+
IGhoBucketSteward internal immutable LOCAL_GHO_BUCKET_STEWARD;
47+
IGhoCcipSteward internal immutable LOCAL_GHO_CCIP_STEWARD;
4248

4349
address internal alice = makeAddr('alice');
4450
address internal bob = makeAddr('bob');
@@ -70,29 +76,40 @@ abstract contract AaveV3GHOLaneTest is ProtocolV3TestBase {
7076
LOCAL_TOKEN_ADMIN_REGISTRY = ITokenAdminRegistry(localChainInfo.tokenAdminRegistry);
7177
ETH_TOKEN_POOL = IUpgradeableBurnMintTokenPool_1_5_1(GhoCCIPChains.ETHEREUM().ghoCCIPTokenPool);
7278
LOCAL_CCIP_ROUTER = IRouter(localChainInfo.ccipRouter);
73-
}
74-
75-
function _isPostExecutionTest() internal view virtual returns (bool) {
76-
return true;
79+
LOCAL_GHO_AAVE_CORE_STEWARD = IGhoAaveSteward(localChainInfo.ghoAaveCoreSteward);
80+
LOCAL_GHO_BUCKET_STEWARD = IGhoBucketSteward(localChainInfo.ghoBucketSteward);
81+
LOCAL_GHO_CCIP_STEWARD = IGhoCcipSteward(localChainInfo.ghoCCIPSteward);
7782
}
7883

7984
///// Constants to setup
8085

81-
function _ccipRateLimitCapacity() internal view virtual returns (uint128);
86+
function _ccipRateLimitCapacity() internal view virtual returns (uint128) {
87+
return 1_500_000e18;
88+
}
8289

83-
function _ccipRateLimitRefillRate() internal view virtual returns (uint128);
90+
function _ccipRateLimitRefillRate() internal view virtual returns (uint128) {
91+
return 300e18;
92+
}
8493

8594
// Local Chain's outbound lane to Ethereum (OnRamp address)
86-
function _localOutboundLaneToEth() internal view virtual returns (IEVM2EVMOnRamp);
95+
function _localOutboundLaneToEth() internal view virtual returns (IEVM2EVMOnRamp) {
96+
return IEVM2EVMOnRamp(_getOnRamp(ETH_CHAIN_SELECTOR));
97+
}
8798

8899
// Local Chain's inbound lane from Ethereum (OffRamp address)
89-
function _localInboundLaneFromEth() internal view virtual returns (IEVM2EVMOffRamp_1_5);
100+
function _localInboundLaneFromEth() internal view virtual returns (IEVM2EVMOffRamp_1_5) {
101+
return IEVM2EVMOffRamp_1_5(_getOffRamp(ETH_CHAIN_SELECTOR));
102+
}
90103

91104
// Local Chain's outbound lane to Remote Chain (OnRamp address)
92-
function _localOutboundLaneToRemote() internal view virtual returns (IEVM2EVMOnRamp);
105+
function _localOutboundLaneToRemote() internal view virtual returns (IEVM2EVMOnRamp) {
106+
return IEVM2EVMOnRamp(_getOnRamp(REMOTE_CHAIN_SELECTOR));
107+
}
93108

94109
// Local Chain's inbound lane from Remote Chain (OffRamp address)
95-
function _localInboundLaneFromRemote() internal view virtual returns (IEVM2EVMOffRamp_1_5);
110+
function _localInboundLaneFromRemote() internal view virtual returns (IEVM2EVMOffRamp_1_5) {
111+
return IEVM2EVMOffRamp_1_5(_getOffRamp(REMOTE_CHAIN_SELECTOR));
112+
}
96113

97114
function _deployAaveV3GHOLaneProposal() internal virtual returns (AaveV3GHOLane);
98115

@@ -102,6 +119,26 @@ abstract contract AaveV3GHOLaneTest is ProtocolV3TestBase {
102119
virtual
103120
returns (GhoCCIPChains.ChainInfo[] memory);
104121

122+
function _getOnRamp(uint64 chainSelector) internal view virtual returns (address) {
123+
return LOCAL_CCIP_ROUTER.getOnRamp(chainSelector);
124+
}
125+
126+
function _getOnRampFailIfNotFound(uint64 chainSelector) internal view virtual returns (address) {
127+
address offRamp = _getOffRamp(chainSelector);
128+
assertNotEq(offRamp, address(0), 'No offRamp found for the supported chain');
129+
return offRamp;
130+
}
131+
132+
function _getOffRamp(uint64 chainSelector) internal view virtual returns (address) {
133+
IRouter.OffRamp[] memory offRamps = LOCAL_CCIP_ROUTER.getOffRamps();
134+
for (uint256 i = 0; i < offRamps.length; i++) {
135+
if (offRamps[i].sourceChainSelector == chainSelector) {
136+
return offRamps[i].offRamp;
137+
}
138+
}
139+
return address(0);
140+
}
141+
105142
function setUp() public virtual {
106143
vm.createSelectFork(vm.rpcUrl(forkRpcAlias), FORK_BLOCK_NUMBER);
107144
proposal = _deployAaveV3GHOLaneProposal();

src/20250519_Multi_GHOAvalancheLaunch/abstraction/tests/AaveV3GHOLaunchTest.sol

Lines changed: 28 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ pragma solidity ^0.8.0;
44
import {IPool as IPool_CCIP} from 'src/interfaces/ccip/tokenPool/IPool.sol';
55
import {IClient} from 'src/interfaces/ccip/IClient.sol';
66
import {IInternal} from 'src/interfaces/ccip/IInternal.sol';
7-
import {IRouter} from 'src/interfaces/ccip/IRouter.sol';
87
import {AaveV3GHOLaneTest} from './AaveV3GHOLaneTest.sol';
98
import {GhoCCIPChains} from '../constants/GhoCCIPChains.sol';
109
import {IACLManager} from 'aave-address-book/AaveV3.sol';
1110
import {IGhoToken} from 'src/interfaces/IGhoToken.sol';
12-
import {IGhoAaveSteward} from 'src/interfaces/IGhoAaveSteward.sol';
13-
import {IGhoBucketSteward} from 'src/interfaces/IGhoBucketSteward.sol';
14-
import {IGhoCcipSteward} from 'src/interfaces/IGhoCcipSteward.sol';
1511
import {IOwnable} from 'aave-address-book/common/IOwnable.sol';
1612
import {GovernanceV3Avalanche} from 'aave-address-book/GovernanceV3Avalanche.sol';
1713
import {AaveV3Avalanche} from 'aave-address-book/AaveV3Avalanche.sol';
1814
import {IUpgradeableBurnMintTokenPool_1_5_1} from 'src/interfaces/ccip/tokenPool/IUpgradeableBurnMintTokenPool.sol';
15+
import {IGhoAaveSteward} from 'src/interfaces/IGhoAaveSteward.sol';
16+
import {IGhoCcipSteward} from 'src/interfaces/IGhoCcipSteward.sol';
1917

2018
abstract contract AaveV3GHOLaunchTest_PreExecution is AaveV3GHOLaneTest {
2119
IACLManager public immutable LOCAL_ACL_MANAGER;
@@ -46,10 +44,6 @@ abstract contract AaveV3GHOLaunchTest_PreExecution is AaveV3GHOLaneTest {
4644
LOCAL_ACL_MANAGER = IACLManager(localChainInfo.aclManager);
4745
}
4846

49-
function _isPostExecutionTest() internal view virtual override returns (bool) {
50-
return false;
51-
}
52-
5347
/**
5448
* @dev executes the generic test suite including e2e and config snapshots
5549
*/
@@ -61,12 +55,6 @@ abstract contract AaveV3GHOLaunchTest_PreExecution is AaveV3GHOLaneTest {
6155
);
6256
}
6357

64-
function _localGhoBucketSteward() internal view virtual returns (IGhoBucketSteward);
65-
66-
function _localGhoAaveSteward() internal view virtual returns (IGhoAaveSteward);
67-
68-
function _localGhoCCIPSteward() internal view virtual returns (IGhoCcipSteward);
69-
7058
function _localRiskCouncil() internal view virtual returns (address);
7159

7260
function _localRmnProxy() internal view virtual returns (address);
@@ -77,10 +65,10 @@ abstract contract AaveV3GHOLaunchTest_PreExecution is AaveV3GHOLaneTest {
7765
assertFalse(
7866
LOCAL_ACL_MANAGER.hasRole(
7967
LOCAL_ACL_MANAGER.RISK_ADMIN_ROLE(),
80-
address(_localGhoAaveSteward())
68+
address(LOCAL_GHO_AAVE_CORE_STEWARD)
8169
)
8270
);
83-
assertEq(_localGhoBucketSteward().getControlledFacilitators().length, 0);
71+
assertEq(LOCAL_GHO_BUCKET_STEWARD.getControlledFacilitators().length, 0);
8472
assertEq(LOCAL_TOKEN_POOL.getRateLimitAdmin(), address(0));
8573

8674
executePayload(vm, address(proposal));
@@ -107,59 +95,60 @@ abstract contract AaveV3GHOLaunchTest_PreExecution is AaveV3GHOLaneTest {
10795
assertTrue(
10896
LOCAL_ACL_MANAGER.hasRole(
10997
LOCAL_ACL_MANAGER.RISK_ADMIN_ROLE(),
110-
address(_localGhoAaveSteward())
98+
address(LOCAL_GHO_AAVE_CORE_STEWARD)
11199
)
112100
);
113101

114102
assertTrue(
115103
LOCAL_GHO_TOKEN.hasRole(
116104
LOCAL_GHO_TOKEN.BUCKET_MANAGER_ROLE(),
117-
address(_localGhoBucketSteward())
105+
address(LOCAL_GHO_BUCKET_STEWARD)
118106
)
119107
);
120108

121-
address[] memory facilitatorList = _localGhoBucketSteward().getControlledFacilitators();
109+
address[] memory facilitatorList = LOCAL_GHO_BUCKET_STEWARD.getControlledFacilitators();
122110
assertEq(facilitatorList.length, 1);
123111
assertEq(facilitatorList[0], address(LOCAL_TOKEN_POOL));
124-
assertTrue(_localGhoBucketSteward().isControlledFacilitator(address(LOCAL_TOKEN_POOL)));
112+
assertTrue(LOCAL_GHO_BUCKET_STEWARD.isControlledFacilitator(address(LOCAL_TOKEN_POOL)));
125113

126-
assertEq(LOCAL_TOKEN_POOL.getRateLimitAdmin(), address(_localGhoCCIPSteward()));
114+
assertEq(LOCAL_TOKEN_POOL.getRateLimitAdmin(), address(LOCAL_GHO_CCIP_STEWARD));
127115
}
128116

129117
function test_stewardsConfig() public view {
130118
assertEq(
131-
IOwnable(address(_localGhoAaveSteward())).owner(),
119+
IOwnable(address(LOCAL_GHO_AAVE_CORE_STEWARD)).owner(),
132120
GovernanceV3Avalanche.EXECUTOR_LVL_1
133121
);
134122
assertEq(
135-
_localGhoAaveSteward().POOL_ADDRESSES_PROVIDER(),
123+
LOCAL_GHO_AAVE_CORE_STEWARD.POOL_ADDRESSES_PROVIDER(),
136124
address(AaveV3Avalanche.POOL_ADDRESSES_PROVIDER)
137125
);
138126
assertEq(
139-
_localGhoAaveSteward().POOL_DATA_PROVIDER(),
127+
LOCAL_GHO_AAVE_CORE_STEWARD.POOL_DATA_PROVIDER(),
140128
address(AaveV3Avalanche.AAVE_PROTOCOL_DATA_PROVIDER)
141129
);
142-
assertEq(_localGhoAaveSteward().RISK_COUNCIL(), _localRiskCouncil());
143-
IGhoAaveSteward.BorrowRateConfig memory config = _localGhoAaveSteward().getBorrowRateConfig();
130+
assertEq(LOCAL_GHO_AAVE_CORE_STEWARD.RISK_COUNCIL(), _localRiskCouncil());
131+
IGhoAaveSteward.BorrowRateConfig memory config = LOCAL_GHO_AAVE_CORE_STEWARD
132+
.getBorrowRateConfig();
144133
assertEq(config.optimalUsageRatioMaxChange, 500);
145134
assertEq(config.baseVariableBorrowRateMaxChange, 500);
146135
assertEq(config.variableRateSlope1MaxChange, 500);
147136
assertEq(config.variableRateSlope2MaxChange, 500);
148137

149138
assertEq(
150-
IOwnable(address(_localGhoBucketSteward())).owner(),
139+
IOwnable(address(LOCAL_GHO_BUCKET_STEWARD)).owner(),
151140
GovernanceV3Avalanche.EXECUTOR_LVL_1
152141
);
153-
assertEq(_localGhoBucketSteward().GHO_TOKEN(), address(LOCAL_GHO_TOKEN));
154-
assertEq(_localGhoBucketSteward().RISK_COUNCIL(), _localRiskCouncil());
155-
assertEq(_localGhoBucketSteward().getControlledFacilitators().length, 0); // before AIP, no controlled facilitators are set
156-
157-
assertEq(_localGhoCCIPSteward().GHO_TOKEN(), address(LOCAL_GHO_TOKEN));
158-
assertEq(_localGhoCCIPSteward().GHO_TOKEN_POOL(), address(LOCAL_TOKEN_POOL));
159-
assertEq(_localGhoCCIPSteward().RISK_COUNCIL(), _localRiskCouncil());
160-
assertFalse(_localGhoCCIPSteward().BRIDGE_LIMIT_ENABLED());
142+
assertEq(LOCAL_GHO_BUCKET_STEWARD.GHO_TOKEN(), address(LOCAL_GHO_TOKEN));
143+
assertEq(LOCAL_GHO_BUCKET_STEWARD.RISK_COUNCIL(), _localRiskCouncil());
144+
assertEq(LOCAL_GHO_BUCKET_STEWARD.getControlledFacilitators().length, 0); // before AIP, no controlled facilitators are set
145+
146+
assertEq(LOCAL_GHO_CCIP_STEWARD.GHO_TOKEN(), address(LOCAL_GHO_TOKEN));
147+
assertEq(LOCAL_GHO_CCIP_STEWARD.GHO_TOKEN_POOL(), address(LOCAL_TOKEN_POOL));
148+
assertEq(LOCAL_GHO_CCIP_STEWARD.RISK_COUNCIL(), _localRiskCouncil());
149+
assertFalse(LOCAL_GHO_CCIP_STEWARD.BRIDGE_LIMIT_ENABLED());
161150
assertEq(
162-
abi.encode(_localGhoCCIPSteward().getCcipTimelocks()),
151+
abi.encode(LOCAL_GHO_CCIP_STEWARD.getCcipTimelocks()),
163152
abi.encode(IGhoCcipSteward.CcipDebounce(0, 0))
164153
);
165154
}
@@ -257,9 +246,7 @@ abstract contract AaveV3GHOLaunchTest_PostExecution is AaveV3GHOLaneTest {
257246

258247
function setUp() public override {
259248
super.setUp();
260-
if (_isPostExecutionTest()) {
261-
executePayload(vm, address(proposal));
262-
}
249+
executePayload(vm, address(proposal));
263250
}
264251

265252
function test_sendMessageToSupportedChainSucceeds(uint256 amount, uint8 chainIndex) public {
@@ -332,7 +319,7 @@ abstract contract AaveV3GHOLaunchTest_PostExecution is AaveV3GHOLaneTest {
332319

333320
uint256 aliceBalance = LOCAL_GHO_TOKEN.balanceOf(alice);
334321

335-
address offRamp = _getOffRamp(supportedChains[chainIndex].chainSelector);
322+
address offRamp = _getOnRampFailIfNotFound(supportedChains[chainIndex].chainSelector);
336323

337324
vm.expectEmit(address(LOCAL_TOKEN_POOL));
338325
emit Minted(offRamp, alice, amount);
@@ -368,7 +355,7 @@ abstract contract AaveV3GHOLaunchTest_PostExecution is AaveV3GHOLaneTest {
368355
uint256 amount = 100e18;
369356
skip(_getInboundRefillTime(amount));
370357

371-
address offRampI = _getOffRamp(supportedChains[chainIndexI].chainSelector);
358+
address offRampI = _getOnRampFailIfNotFound(supportedChains[chainIndexI].chainSelector);
372359

373360
vm.expectRevert(
374361
abi.encodeWithSelector(
@@ -390,14 +377,4 @@ abstract contract AaveV3GHOLaunchTest_PostExecution is AaveV3GHOLaneTest {
390377
})
391378
);
392379
}
393-
394-
function _getOffRamp(uint64 chainSelector) internal view virtual returns (address) {
395-
IRouter.OffRamp[] memory offRamps = LOCAL_CCIP_ROUTER.getOffRamps();
396-
for (uint256 i = 0; i < offRamps.length; i++) {
397-
if (offRamps[i].sourceChainSelector == chainSelector) {
398-
return offRamps[i].offRamp;
399-
}
400-
}
401-
revert('No offRamp found for the supported chain');
402-
}
403380
}

0 commit comments

Comments
 (0)