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 28, 2023
1 parent a52a621 commit afc905c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 38 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
}
55 changes: 28 additions & 27 deletions subgraphs/isolated-pools/tests/integration/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export const SYNC_DELAY = 2000;

export const defaultMarkets = [
{
id: '0x2a810409872afc346f9b5b26571fd6ec42ea4849',
id: '0x8a93d247134d91e0de6f96547cb0204e5be8e5d8',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
Expand Down Expand Up @@ -39,9 +39,9 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0x38a024c0b412b9d1db8bc398140d00f5af3093d4',
id: '0xb82008565fdc7e44609fa118a4a681e92581e680',
pool: {
id: '0xab16a69a5a8c12c732e0deff4be56a70bb64c926',
id: '0x1f10f3ba7acb61b2f50b9d6ddcf91a6f787c0e82',
__typename: 'Pool',
},
badDebtMantissa: '0',
Expand Down Expand Up @@ -72,9 +72,9 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0x40918ba7f132e0acba2ce4de4c4baf9bd2d7d849',
id: '0xd6e1afe5ca8d00a2efc01b89997abe2de47fdfaf',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
Expand Down Expand Up @@ -105,9 +105,9 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0x8a93d247134d91e0de6f96547cb0204e5be8e5d8',
id: '0xf32d39ff9f6aa7a7a64d7a4f00a54826ef791a55',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
Expand Down Expand Up @@ -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,9 +171,9 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0xb82008565fdc7e44609fa118a4a681e92581e680',
id: '0xb9beecd1a582768711de1ee7b0a1d582d9d72a6c',
pool: {
id: '0xab16a69a5a8c12c732e0deff4be56a70bb64c926',
id: '0x1f10f3ba7acb61b2f50b9d6ddcf91a6f787c0e82',
__typename: 'Pool',
},
badDebtMantissa: '0',
Expand Down Expand Up @@ -204,9 +204,9 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0xb9beecd1a582768711de1ee7b0a1d582d9d72a6c',
id: '0x40918ba7f132e0acba2ce4de4c4baf9bd2d7d849',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
Expand Down Expand Up @@ -237,9 +237,9 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0xd6e1afe5ca8d00a2efc01b89997abe2de47fdfaf',
id: '0x6f6f570f45833e249e27022648a26f4076f48f78',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
Expand Down Expand Up @@ -270,9 +270,9 @@ export const defaultMarkets = [
__typename: 'Market',
},
{
id: '0xf32d39ff9f6aa7a7a64d7a4f00a54826ef791a55',
id: '0x99dbe4aea58e518c50a1c04ae9b48c9f6354612f',
pool: {
id: '0xe3011a37a904ab90c8881a99bd1f6e21401f1522',
id: '0x457ccf29090fe5a24c19c1bc95f492168c0eafdb',
__typename: 'Pool',
},
badDebtMantissa: '0',
Expand Down Expand Up @@ -303,33 +303,34 @@ 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',
closeFactorMantissa: '500000000000000000',
liquidationIncentiveMantissa: '3000000000000000000',
minLiquidatableCollateralMantissa: '200000000000000000000',
priceOracleAddress: '0x59b670e9fa9d0a427751af201d676719a970857b',
closeFactorMantissa: '50000000000000000',
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',
priceOracleAddress: '0x59b670e9fa9d0a427751af201d676719a970857b',
closeFactorMantissa: '50000000000000000',
liquidationIncentiveMantissa: '1000000000000000000',
minLiquidatableCollateralMantissa: '100000000000000000000',
Expand Down
16 changes: 6 additions & 10 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,18 +70,16 @@ 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!;
console.log({ markets });
expect(markets.length).to.equal(9);

markets.forEach((m, idx) => {
Expand Down Expand Up @@ -116,7 +112,7 @@ describe('Pools', function () {

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
4 changes: 4 additions & 0 deletions subgraphs/isolated-pools/tests/integration/poolRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { waitForSubgraphToBeSynced } from 'venus-subgraph-utils';

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

describe('Pool Registry', function () {
let root: SignerWithAddress;
Expand All @@ -21,6 +22,8 @@ describe('Pool Registry', function () {
before(async function () {
this.timeout(500000); // sometimes it takes a long time

await deploy();

[root] = await ethers.getSigners();
poolRegistry = await ethers.getContract('PoolRegistry');

Expand All @@ -45,6 +48,7 @@ describe('Pool Registry', function () {
it('indexes pool registry events', async function () {
const { data } = await subgraphClient.getPools();
const { pools } = data!;

expect(pools.length).to.equal(2);
pools.forEach((pool, idx) => {
expect(pool.id).to.be.equal(defaultPools[idx].id);
Expand Down

0 comments on commit afc905c

Please sign in to comment.