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 25, 2024
1 parent 07a3923 commit 6adec8e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 42 deletions.
34 changes: 13 additions & 21 deletions test/fork/add-asset-cbbtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,62 +139,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 +233,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 6adec8e

Please sign in to comment.