From 0f77f75bc97b51aef79c3d0022397717b9a14b2d Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Tue, 2 May 2023 15:45:16 +0300 Subject: [PATCH] Fix c2d restart job with valid fees and order (#1729) * added logs * adds wait method * adds await till job ends * cleanups * removes logs --- test/integration/ComputeFlow.test.ts | 31 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index 73276d4f..370a7658 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -226,6 +226,23 @@ function delay(interval: number) { }).timeout(interval + 100) } +async function waitTillJobEnds(): Promise { + return new Promise((resolve) => { + const interval = setInterval(async () => { + const jobStatus = (await ProviderInstance.computeStatus( + providerUrl, + consumerAccount, + freeComputeJobId, + resolvedDdoWith5mTimeout.id + )) as ComputeJob + if (jobStatus?.status === 70) { + clearInterval(interval) + resolve(jobStatus.status) + } + }, 10000) + }) +} + describe('Simple compute tests', async () => { before(async () => { config = await getTestConfig(web3) @@ -394,10 +411,6 @@ describe('Simple compute tests', async () => { providerUrl, consumerAccount ) - console.log( - 'compute flow initializeCompute result = ', - providerInitializeComputeResults - ) assert( !('error' in providerInitializeComputeResults.algorithm), 'Cannot order algorithm' @@ -438,15 +451,7 @@ describe('Simple compute tests', async () => { delay(100000) - it('Check compute status', async () => { - const jobStatus = (await ProviderInstance.computeStatus( - providerUrl, - consumerAccount, - freeComputeJobId, - resolvedDdoWith5mTimeout.id - )) as ComputeJob - assert(jobStatus, 'Cannot retrieve compute status!') - }) + const jobFinished = await waitTillJobEnds() // move to start orders with initial txid's and provider fees it('should restart a computeJob without paying anything, because order is valid and providerFees are still valid', async () => {