Skip to content

Commit

Permalink
test: fix integration tests after adding government deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Sep 29, 2023
1 parent a52a621 commit 1056df3
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 88 deletions.
2 changes: 1 addition & 1 deletion subgraphs/isolated-pools/config/local.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"network": "hardhat",
"poolRegistryAddress": "0x5bf5b11053e734690269c6b9d438f8c9d48f528a",
"poolRegistryAddress": "0xffa7CA1AEEEbBc30C874d32C7e22F052BbEa0429",
"poolLensAddress": "0x3aade2dcd2df6a8cac689ee797591b2913658659",
"startBlock": 0
}
79 changes: 40 additions & 39 deletions subgraphs/isolated-pools/tests/integration/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ export const SYNC_DELAY = 2000;

export const defaultMarkets = [
{
id: '0x2a810409872afc346f9b5b26571fd6ec42ea4849',
id: '0x8a93d247134d91e0de6f96547cb0204e5be8e5d8',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
borrowRateMantissa: '0',
cashMantissa: '10000000000000000000',
collateralFactorMantissa: '700000000000000000',
exchangeRateMantissa: '10000000000000000000000000000',
interestRateModelAddress: '0x5fc748f1feb28d7b76fa1c6b07d8ba2d5535177c',
interestRateModelAddress: '0x2a810409872afc346f9b5b26571fd6ec42ea4849',
name: 'Venus ANKR',
reservesMantissa: '0',
supplyRateMantissa: '0',
Expand All @@ -39,17 +39,17 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0x38a024c0b412b9d1db8bc398140d00f5af3093d4',
id: '0xb82008565fdc7e44609fa118a4a681e92581e680',
pool: {
id: '0xab16a69a5a8c12c732e0deff4be56a70bb64c926',
id: '0x1f10f3ba7acb61b2f50b9d6ddcf91a6f787c0e82',
__typename: 'Pool',
},
badDebtMantissa: '0',
borrowRateMantissa: '951293759',
borrowRateMantissa: '0',
cashMantissa: '10000000000000000000',
collateralFactorMantissa: '600000000000000000',
exchangeRateMantissa: '10000000000000000000000000000',
interestRateModelAddress: '0x525c7063e7c20997baae9bda922159152d0e8417',
interestRateModelAddress: '0x5fc748f1feb28d7b76fa1c6b07d8ba2d5535177c',
name: 'Venus BNX',
reservesMantissa: '0',
supplyRateMantissa: '0',
Expand All @@ -72,17 +72,17 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0x40918ba7f132e0acba2ce4de4c4baf9bd2d7d849',
id: '0xd6e1afe5ca8d00a2efc01b89997abe2de47fdfaf',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
borrowRateMantissa: '951293759',
borrowRateMantissa: '0',
cashMantissa: '10000000000000000000',
collateralFactorMantissa: '600000000000000000',
exchangeRateMantissa: '10000000000000000000000000000',
interestRateModelAddress: '0x525c7063e7c20997baae9bda922159152d0e8417',
interestRateModelAddress: '0x5fc748f1feb28d7b76fa1c6b07d8ba2d5535177c',
name: 'Venus NFT',
reservesMantissa: '0',
supplyRateMantissa: '0',
Expand All @@ -105,17 +105,17 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0x8a93d247134d91e0de6f96547cb0204e5be8e5d8',
id: '0xf32d39ff9f6aa7a7a64d7a4f00a54826ef791a55',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
borrowRateMantissa: '0',
cashMantissa: '10000000000000000000',
collateralFactorMantissa: '700000000000000000',
exchangeRateMantissa: '10000000000000000000000000000',
interestRateModelAddress: '0x5fc748f1feb28d7b76fa1c6b07d8ba2d5535177c',
interestRateModelAddress: '0x2a810409872afc346f9b5b26571fd6ec42ea4849',
name: 'Venus MBOX',
reservesMantissa: '0',
supplyRateMantissa: '0',
Expand All @@ -138,9 +138,9 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0x99dbe4aea58e518c50a1c04ae9b48c9f6354612f',
id: '0xca8c8688914e0f7096c920146cd0ad85cd7ae8b9',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
Expand Down Expand Up @@ -171,17 +171,17 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0xb82008565fdc7e44609fa118a4a681e92581e680',
id: '0xb9beecd1a582768711de1ee7b0a1d582d9d72a6c',
pool: {
id: '0xab16a69a5a8c12c732e0deff4be56a70bb64c926',
id: '0x1f10f3ba7acb61b2f50b9d6ddcf91a6f787c0e82',
__typename: 'Pool',
},
badDebtMantissa: '0',
borrowRateMantissa: '0',
cashMantissa: '10000000000000000000',
collateralFactorMantissa: '700000000000000000',
exchangeRateMantissa: '10000000000000000000000000000',
interestRateModelAddress: '0x5fc748f1feb28d7b76fa1c6b07d8ba2d5535177c',
interestRateModelAddress: '0x2a810409872afc346f9b5b26571fd6ec42ea4849',
name: 'Venus BTCB',
reservesMantissa: '0',
supplyRateMantissa: '0',
Expand All @@ -204,17 +204,17 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0xb9beecd1a582768711de1ee7b0a1d582d9d72a6c',
id: '0x40918ba7f132e0acba2ce4de4c4baf9bd2d7d849',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
borrowRateMantissa: '951293759',
cashMantissa: '10000000000000000000',
collateralFactorMantissa: '600000000000000000',
exchangeRateMantissa: '10000000000000000000000000000',
interestRateModelAddress: '0x525c7063e7c20997baae9bda922159152d0e8417',
interestRateModelAddress: '0x5fc748f1feb28d7b76fa1c6b07d8ba2d5535177c',
name: 'Venus ankrBNB',
reservesMantissa: '0',
supplyRateMantissa: '0',
Expand All @@ -237,17 +237,17 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0xd6e1afe5ca8d00a2efc01b89997abe2de47fdfaf',
id: '0x6f6f570f45833e249e27022648a26f4076f48f78',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
borrowRateMantissa: '951293759',
borrowRateMantissa: '0',
cashMantissa: '10000000000000000000',
collateralFactorMantissa: '600000000000000000',
exchangeRateMantissa: '10000000000000000000000000000',
interestRateModelAddress: '0x525c7063e7c20997baae9bda922159152d0e8417',
interestRateModelAddress: '0x5fc748f1feb28d7b76fa1c6b07d8ba2d5535177c',
name: 'Venus stkBNB',
reservesMantissa: '0',
supplyRateMantissa: '0',
Expand All @@ -270,17 +270,17 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0xf32d39ff9f6aa7a7a64d7a4f00a54826ef791a55',
id: '0x99dbe4aea58e518c50a1c04ae9b48c9f6354612f',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
borrowRateMantissa: '951293759',
borrowRateMantissa: '0',
cashMantissa: '10000000000000000000',
collateralFactorMantissa: '600000000000000000',
exchangeRateMantissa: '10000000000000000000000000000',
interestRateModelAddress: '0x525c7063e7c20997baae9bda922159152d0e8417',
interestRateModelAddress: '0x5fc748f1feb28d7b76fa1c6b07d8ba2d5535177c',
name: 'Venus RACA',
reservesMantissa: '0',
supplyRateMantissa: '0',
Expand All @@ -303,34 +303,35 @@ export const defaultMarkets = [
__typename: 'Market',
},
];

export const defaultPools = [
{
id: '0xab16a69a5a8c12c732e0deff4be56a70bb64c926',
id: '0x1f10f3ba7acb61b2f50b9d6ddcf91a6f787c0e82',
name: 'Pool 1',
creator: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
blockPosted: '235',
blockPosted: '238',
timestampPosted: '1694787800',
category: '',
logoUrl: '',
description: '',
priceOracleAddress: '0x68b1d87f95878fe05b998f19b66f4baba5de1aed',
priceOracleAddress: '0x987e855776c03a4682639eeb14e65b3089ee6310',
closeFactorMantissa: '500000000000000000',
liquidationIncentiveMantissa: '3000000000000000000',
minLiquidatableCollateralMantissa: '200000000000000000000',
liquidationIncentiveMantissa: '1000000000000000000',
minLiquidatableCollateralMantissa: '100000000000000000000',
markets: [Array],
__typename: 'Pool',
},
{
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
name: 'Pool 2',
creator: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
blockPosted: '237',
blockPosted: '240',
timestampPosted: '1694787802',
category: '',
logoUrl: '',
description: '',
priceOracleAddress: '0x68b1d87f95878fe05b998f19b66f4baba5de1aed',
closeFactorMantissa: '50000000000000000',
priceOracleAddress: '0x987e855776c03a4682639eeb14e65b3089ee6310',
closeFactorMantissa: '500000000000000000',
liquidationIncentiveMantissa: '1000000000000000000',
minLiquidatableCollateralMantissa: '100000000000000000000',
markets: [Array],
Expand Down
73 changes: 35 additions & 38 deletions subgraphs/isolated-pools/tests/integration/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@ import { scaleValue, waitForSubgraphToBeSynced } from 'venus-subgraph-utils';

import subgraphClient from '../../subgraph-client';
import { defaultMarkets } from './constants';
import deploy from './utils/deploy';

describe('Pools', function () {
let acc1: Signer;
let root: SignerWithAddress;
let accessControlManager: Contract;

const syncDelay = 3000;
const syncDelay = 6000;

before(async function () {
this.timeout(500000); // sometimes it takes a long time
const signers = await ethers.getSigners();
[root] = await ethers.getSigners();
acc1 = signers[1];
await deploy();

accessControlManager = await ethers.getContract('AccessControlManager');

Expand Down Expand Up @@ -72,51 +70,50 @@ describe('Pools', function () {
root.address,
);
tx.wait();
const { data: marketsData } = await subgraphClient.getMarkets();
const { markets } = marketsData!;
markets.forEach(async m => {
const comptrollerProxy = await ethers.getContractAt('Comptroller', m.pool.id);
comptrollerProxy.supportMarket(m.id);
});
await waitForSubgraphToBeSynced(syncDelay);
// const { data: marketsData } = await subgraphClient.getMarkets();
// const { markets } = marketsData!;
});

it('handles MarketAdded event', async function () {
// check markets
const { data: marketsData } = await subgraphClient.getMarkets();
const { markets } = marketsData!;
expect(markets.length).to.equal(9);

markets.forEach((m, idx) => {
const defaultMarket = defaultMarkets[idx];
expect(m.pool.id).to.equal(defaultMarket.pool.id);
expect(m.borrowRateMantissa).to.equal(defaultMarket.borrowRateMantissa);
expect(m.cashMantissa).to.equal(defaultMarket.cashMantissa);
expect(m.collateralFactorMantissa).to.equal(defaultMarket.collateralFactorMantissa);
expect(m.exchangeRateMantissa).to.equal(defaultMarket.exchangeRateMantissa);
expect(m.interestRateModelAddress).to.equal(defaultMarket.interestRateModelAddress);
expect(m.name).to.equal(defaultMarket.name);
expect(m.reservesMantissa).to.equal(defaultMarket.reservesMantissa);
expect(m.supplyRateMantissa).to.equal(defaultMarket.supplyRateMantissa);
expect(m.symbol).to.equal(defaultMarket.symbol);
expect(m.underlyingAddress).to.equal(defaultMarket.underlyingAddress);
expect(m.underlyingName).to.equal(defaultMarket.underlyingName);
expect(m.underlyingSymbol).to.equal(defaultMarket.underlyingSymbol);
expect(m.borrowCapMantissa).to.equal(defaultMarket.borrowCapMantissa);
expect(m.supplyCapMantissa).to.equal(defaultMarket.supplyCapMantissa);
expect(m.accrualBlockNumber).to.equal(defaultMarket.accrualBlockNumber);
expect(m.blockTimestamp).to.not.be.equal(defaultMarket.blockTimestamp);
expect(m.borrowIndexMantissa).to.equal(defaultMarket.borrowIndexMantissa);
expect(m.reserveFactorMantissa).to.equal(defaultMarket.reserveFactorMantissa);
expect(m.underlyingPriceCents).to.equal(defaultMarket.underlyingPriceCents);
expect(m.underlyingDecimals).to.equal(defaultMarket.underlyingDecimals);
expect(m.supplierCount).to.equal(defaultMarket.supplierCount);
expect(m.borrowerCount).to.equal(defaultMarket.borrowerCount);
expect(markets.length).to.equal(9);
console.log(markets);
markets.forEach(m => {
const defaultMarket = defaultMarkets.find(dm => m.id === dm.id);
console.log(m, m.symbol, defaultMarket);
expect(m.pool.id).to.equal(defaultMarket?.pool.id);
expect(m.borrowRateMantissa).to.equal(defaultMarket?.borrowRateMantissa);
expect(m.cashMantissa).to.equal(defaultMarket?.cashMantissa);
expect(m.collateralFactorMantissa).to.equal(defaultMarket?.collateralFactorMantissa);
expect(m.exchangeRateMantissa).to.equal(defaultMarket?.exchangeRateMantissa);
expect(m.interestRateModelAddress).to.equal(defaultMarket?.interestRateModelAddress);
expect(m.name).to.equal(defaultMarket?.name);
expect(m.reservesMantissa).to.equal(defaultMarket?.reservesMantissa);
expect(m.supplyRateMantissa).to.equal(defaultMarket?.supplyRateMantissa);
expect(m.symbol).to.equal(defaultMarket?.symbol);
expect(m.underlyingAddress).to.equal(defaultMarket?.underlyingAddress);
expect(m.underlyingName).to.equal(defaultMarket?.underlyingName);
expect(m.underlyingSymbol).to.equal(defaultMarket?.underlyingSymbol);
expect(m.borrowCapMantissa).to.equal(defaultMarket?.borrowCapMantissa);
expect(m.supplyCapMantissa).to.equal(defaultMarket?.supplyCapMantissa);
expect(m.accrualBlockNumber).to.equal(defaultMarket?.accrualBlockNumber);
expect(m.blockTimestamp).to.not.be.equal(defaultMarket?.blockTimestamp);
expect(m.borrowIndexMantissa).to.equal(defaultMarket?.borrowIndexMantissa);
expect(m.reserveFactorMantissa).to.equal(defaultMarket?.reserveFactorMantissa);
expect(m.underlyingPriceCents).to.equal(defaultMarket?.underlyingPriceCents);
expect(m.underlyingDecimals).to.equal(defaultMarket?.underlyingDecimals);
expect(m.supplierCount).to.equal(defaultMarket?.supplierCount);
expect(m.borrowerCount).to.equal(defaultMarket?.borrowerCount);
});
});

it('handles MarketEntered and MarketExited events', async function () {
const account1Address = await acc1.getAddress();
await waitForSubgraphToBeSynced(syncDelay * 2);
await waitForSubgraphToBeSynced(syncDelay);

// check account
const { data } = await subgraphClient.getAccountById(account1Address.toLowerCase());
Expand Down Expand Up @@ -268,7 +265,7 @@ describe('Pools', function () {
const { data } = await subgraphClient.getMarkets();
const { markets: marketsBeforeUpdate } = data!;

expect(marketsBeforeUpdate[0].borrowCapMantissa).to.equal('3000000000000000000000000');
expect(marketsBeforeUpdate[0].borrowCapMantissa).to.equal('100000000000000000000');

const comptrollerProxy = await ethers.getContractAt(
'Comptroller',
Expand Down Expand Up @@ -308,7 +305,7 @@ describe('Pools', function () {
const { data } = await subgraphClient.getMarkets();
const { markets: marketsBeforeUpdate } = data!;

expect(marketsBeforeUpdate[0].supplyCapMantissa).to.equal('3000000000000000000000000');
expect(marketsBeforeUpdate[0].supplyCapMantissa).to.equal('100000000000000000000');

const comptrollerProxy = await ethers.getContractAt(
'Comptroller',
Expand Down
Loading

0 comments on commit 1056df3

Please sign in to comment.