Skip to content

Commit

Permalink
test: update isolated pools test
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Oct 1, 2024
1 parent 43399b6 commit 426609e
Show file tree
Hide file tree
Showing 3 changed files with 332 additions and 190 deletions.
48 changes: 48 additions & 0 deletions subgraphs/isolated-pools/tests/integration/checkEntities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { TransactionResponse } from '@ethersproject/abstract-provider';
import { expect } from 'chai';
import { ethers } from 'hardhat';

import subgraphClient from '../../subgraph-client';

export const checkMarket = async (marketAddress: string) => {
const vToken = await ethers.getContractAt('VToken', marketAddress);
const { accountVTokens: accountVTokensSupply } =
await subgraphClient.getAccountVTokensWithSupplyByMarketId(marketAddress.toLowerCase());
const { accountVTokens: accountVTokensBorrow } =
await subgraphClient.getAccountVTokensWithBorrowByMarketId(marketAddress.toLowerCase());
const { market } = await subgraphClient.getMarketById(marketAddress.toLowerCase());
expect(market?.supplierCount).to.equal(accountVTokensSupply.length.toString());
expect(market?.borrowerCount).to.equal(accountVTokensBorrow.length.toString());

expect(market?.totalBorrowsMantissa).to.equal(await vToken.totalBorrows());
expect(market?.totalSupplyVTokenMantissa).to.equal(await vToken.totalSupply());

expect(market?.borrowIndexMantissa).to.equal(await vToken.borrowIndex());
expect(market?.borrowRateMantissa).to.equal(await vToken.borrowRatePerBlock());
expect(market?.supplyRateMantissa).to.equal(await vToken.supplyRatePerBlock());

expect(market?.cashMantissa).to.equal(await vToken.getCash());
expect(market?.reservesMantissa).to.equal(await vToken.totalReserves());

return market;
};

export const checkAccountVToken = async (
accountAddress: string,
marketAddress: string,
transaction: TransactionResponse,
) => {
const vToken = await ethers.getContractAt('VToken', marketAddress);

const { accountVToken } = await subgraphClient.getAccountVTokenByAccountAndMarket({
accountId: accountAddress.toLowerCase(),
marketId: marketAddress.toLowerCase(),
});
expect(accountVToken!.accrualBlockNumber).to.equal(transaction.blockNumber);
expect(accountVToken!.vTokenBalanceMantissa).to.equal(await vToken.balanceOf(accountAddress));
expect(accountVToken!.storedBorrowBalanceMantissa).to.equal(
await vToken.borrowBalanceStored(accountAddress),
);
expect(accountVToken!.borrowIndex).to.equal(await vToken.borrowIndex());
expect(accountVToken!.enteredMarket).to.equal(await vToken.checkMembership(accountAddress));
};
6 changes: 2 additions & 4 deletions subgraphs/isolated-pools/tests/integration/unlistMarkets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ describe('VToken events', function () {
await waitForSubgraphToBeSynced(syncDelay);

for (const market of markets) {
const {
data: { market: unlistedMarket },
} = await subgraphClient.getMarketById(market.toLowerCase());
const { market: unlistedMarket } = await subgraphClient.getMarketById(market.toLowerCase());

expect(unlistedMarket.isListed).to.equal(false);
expect(unlistedMarket?.isListed).to.equal(false);
}
});
});
Loading

0 comments on commit 426609e

Please sign in to comment.