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 () => {