diff --git a/apps/whale-api/src/e2e.defid.module.ts b/apps/whale-api/src/e2e.defid.module.ts index 1f90a84172..0e8e26c5ce 100644 --- a/apps/whale-api/src/e2e.defid.module.ts +++ b/apps/whale-api/src/e2e.defid.module.ts @@ -6,6 +6,7 @@ import { v4 as uuidv4 } from 'uuid' import fs from 'fs' import { ChildProcess, spawn } from 'child_process' import { RegTestFoundationKeys } from '@defichain/jellyfish-network' +import { MasterNodeRegTestContainer } from '@defichain/testcontainers/dist/index' const PORT = 3002 const ENDPOINT = `http://127.0.0.1:${PORT}` @@ -274,6 +275,7 @@ export class DefidBin { binary: ChildProcess | null = null public constructor ( + readonly container: MasterNodeRegTestContainer, readonly addressController: DAddressController, readonly blockController: DBlockController ) { diff --git a/apps/whale-api/src/e2e.module.ts b/apps/whale-api/src/e2e.module.ts index f7f885147d..aacc4fdec0 100644 --- a/apps/whale-api/src/e2e.module.ts +++ b/apps/whale-api/src/e2e.module.ts @@ -24,6 +24,7 @@ import { DefidBin, DAddressController, DBlockController } from './e2e.defid.modu export async function createTestingApp (container: MasterNodeRegTestContainer): Promise { if (process.env.DEFID !== undefined) { const defid = new DefidBin( + container, new DAddressController(), new DBlockController() ) @@ -114,15 +115,18 @@ export async function waitForIndexedHeightLatest (app: NestFastifyApplication, c export async function waitForIndexedHeight (app: NestFastifyApplication | DefidBin, height: number, timeout: number = 30000): Promise { if (app instanceof DefidBin) { await waitForExpect(async () => { - // get index from DefidBin - }) - return + // TODO(): maybe get index from DefidBin + const count = await app.container.getBlockCount() + await expect(count).toBeGreaterThan(height) + await await app.container.generate(1) + }, timeout) + } else { + const blockMapper = app.get(BlockMapper) + await waitForExpect(async () => { + const block = await blockMapper.getHighest() + await expect(block?.height).toBeGreaterThan(height) + }, timeout) } - const blockMapper = app.get(BlockMapper) - await waitForExpect(async () => { - const block = await blockMapper.getHighest() - await expect(block?.height).toBeGreaterThan(height) - }, timeout) await new Promise((resolve) => setTimeout(resolve, 1000)) }