Skip to content

Commit 969119b

Browse files
committed
test: create abstract main test
1 parent 3e9a028 commit 969119b

2 files changed

Lines changed: 62 additions & 58 deletions

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Verifier URL for contract verification
22
VERIFIER_URL=
3+
# leave DRY blank to disable dry run
34
DRY=
45
ACCOUNT=
56
CHAIN=

src/AaveV3Horizon_ACREDListing_20260217/AaveV3Horizon_ACREDListing_20260217.t.sol

Lines changed: 61 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,62 +9,18 @@ import {AaveV3Horizon_ACREDListing_20260217} from 'src/AaveV3Horizon_ACREDListin
99
import {AaveV3EthereumHorizonCustom} from 'src/utils/AaveV3EthereumHorizonCustom.sol';
1010
import {AaveV3EthereumHorizonAssets} from 'aave-address-book-latest/AaveV3EthereumHorizon.sol';
1111

12-
/**
13-
* @dev Test for Horizon ACRED listing
14-
* command: FOUNDRY_PROFILE=test forge test --match-path=src/AaveV3Horizon_ACREDListing_20260217/AaveV3Horizon_ACREDListing_20260217.t.sol -vv
15-
*/
16-
contract AaveV3Horizon_ACREDListing_20260217_Test is ProtocolV3HorizonTestBase {
12+
abstract contract AaveV3Horizon_ACREDListing_20260217_TestBase is ProtocolV3HorizonTestBase {
1713
AaveV3Horizon_ACREDListing_20260217 internal proposal;
1814

1915
ExpectedAssetConfig internal expectedAssetConfig;
2016
ExpectedEModeConfig internal expectedEModeConfig;
2117

2218
function setUp() public virtual {
2319
_setExpectedConfig();
24-
25-
vm.createSelectFork(vm.rpcUrl('mainnet'), 24473387);
26-
proposal = new AaveV3Horizon_ACREDListing_20260217();
27-
}
28-
29-
/**
30-
* @dev executes the generic test suite including e2e and config snapshots
31-
*/
32-
function test_defaultProposalExecution() public virtual {
33-
defaultTest_v3_3(
34-
'AaveV3Horizon_ACREDListing_20260217',
35-
IPool(AaveV3EthereumHorizonCustom.POOL),
36-
address(proposal)
37-
);
3820
}
3921

40-
/**
41-
* @dev verifies the exact config values set by the ACRED listing payload
42-
*/
43-
function test_acredConfig() public {
44-
IPool pool = IPool(AaveV3EthereumHorizonCustom.POOL);
45-
46-
// check eMode 3 before execution (has config values but no assets assigned)
47-
_assertEModeConfig(
48-
pool,
49-
ExpectedEModeConfig({
50-
eModeCategory: 3,
51-
ltv: 72_00,
52-
liquidationThreshold: 79_00,
53-
liquidationBonus: 100_00 + 7_50,
54-
label: '',
55-
collateralAssets: new address[](0),
56-
borrowableAssets: new address[](0)
57-
})
58-
);
59-
60-
// execute payload
61-
_executeHorizonPayload(address(proposal));
62-
63-
// verify ACRED asset config
64-
_assertAssetConfig(pool, expectedAssetConfig);
65-
66-
// verify eMode 3 = ACRED GHO after execution
67-
_assertEModeConfig(pool, expectedEModeConfig);
22+
function _pool() internal pure returns (IPool) {
23+
return IPool(AaveV3EthereumHorizonCustom.POOL);
6824
}
6925

7026
function _setExpectedConfig() internal virtual override {
@@ -105,31 +61,78 @@ contract AaveV3Horizon_ACREDListing_20260217_Test is ProtocolV3HorizonTestBase {
10561
}
10662
}
10763

64+
/**
65+
* @dev Test for Horizon ACRED listing (pre-execution).
66+
* command: FOUNDRY_PROFILE=test forge test --match-contract AaveV3Horizon_ACREDListing_20260217_Test -vv
67+
*/
68+
contract AaveV3Horizon_ACREDListing_20260217_Test is AaveV3Horizon_ACREDListing_20260217_TestBase {
69+
function setUp() public virtual override {
70+
super.setUp();
71+
vm.createSelectFork(vm.rpcUrl('mainnet'), 24473387);
72+
proposal = new AaveV3Horizon_ACREDListing_20260217();
73+
}
74+
75+
/**
76+
* @dev executes the generic test suite including e2e and config snapshots
77+
*/
78+
function test_defaultProposalExecution() public virtual {
79+
defaultTest_v3_3('AaveV3Horizon_ACREDListing_20260217', _pool(), address(proposal));
80+
}
81+
82+
/**
83+
* @dev verifies the exact config values set by the ACRED listing payload
84+
*/
85+
function test_acredConfig() public virtual {
86+
IPool pool = _pool();
87+
88+
// check eMode 3 before execution (has config values but no assets assigned)
89+
_assertEModeConfig(
90+
pool,
91+
ExpectedEModeConfig({
92+
eModeCategory: 3,
93+
ltv: 72_00,
94+
liquidationThreshold: 79_00,
95+
liquidationBonus: 100_00 + 7_50,
96+
label: '',
97+
collateralAssets: new address[](0),
98+
borrowableAssets: new address[](0)
99+
})
100+
);
101+
102+
// execute payload
103+
_executeHorizonPayload(address(proposal));
104+
105+
// verify ACRED asset config
106+
_assertAssetConfig(pool, expectedAssetConfig);
107+
108+
// verify eMode 3 = ACRED GHO after execution
109+
_assertEModeConfig(pool, expectedEModeConfig);
110+
}
111+
}
112+
108113
/**
109114
* @dev Post-execution fork test. Run after the payload has been executed on mainnet
110115
* to validate the live state matches expected config and run full E2E.
111116
* command: FOUNDRY_PROFILE=test forge test --match-contract AaveV3Horizon_ACREDListing_20260217_PostExecution_Test -vv
112117
*/
113118
contract AaveV3Horizon_ACREDListing_20260217_PostExecution_Test is
114-
AaveV3Horizon_ACREDListing_20260217_Test
119+
AaveV3Horizon_ACREDListing_20260217_TestBase
115120
{
116121
function setUp() public virtual override {
117-
_setExpectedConfig();
122+
super.setUp();
118123
vm.skip(true, 'skipping post-execution test');
119124
// TODO: pin to block after on-chain execution
120125
vm.createSelectFork(vm.rpcUrl('mainnet'));
126+
proposal = AaveV3Horizon_ACREDListing_20260217(0xD7b0ed496C468aDb1702D8dFe08383644b57a544);
127+
_executeHorizonPayload(address(proposal));
121128
}
122129

123-
function test_defaultPostExecution() public {
124-
defaultTest_v3_3_postExecution(IPool(AaveV3EthereumHorizonCustom.POOL));
130+
function test_defaultProposalExecution() public {
131+
defaultTest_v3_3_postExecution(_pool());
125132
}
126133

127-
function test_acredConfigPostExecution() public {
128-
IPool pool = IPool(AaveV3EthereumHorizonCustom.POOL);
129-
_assertAssetConfig(pool, expectedAssetConfig);
130-
_assertEModeConfig(pool, expectedEModeConfig);
134+
function test_acredConfig() public {
135+
_assertAssetConfig(_pool(), expectedAssetConfig);
136+
_assertEModeConfig(_pool(), expectedEModeConfig);
131137
}
132-
133-
// no payload to execute post-deployment
134-
function test_defaultProposalExecution() public override {}
135138
}

0 commit comments

Comments
 (0)