Skip to content

Commit

Permalink
test: clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rackstar committed Oct 30, 2024
1 parent 35fe804 commit c00920e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 46 deletions.
38 changes: 13 additions & 25 deletions test/fork/add-asset-cbbtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ describe('add cbBTC asset to Pool', function () {
this.stakingProducts = await ethers.getContractAt(abis.StakingProducts, addresses.StakingProducts);
this.swapOperator = await ethers.getContractAt(abis.SwapOperator, addresses.SwapOperator);
this.stakingPool = await ethers.getContractAt(abis.StakingPool, V2Addresses.StakingPoolImpl);

this.priceFeedOracle = await ethers.getContractAt(abis.PriceFeedOracle, addresses.PriceFeedOracle);
// const poolPriceFeedOracle = await this.pool.priceFeedOracle();
// this.priceFeedOracle = await ethers.getContractAt(abis.PriceFeedOracle, poolPriceFeedOracle);

this.tokenController = await ethers.getContractAt(abis.TokenController, addresses.TokenController);
this.individualClaims = await ethers.getContractAt(abis.IndividualClaims, addresses.IndividualClaims);
this.quotationData = await ethers.getContractAt(abis.LegacyQuotationData, addresses.LegacyQuotationData);
Expand Down Expand Up @@ -139,62 +135,56 @@ describe('add cbBTC asset to Pool', function () {
});

it('Deploy new PriceFeedOracle contract', async function () {
const poolAssets = {
dai: {
const priceFeedAssets = [
{
address: Address.DAI_ADDRESS,
aggregator: PriceFeedOracle.DAI_ETH_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.ETH,
decimals: 18,
},
stETH: {
{
address: Address.STETH_ADDRESS,
aggregator: PriceFeedOracle.STETH_ETH_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.ETH,
decimals: 18,
},
enzyme: {
{
address: EnzymeAdress.ENZYMEV4_VAULT_PROXY_ADDRESS,
aggregator: PriceFeedOracle.ENZYMEV4_VAULT_ETH_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.ETH,
decimals: 18,
},
rETH: {
{
address: Address.RETH_ADDRESS,
aggregator: PriceFeedOracle.RETH_ETH_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.ETH,
decimals: 18,
},
usdc: {
{
address: Address.USDC_ADDRESS,
aggregator: PriceFeedOracle.USDC_ETH_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.ETH,
decimals: 6,
},
cbBTC: {
{
address: Address.CBBTC_ADDRESS,
aggregator: PriceFeedOracle.CBBTC_USD_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.USD,
decimals: 8,
},
ethUsd: {
{
address: Address.ETH,
aggregator: PriceFeedOracle.ETH_USD_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.USD,
decimals: 18,
},
};

const assets = Object.values(poolAssets);
const assetAddresses = assets.map(asset => asset.address);
const assetAggregators = assets.map(asset => asset.aggregator);
const aggregatorTypes = assets.map(asset => asset.aggregatorType);
const assetDecimals = assets.map(asset => asset.decimals);
];

this.priceFeedOracle = await ethers.deployContract('PriceFeedOracle', [
assetAddresses,
assetAggregators,
aggregatorTypes,
assetDecimals,
priceFeedAssets.map(asset => asset.address),
priceFeedAssets.map(asset => asset.aggregator),
priceFeedAssets.map(asset => asset.aggregatorType),
priceFeedAssets.map(asset => asset.decimals),
this.safeTracker.address,
]);
});
Expand Down Expand Up @@ -239,8 +229,6 @@ describe('add cbBTC asset to Pool', function () {
expect(latestPoolAsset.assetAddress).to.equal(Address.CBBTC_ADDRESS);
expect(latestPoolAsset.isCoverAsset).to.equal(true);
expect(latestPoolAsset.isAbandoned).to.equal(false);

console.info('cbBTC asset added - Snapshot ID: ', await evm.snapshot());
});

it('fail to buy cover that only supports DAI', async function () {
Expand Down
35 changes: 15 additions & 20 deletions test/fork/basic-functionality-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1134,61 +1134,56 @@ describe('basic functionality tests', function () {
]);

// PriceFeedOracle.sol
const priceFeedAssets = {
dai: {
const priceFeedAssets = [
{
address: Address.DAI_ADDRESS,
aggregator: PriceFeedOracle.DAI_ETH_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.ETH,
decimals: 18,
},
stETH: {
{
address: Address.STETH_ADDRESS,
aggregator: PriceFeedOracle.STETH_ETH_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.ETH,
decimals: 18,
},
enzyme: {
{
address: EnzymeAdress.ENZYMEV4_VAULT_PROXY_ADDRESS,
aggregator: PriceFeedOracle.ENZYMEV4_VAULT_ETH_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.ETH,
decimals: 18,
},
rETH: {
{
address: Address.RETH_ADDRESS,
aggregator: PriceFeedOracle.RETH_ETH_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.ETH,
decimals: 18,
},
usdc: {
{
address: Address.USDC_ADDRESS,
aggregator: PriceFeedOracle.USDC_ETH_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.ETH,
decimals: 6,
},
cbBTC: {
{
address: Address.CBBTC_ADDRESS,
aggregator: PriceFeedOracle.CBBTC_USD_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.USD,
decimals: 8,
},
ethUsd: {
{
address: Address.ETH,
aggregator: PriceFeedOracle.ETH_USD_PRICE_FEED_ORACLE_AGGREGATOR,
aggregatorType: AggregatorType.USD,
decimals: 18,
},
};
];

const assets = Object.values(priceFeedAssets);
const assetAddresses = assets.map(asset => asset.address);
const assetAggregators = assets.map(asset => asset.aggregator);
const aggregatorTypes = assets.map(asset => asset.aggregatorType);
const assetDecimals = assets.map(asset => asset.decimals);
const priceFeedOracle = await deployContract('PriceFeedOracle', [
assetAddresses,
assetAggregators,
aggregatorTypes,
assetDecimals,
this.priceFeedOracle = await ethers.deployContract('PriceFeedOracle', [
priceFeedAssets.map(asset => asset.address),
priceFeedAssets.map(asset => asset.aggregator),
priceFeedAssets.map(asset => asset.aggregatorType),
priceFeedAssets.map(asset => asset.decimals),
this.safeTracker.address,
]);

Expand All @@ -1197,7 +1192,7 @@ describe('basic functionality tests', function () {
// P1 - Pool.sol
const pool = await deployContract('Pool', [
this.master.address,
priceFeedOracle.address,
this.priceFeedOracle.address,
swapOperatorAddress,
this.nxm.address,
this.pool.address,
Expand Down
1 change: 0 additions & 1 deletion test/unit/Pool/updateParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { ethers } = require('hardhat');
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');

const setup = require('./setup');
const { AggregatorType } = require('../../fork/utils');

const { toBytes8 } = require('../utils').helpers;
const { PoolUintParamType, PoolAddressParamType } = require('../utils').constants;
Expand Down

0 comments on commit c00920e

Please sign in to comment.