generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add snapshot tests for generator
- Loading branch information
1 parent
af8e11e
commit 5ba7d2b
Showing
16 changed files
with
1,287 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`feature: capUpdates > should properly generate files 1`] = ` | ||
{ | ||
"jsonConfig": "import {ConfigFile} from '../../generator/types'; | ||
export const config: ConfigFile = { | ||
rootOptions: { | ||
pools: ['AaveV3Ethereum'], | ||
title: 'test', | ||
shortName: 'Test', | ||
date: '20231023', | ||
author: 'test', | ||
discussion: 'test', | ||
}, | ||
poolOptions: { | ||
AaveV3Ethereum: { | ||
configs: {CAPS_UPDATE: [{asset: 'WETH', supplyCap: '10000', borrowCap: '5000'}]}, | ||
cache: {blockNumber: 42}, | ||
}, | ||
}, | ||
}; | ||
", | ||
"payloads": [ | ||
{ | ||
"contractName": "AaveV3Ethereum_Test_20231023", | ||
"payload": "// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; | ||
import {RiskStewardsEthereum} from '../../../../scripts/networks/RiskStewardsEthereum.s.sol'; | ||
import {IAaveV3ConfigEngine} from 'aave-v3-periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol'; | ||
/** | ||
* @title test | ||
* @author test | ||
* - discussion: test | ||
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false | ||
*/ | ||
contract AaveV3Ethereum_Test_20231023 is RiskStewardsEthereum { | ||
function name() public pure override returns (string memory) { | ||
return 'AaveV3Ethereum_Test_20231023'; | ||
} | ||
function capsUpdates() public pure override returns (IAaveV3ConfigEngine.CapsUpdate[] memory) { | ||
IAaveV3ConfigEngine.CapsUpdate[] memory capsUpdate = new IAaveV3ConfigEngine.CapsUpdate[](1); | ||
capsUpdate[0] = IAaveV3ConfigEngine.CapsUpdate({ | ||
asset: AaveV3EthereumAssets.WETH_UNDERLYING, | ||
supplyCap: 10_000, | ||
borrowCap: 5_000 | ||
}); | ||
return capsUpdate; | ||
} | ||
} | ||
", | ||
"pool": "AaveV3Ethereum", | ||
}, | ||
], | ||
} | ||
`; | ||
|
||
exports[`feature: capUpdates > should return reasonable code 1`] = ` | ||
{ | ||
"code": { | ||
"fn": [ | ||
"function capsUpdates() public pure override returns (IAaveV3ConfigEngine.CapsUpdate[] memory) { | ||
IAaveV3ConfigEngine.CapsUpdate[] memory capsUpdate = new IAaveV3ConfigEngine.CapsUpdate[](1); | ||
capsUpdate[0] = IAaveV3ConfigEngine.CapsUpdate({ | ||
asset: AaveV3EthereumAssets.WETH_UNDERLYING, | ||
supplyCap: 10_000, | ||
borrowCap: 5_000 | ||
}); | ||
return capsUpdate; | ||
}", | ||
], | ||
}, | ||
} | ||
`; |
105 changes: 105 additions & 0 deletions
105
generator/features/__snapshots__/collateralUpdates.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`feature: collateralUpdates > should properly generate files 1`] = ` | ||
{ | ||
"jsonConfig": "import {ConfigFile} from '../../generator/types'; | ||
export const config: ConfigFile = { | ||
rootOptions: { | ||
pools: ['AaveV3Ethereum'], | ||
title: 'test', | ||
shortName: 'Test', | ||
date: '20231023', | ||
author: 'test', | ||
discussion: 'test', | ||
}, | ||
poolOptions: { | ||
AaveV3Ethereum: { | ||
configs: { | ||
COLLATERALS_UPDATE: [ | ||
{ | ||
asset: 'DAI', | ||
ltv: '8500', | ||
liqThreshold: '8800', | ||
liqBonus: '600', | ||
debtCeiling: '', | ||
liqProtocolFee: '1200', | ||
}, | ||
], | ||
}, | ||
cache: {blockNumber: 42}, | ||
}, | ||
}, | ||
}; | ||
", | ||
"payloads": [ | ||
{ | ||
"contractName": "AaveV3Ethereum_Test_20231023", | ||
"payload": "// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; | ||
import {RiskStewardsEthereum} from '../../../../scripts/networks/RiskStewardsEthereum.s.sol'; | ||
import {EngineFlags} from 'aave-v3-periphery/contracts/v3-config-engine/EngineFlags.sol'; | ||
import {IAaveV3ConfigEngine} from 'aave-v3-periphery/contracts/v3-config-engine/IAaveV3ConfigEngine.sol'; | ||
/** | ||
* @title test | ||
* @author test | ||
* - discussion: test | ||
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false | ||
*/ | ||
contract AaveV3Ethereum_Test_20231023 is RiskStewardsEthereum { | ||
function name() public pure override returns (string memory) { | ||
return 'AaveV3Ethereum_Test_20231023'; | ||
} | ||
function collateralsUpdates() | ||
public | ||
pure | ||
override | ||
returns (IAaveV3ConfigEngine.CollateralUpdate[] memory) | ||
{ | ||
IAaveV3ConfigEngine.CollateralUpdate[] | ||
memory collateralUpdate = new IAaveV3ConfigEngine.CollateralUpdate[](1); | ||
collateralUpdate[0] = IAaveV3ConfigEngine.CollateralUpdate({ | ||
asset: AaveV3EthereumAssets.DAI_UNDERLYING, | ||
ltv: 8_500_00, | ||
liqThreshold: 8_800_00, | ||
liqBonus: 600_00, | ||
debtCeiling: EngineFlags.KEEP_CURRENT, | ||
liqProtocolFee: 1_200_00 | ||
}); | ||
return collateralUpdate; | ||
} | ||
} | ||
", | ||
"pool": "AaveV3Ethereum", | ||
}, | ||
], | ||
} | ||
`; | ||
|
||
exports[`feature: collateralUpdates > should return reasonable code 1`] = ` | ||
{ | ||
"code": { | ||
"fn": [ | ||
"function collateralsUpdates() public pure override returns (IAaveV3ConfigEngine.CollateralUpdate[] memory) { | ||
IAaveV3ConfigEngine.CollateralUpdate[] memory collateralUpdate = new IAaveV3ConfigEngine.CollateralUpdate[](1); | ||
collateralUpdate[0] = IAaveV3ConfigEngine.CollateralUpdate({ | ||
asset: AaveV3EthereumAssets.DAI_UNDERLYING, | ||
ltv: 8_500_00, | ||
liqThreshold: 8_800_00, | ||
liqBonus: 600_00, | ||
debtCeiling: EngineFlags.KEEP_CURRENT, | ||
liqProtocolFee: 1_200_00 | ||
}); | ||
return collateralUpdate; | ||
}", | ||
], | ||
}, | ||
} | ||
`; |
103 changes: 103 additions & 0 deletions
103
generator/features/__snapshots__/lstPriceCapUpdates.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`feature: lstPriceCapUpdates > should properly generate files 1`] = ` | ||
{ | ||
"jsonConfig": "import {ConfigFile} from '../../generator/types'; | ||
export const config: ConfigFile = { | ||
rootOptions: { | ||
pools: ['AaveV3Ethereum'], | ||
title: 'test', | ||
shortName: 'Test', | ||
date: '20231023', | ||
author: 'test', | ||
discussion: 'test', | ||
}, | ||
poolOptions: { | ||
AaveV3Ethereum: { | ||
configs: { | ||
LST_PRICE_CAP_UPDATE: [ | ||
{ | ||
asset: 'wstETH', | ||
snapshotTimestamp: '1723621200', | ||
snapshotRatio: '1177101458282319168', | ||
maxYearlyRatioGrowthPercent: '10.64', | ||
}, | ||
], | ||
}, | ||
cache: {blockNumber: 42}, | ||
}, | ||
}, | ||
}; | ||
", | ||
"payloads": [ | ||
{ | ||
"contractName": "AaveV3Ethereum_Test_20231023", | ||
"payload": "// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
import {AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; | ||
import {RiskStewardsEthereum} from '../../../../scripts/networks/RiskStewardsEthereum.s.sol'; | ||
import {IRiskSteward, IPriceCapAdapter} from '../../../interfaces/IRiskSteward.sol'; | ||
/** | ||
* @title test | ||
* @author test | ||
* - discussion: test | ||
* - deploy-command: make run-script contract=src/contracts/updates/20231023_AaveV3Ethereum_Test/AaveV3Ethereum_Test_20231023.sol:AaveV3Ethereum_Test_20231023 network=mainnet broadcast=false | ||
*/ | ||
contract AaveV3Ethereum_Test_20231023 is RiskStewardsEthereum { | ||
function name() public pure override returns (string memory) { | ||
return 'AaveV3Ethereum_Test_20231023'; | ||
} | ||
function lstPriceCapsUpdates() | ||
public | ||
pure | ||
override | ||
returns (IRiskSteward.PriceCapLstUpdate[] memory) | ||
{ | ||
IRiskSteward.PriceCapLstUpdate[] memory priceCapUpdates = new IRiskSteward.PriceCapLstUpdate[]( | ||
1 | ||
); | ||
priceCapUpdates[0] = IRiskSteward.PriceCapLstUpdate({ | ||
oracle: AaveV3EthereumAssets.wstETH_ORACLE, | ||
priceCapUpdateParams: IPriceCapAdapter.PriceCapUpdateParams({ | ||
snapshotTimestamp: 1723621200, | ||
snapshotRatio: 1177101458282319168, | ||
maxYearlyRatioGrowthPercent: 10_64 | ||
}) | ||
}); | ||
return priceCapUpdates; | ||
} | ||
} | ||
", | ||
"pool": "AaveV3Ethereum", | ||
}, | ||
], | ||
} | ||
`; | ||
|
||
exports[`feature: lstPriceCapUpdates > should return reasonable code 1`] = ` | ||
{ | ||
"code": { | ||
"fn": [ | ||
"function lstPriceCapsUpdates() public pure override returns (IRiskSteward.PriceCapLstUpdate[] memory) { | ||
IRiskSteward.PriceCapLstUpdate[] memory priceCapUpdates = new IRiskSteward.PriceCapLstUpdate[](1); | ||
priceCapUpdates[0] = IRiskSteward.PriceCapLstUpdate({ | ||
oracle: AaveV3EthereumAssets.wstETH_ORACLE, | ||
priceCapUpdateParams: IPriceCapAdapter.PriceCapUpdateParams({ | ||
snapshotTimestamp: 1723621200, | ||
snapshotRatio: 1177101458282319168, | ||
maxYearlyRatioGrowthPercent: 10_64, | ||
}) | ||
}); | ||
return priceCapUpdates; | ||
}", | ||
], | ||
}, | ||
} | ||
`; |
Oops, something went wrong.