Skip to content

Commit

Permalink
Merge pull request #115 from VenusProtocol/fix-isolated-pool-integrat…
Browse files Browse the repository at this point in the history
…ion-test-deploy

Fix isolated pool integration test deploy
  • Loading branch information
coreyar authored Oct 11, 2023
2 parents 9dc1c76 + 9acc682 commit d7cf2a2
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 23 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ hardhat.config.ts
typechain-types

/subgraphs/venus-governance/tests/integration/index.ts
/subgraphs/isolated-pools/tests/integration/index.ts
44 changes: 25 additions & 19 deletions subgraphs/isolated-pools/subgraph-client/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DocumentNode } from 'graphql';
import { Client as UrqlClient, createClient } from 'urql/core';

import {
Expand All @@ -24,66 +25,71 @@ class SubgraphClient {
});
}

async query(document: DocumentNode, args: Record<string, string>) {
const result = await this.urqlClient.query(document, args).toPromise();
if (result.error) {
console.error(result.error);
}
return result;
}

async getPools() {
const result = await this.urqlClient.query(PoolsDocument, {}).toPromise();
const result = await this.query(PoolsDocument, {});
return result;
}

async getMarkets() {
const result = await this.urqlClient.query(MarketsDocument, {}).toPromise();
const result = await this.query(MarketsDocument, {});
return result;
}

async getMarketById(id: string) {
const result = await this.urqlClient.query(MarketByIdDocument, { id }).toPromise();
const result = await this.query(MarketByIdDocument, { id });
return result;
}

async getAccountById(id: string) {
const result = await this.urqlClient.query(AccountByIdDocument, { id }).toPromise();
const result = await this.query(AccountByIdDocument, { id });
return result;
}

async getAccountVTokens() {
const result = await this.urqlClient.query(AccountVTokensDocument, {}).toPromise();
const result = await this.query(AccountVTokensDocument, {});
return result;
}

async getAccountVTokensTransactions() {
const result = await this.urqlClient.query(AccountVTokenTransactionsDocument, {}).toPromise();
const result = await this.query(AccountVTokenTransactionsDocument, {});
return result;
}

async getMarketActions() {
const result = await this.urqlClient.query(MarketActionsDocument, {}).toPromise();
const result = await this.query(MarketActionsDocument, {});
return result;
}

async getAccountFromMarket(marketId: string, accountId: string) {
const result = await this.urqlClient
.query(AccountFromMarketDocument, { marketId, accountId })
.toPromise();
const result = await this.query(AccountFromMarketDocument, { marketId, accountId });
return result;
}

async getAccountVTokensByAccountId(accountId: string) {
const result = await this.urqlClient
.query(AccountVTokenByAccountIdDocument, { accountId })
.toPromise();
const result = await this.query(AccountVTokenByAccountIdDocument, { accountId });
return result;
}

async getAccountVTokenByAccountAndMarket(accountId: string, marketId: string) {
const result = await this.urqlClient
.query(AccountVTokenByAccountAndMarketQueryDocument, { accountId, marketId })
.toPromise();
const result = await this.query(AccountVTokenByAccountAndMarketQueryDocument, {
accountId,
marketId,
});
return result;
}

async getAccountVTokenTransactionsByAccountId(accountVTokenId: string) {
const result = await this.urqlClient
.query(AccountVTokenTransactionsByAccountIdDocument, { accountVTokenId })
.toPromise();
const result = await this.query(AccountVTokenTransactionsByAccountIdDocument, {
accountVTokenId,
});
return result;
}
}
Expand Down
2 changes: 1 addition & 1 deletion subgraphs/isolated-pools/tests/integration/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The first test must deploy the subgraph
import './setup';
import './pool.ts';
import './poolRegistry.ts';
import './vTokens.ts';
3 changes: 0 additions & 3 deletions subgraphs/isolated-pools/tests/integration/poolRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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 @@ -22,8 +21,6 @@ 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 Down
18 changes: 18 additions & 0 deletions subgraphs/isolated-pools/tests/integration/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { deploy } from 'venus-subgraph-utils';

import { SUBGRAPH_ACCOUNT, SUBGRAPH_NAME, SYNC_DELAY } from './constants';

describe('Deploy Subgraph', function () {
it('should deploy subgraph', async function () {
this.timeout(500000); // sometimes it takes a long time
const root = `${__dirname}/../..`;

await deploy({
root,
packageName: 'isolated-pools-subgraph',
subgraphAccount: SUBGRAPH_ACCOUNT,
subgraphName: SUBGRAPH_NAME,
syncDelay: SYNC_DELAY,
});
});
});

0 comments on commit d7cf2a2

Please sign in to comment.