Skip to content

Commit f6a905a

Browse files
authored
feat: v2 default test (#154)
* refactor: rename v2 playloadbase to v2payload for consistency * feat: add v2 default test
1 parent 55a0482 commit f6a905a

9 files changed

Lines changed: 44 additions & 18 deletions

src/ProtocolV2TestBase.sol

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {ExtendedAggregatorV2V3Interface} from './interfaces/ExtendedAggregatorV2
1111
import {CommonTestBase, ReserveTokens} from './CommonTestBase.sol';
1212
import {ProxyHelpers} from './ProxyHelpers.sol';
1313
import {ChainIds} from './ChainIds.sol';
14+
import {GovV3Helpers} from './GovV3Helpers.sol';
1415

1516
struct ReserveConfig {
1617
string symbol;
@@ -49,6 +50,30 @@ struct InterestStrategyValues {
4950
contract ProtocolV2TestBase is CommonTestBase {
5051
using SafeERC20 for IERC20;
5152

53+
/**
54+
* @dev runs the default test suite that should run on any proposal touching the aave protocol which includes:
55+
* - diffing the config
56+
* - running an e2e testsuite over all assets
57+
*/
58+
function defaultTest(
59+
string memory reportName,
60+
ILendingPool pool,
61+
address payload
62+
) public returns (ReserveConfig[] memory, ReserveConfig[] memory) {
63+
string memory beforeString = string(abi.encodePacked(reportName, '_before'));
64+
ReserveConfig[] memory configBefore = createConfigurationSnapshot(beforeString, pool);
65+
66+
GovV3Helpers.executePayload(vm, payload);
67+
68+
string memory afterString = string(abi.encodePacked(reportName, '_after'));
69+
ReserveConfig[] memory configAfter = createConfigurationSnapshot(afterString, pool);
70+
71+
diffReports(beforeString, afterString);
72+
73+
e2eTest(pool);
74+
return (configBefore, configAfter);
75+
}
76+
5277
/**
5378
* @dev Generates a markdown compatible snapshot of the whole pool configuration into `/reports`.
5479
* @param reportName filename suffix for the generated reports.

src/ProtocolV3TestBase.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ contract ProtocolV3TestBase is CommonTestBase {
6666
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
6767
using SafeERC20 for IERC20;
6868

69+
/**
70+
* @dev runs the default test suite that should run on any proposal touching the aave protocol which includes:
71+
* - diffing the config
72+
* - checking if the changes are plausible (no conflicting config changes etc)
73+
* - running an e2e testsuite over all assets
74+
*/
6975
function defaultTest(
7076
string memory reportName,
7177
IPool pool,

src/v2-config-engine/AaveV2PayloadBase.sol renamed to src/v2-config-engine/AaveV2Payload.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {EngineFlags} from '../v3-config-engine/EngineFlags.sol';
1616
* Updates of interest rate strategies.
1717
* @author BGD Labs
1818
*/
19-
abstract contract AaveV2PayloadBase {
19+
abstract contract AaveV2Payload {
2020
using Address for address;
2121

2222
IEngine public immutable LISTING_ENGINE;

src/v2-config-engine/AaveV2PayloadAvalanche.sol

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
pragma solidity ^0.8.0;
33

44
import {AaveV2Avalanche} from 'aave-address-book/AaveV2Avalanche.sol';
5-
import './AaveV2PayloadBase.sol';
5+
import './AaveV2Payload.sol';
66

77
/**
88
* @dev Base smart contract for an Aave v2 rates update on Avalanche.
99
* @author BGD Labs
1010
*/
1111
// TODO: Add rates factory address after deploying
12-
abstract contract AaveV2PayloadAvalanche is
13-
AaveV2PayloadBase(IEngine(AaveV2Avalanche.CONFIG_ENGINE))
14-
{
12+
abstract contract AaveV2PayloadAvalanche is AaveV2Payload(IEngine(AaveV2Avalanche.CONFIG_ENGINE)) {
1513

1614
}

src/v2-config-engine/AaveV2PayloadEthereum.sol

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
pragma solidity ^0.8.0;
33

44
import {AaveV2Ethereum} from 'aave-address-book/AaveV2Ethereum.sol';
5-
import './AaveV2PayloadBase.sol';
5+
import './AaveV2Payload.sol';
66

77
/**
88
* @dev Base smart contract for an Aave v2 rates update on Ethereum.
99
* @author BGD Labs
1010
*/
1111
// TODO: Add rates factory address after deploying
12-
abstract contract AaveV2PayloadEthereum is
13-
AaveV2PayloadBase(IEngine(AaveV2Ethereum.CONFIG_ENGINE))
14-
{
12+
abstract contract AaveV2PayloadEthereum is AaveV2Payload(IEngine(AaveV2Ethereum.CONFIG_ENGINE)) {
1513

1614
}

src/v2-config-engine/AaveV2PayloadEthereumAMM.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
pragma solidity ^0.8.0;
33

44
import {AaveV2EthereumAMM} from 'aave-address-book/AaveV2EthereumAMM.sol';
5-
import './AaveV2PayloadBase.sol';
5+
import './AaveV2Payload.sol';
66

77
/**
88
* @dev Base smart contract for an Aave v2 rates update on Ethereum.
99
* @author BGD Labs
1010
*/
1111
// TODO: Add rates factory address after deploying
1212
abstract contract AaveV2PayloadEthereumAMM is
13-
AaveV2PayloadBase(IEngine(AaveV2EthereumAMM.CONFIG_ENGINE))
13+
AaveV2Payload(IEngine(AaveV2EthereumAMM.CONFIG_ENGINE))
1414
{
1515

1616
}

src/v2-config-engine/AaveV2PayloadPolygon.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
pragma solidity ^0.8.0;
33

44
import {AaveV2Polygon} from 'aave-address-book/AaveV2Polygon.sol';
5-
import './AaveV2PayloadBase.sol';
5+
import './AaveV2Payload.sol';
66

77
/**
88
* @dev Base smart contract for an Aave v2 rates update on Avalanche.
99
* @author BGD Labs
1010
*/
1111
// TODO: Add rates factory address after deploying
12-
abstract contract AaveV2PayloadPolygon is AaveV2PayloadBase(IEngine(AaveV2Polygon.CONFIG_ENGINE)) {
12+
abstract contract AaveV2PayloadPolygon is AaveV2Payload(IEngine(AaveV2Polygon.CONFIG_ENGINE)) {
1313

1414
}

src/v2-config-engine/IAaveV2ConfigEngine.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
44
import {ILendingPoolConfigurator} from 'aave-address-book/AaveV2.sol';
55
import {IV2RateStrategyFactory} from './IV2RateStrategyFactory.sol';
66

7-
/// @dev Examples here assume the usage of the `AaveV2PayloadBase` base contracts
7+
/// @dev Examples here assume the usage of the `AaveV2Payload` base contracts
88
/// contained in this same repository
99
interface IAaveV2ConfigEngine {
1010
/**
@@ -49,5 +49,4 @@ interface IAaveV2ConfigEngine {
4949
function RATE_STRATEGIES_FACTORY() external view returns (IV2RateStrategyFactory);
5050

5151
function POOL_CONFIGURATOR() external view returns (ILendingPoolConfigurator);
52-
5352
}

tests/mocks/AaveV2EthereumRatesUpdate.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
import '../../src/v2-config-engine/AaveV2PayloadBase.sol';
4+
import '../../src/v2-config-engine/AaveV2Payload.sol';
55
import {AaveV2EthereumAssets} from 'aave-address-book/AaveV2Ethereum.sol';
66

77
/**
88
* @dev Smart contract for a mock rates update, for testing purposes
99
* IMPORTANT Parameters are pseudo-random, DON'T USE THIS ANYHOW IN PRODUCTION
1010
* @author BGD Labs
1111
*/
12-
contract AaveV2EthereumRatesUpdate is AaveV2PayloadBase {
13-
constructor(IEngine customEngine) AaveV2PayloadBase(customEngine) {}
12+
contract AaveV2EthereumRatesUpdate is AaveV2Payload {
13+
constructor(IEngine customEngine) AaveV2Payload(customEngine) {}
1414

1515
function rateStrategiesUpdates()
1616
public

0 commit comments

Comments
 (0)