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 1 commit
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
7 changes: 2 additions & 5 deletions src/e2e.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ 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)
})
// Wait 500ms between indexer cycle time to prevent database error
await new Promise((resolve) => setTimeout(resolve, 500))
monstrobishi marked this conversation as resolved.
Show resolved Hide resolved

if (container instanceof MasterNodeRegTestContainer) {
await container.stop()
Expand Down Expand Up @@ -76,7 +74,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