diff --git a/apps/whale-api/src/e2e.defid.module.ts b/apps/whale-api/src/e2e.defid.module.ts index 8db9828f6d..24907bf988 100644 --- a/apps/whale-api/src/e2e.defid.module.ts +++ b/apps/whale-api/src/e2e.defid.module.ts @@ -863,6 +863,16 @@ export class DefidBin { }, timeout, 100, 'waitForWalletBalanceGTE') } + async waitForPath (controller: DPoolPairController, timeout: number = 300000): Promise { + return await waitForCondition(async () => { + const res = await controller.listSwappableTokens('0') + if (res.swappableTokens.length > 0) { + return true + } + return false + }, timeout, 100, 'waitForPath') + } + async fundAddress (address: string, amount: number): Promise<{ txid: string, vout: number }> { const txid = await this.call('sendtoaddress', [address, amount]) await this.generate(1) diff --git a/apps/whale-api/src/module.api/__defid__/poolpair.controller.defid.ts b/apps/whale-api/src/module.api/__defid__/poolpair.controller.defid.ts index 71717c43c1..8727c5467d 100644 --- a/apps/whale-api/src/module.api/__defid__/poolpair.controller.defid.ts +++ b/apps/whale-api/src/module.api/__defid__/poolpair.controller.defid.ts @@ -27,6 +27,8 @@ beforeAll(async () => { // const tkey = `${CachePrefix.TOKEN_INFO} 31` // const token = await cache.get(tkey) // expect(token?.symbolKey).toStrictEqual('USDT-DFI') + + await app.waitForPath(controller) }) afterAll(async () => { diff --git a/apps/whale-api/src/module.api/__defid__/poolpair.fees.service.defid.ts b/apps/whale-api/src/module.api/__defid__/poolpair.fees.service.defid.ts index 807598265e..950d79af26 100644 --- a/apps/whale-api/src/module.api/__defid__/poolpair.fees.service.defid.ts +++ b/apps/whale-api/src/module.api/__defid__/poolpair.fees.service.defid.ts @@ -19,6 +19,8 @@ beforeAll(async () => { // for (const k in tokenResult) { // await defiCache.getTokenInfo(k) // } + + await app.waitForPath(controller) }) afterAll(async () => { @@ -176,7 +178,7 @@ async function setup (): Promise { await app.generate(1) } -describe('get best path - DEX burn fees', () => { +describe.only('get best path - DEX burn fees', () => { it('should return fees - CAT to DFI - Both token fees direction are in', async () => { const paths1 = await controller.getBestPath('3', '0') expect(paths1.bestPath).toStrictEqual([