Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

chore(indexer): removed await within test due to race condition #743

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 0 additions & 3 deletions packages/whale-api-client/__tests__/api/prices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ describe('active price', () => {
const height = await container.getBlockCount()
await container.generate(1)
await service.waitForIndexedHeight(height)
await new Promise((resolve) => setTimeout(resolve, 500))

const fixedIntervalPrice = await testing.rpc.oracle.getFixedIntervalPrice('S1/USD')
const activePrice = await apiClient.prices.getFeedActive('S1', 'USD', 1)
Expand Down Expand Up @@ -642,7 +641,6 @@ describe('active price', () => {
const height = await container.getBlockCount()
await container.generate(1)
await service.waitForIndexedHeight(height)
await new Promise((resolve) => setTimeout(resolve, 500))

const fixedIntervalPrice = await testing.rpc.oracle.getFixedIntervalPrice('S1/USD')
const activePrice = await apiClient.prices.getFeedActive('S1', 'USD', 1)
Expand Down Expand Up @@ -684,7 +682,6 @@ describe('active price', () => {
const height = await container.getBlockCount()
await container.generate(1)
await service.waitForIndexedHeight(height)
await new Promise((resolve) => setTimeout(resolve, 500))

const fixedIntervalPrice = await testing.rpc.oracle.getFixedIntervalPrice('S1/USD')
const activePrice = await apiClient.prices.getFeedActive('S1', 'USD', 1)
Expand Down
1 change: 0 additions & 1 deletion packages/whale-api-client/__tests__/stub.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class StubService {
const block = await blockMapper.getHighest()
await expect(block?.height).toBeGreaterThan(height)
}, timeout)
await new Promise((resolve) => setTimeout(resolve, 1000))
}

async waitForIndexedTimestamp (container: MasterNodeRegTestContainer, timestamp: number, timeout: number = 30000): Promise<void> {
Expand Down
6 changes: 0 additions & 6 deletions src/e2e.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ export async function stopTestingApp (container: MasterNodeRegTestContainer | Te
await indexer.stop()
await app.close()
} finally {
await new Promise((resolve) => {
// Wait 2000ms between indexer cycle time to prevent database error
setTimeout(_ => resolve(0), 500)
})

if (container instanceof MasterNodeRegTestContainer) {
await container.stop()
} else {
Expand Down Expand Up @@ -76,7 +71,6 @@ export async function waitForIndexedHeight (app: NestFastifyApplication, height:
const block = await blockMapper.getHighest()
await expect(block?.height).toBeGreaterThan(height)
}, timeout)
await new Promise((resolve) => setTimeout(resolve, 1000))
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/module.api/loan.auction.history.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ beforeAll(async () => {
await tGroup.waitForSync()

const height = await alice.container.call('getblockcount')
await waitForIndexedHeight(app, height - 1)
await alice.generate(1)
await waitForIndexedHeight(app, height)
})

afterAll(async () => {
Expand Down