Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix isolated pool integration test deploy #115

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 subgraphClient from '../../subgraph-client';
import { defaultPools } from './constants';
import deploy from './utils/deploy';

describe('Pool Registry', function () {
let root: SignerWithAddress;
Expand All @@ -15,15 +14,13 @@
const logoUrl = 'https://images.com/gamer-cat.png';
const description = 'Cat Games';

let poolRegistry: any;

Check warning on line 17 in subgraphs/isolated-pools/tests/integration/poolRegistry.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

const syncDelay = 2000;

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,
});
});
});
Loading