From f99629dfc54a4f20accbb043ffedb2cb637928e6 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Tue, 23 Aug 2022 17:46:54 +0300 Subject: [PATCH] updated timeouts --- test/integration/ComputeFlow.test.ts | 177 ++++++++++++++------------- 1 file changed, 89 insertions(+), 88 deletions(-) diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index 3b10236c..e561beaf 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -505,6 +505,94 @@ describe('Simple compute tests', async () => { freeComputeJobId = computeJobs[0].jobId }) + delay(60000) + + it('Check compute status', async () => { + const jobStatus = (await ProviderInstance.computeStatus( + providerUrl, + consumerAccount, + freeComputeJobId, + resolvedDdoWith1mTimeout.id + )) as ComputeJob + console.log('jobStatus', jobStatus) + assert(jobStatus, 'Cannot retrieve compute status!') + }) + + it('Get download compute results url', async () => { + await sleep(10000) + const downloadURL = await ProviderInstance.getComputeResultUrl( + providerUrl, + web3, + consumerAccount, + freeComputeJobId, + 0 + ) + assert(downloadURL, 'Provider getComputeResultUrl failed!') + }) + + // 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 () => { + // we choose the free env + const computeEnv = computeEnvs.find((ce) => ce.priceMin === 0) + assert(computeEnv, 'Cannot find the free compute env') + + const assets: ComputeAsset[] = [ + { + documentId: resolvedDdoWith1mTimeout.id, + serviceId: resolvedDdoWith1mTimeout.services[0].id, + transferTxId: freeEnvDatasetTxId + } + ] + const algo: ComputeAlgorithm = { + documentId: resolvedAlgoDdoWith1mTimeout.id, + serviceId: resolvedAlgoDdoWith1mTimeout.services[0].id, + transferTxId: freeEnvAlgoTxId + } + + providerInitializeComputeResults = await ProviderInstance.initializeCompute( + assets, + algo, + computeEnv.id, + computeValidUntil, + providerUrl, + consumerAccount + ) + console.log('providerInitializeComputeResults', providerInitializeComputeResults) + assert( + providerInitializeComputeResults.algorithm.validOrder, + 'We should have a valid order for algorithm' + ) + assert( + !providerInitializeComputeResults.algorithm.providerFee, + 'We should not pay providerFees again for algorithm' + ) + assert( + providerInitializeComputeResults.datasets[0].validOrder, + 'We should have a valid order for dataset' + ) + assert( + !providerInitializeComputeResults.datasets[0].providerFee, + 'We should not pay providerFees again for dataset' + ) + algo.transferTxId = providerInitializeComputeResults.algorithm.validOrder + assets[0].transferTxId = providerInitializeComputeResults.datasets[0].validOrder + assert( + algo.transferTxId === freeEnvAlgoTxId && + assets[0].transferTxId === freeEnvDatasetTxId, + 'We should use the same orders, because no fess must be paid' + ) + const computeJobs = await ProviderInstance.computeStart( + providerUrl, + web3, + consumerAccount, + computeEnv.id, + assets[0], + algo + ) + assert(computeJobs, 'Cannot start compute job') + }) + // moving to paid environments it('should start a computeJob on a paid environment', async () => { @@ -566,94 +654,7 @@ describe('Simple compute tests', async () => { assert(computeJobs, 'Cannot start compute job') }) - delay(120000) - // move to check status and get download url - - it('Check compute status', async () => { - const jobStatus = (await ProviderInstance.computeStatus( - providerUrl, - consumerAccount, - freeComputeJobId, - resolvedDdoWith1mTimeout.id - )) as ComputeJob - console.log('jobStatus', jobStatus) - assert(jobStatus, 'Cannot retrieve compute status!') - }) - - it('Get download compute results url', async () => { - await sleep(10000) - const downloadURL = await ProviderInstance.getComputeResultUrl( - providerUrl, - web3, - consumerAccount, - freeComputeJobId, - 0 - ) - assert(downloadURL, 'Provider getComputeResultUrl failed!') - }) - - // 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 () => { - sleep(10000) - // we choose the free env - const computeEnv = computeEnvs.find((ce) => ce.priceMin === 0) - assert(computeEnv, 'Cannot find the free compute env') - - const assets: ComputeAsset[] = [ - { - documentId: resolvedDdoWith1mTimeout.id, - serviceId: resolvedDdoWith1mTimeout.services[0].id, - transferTxId: freeEnvDatasetTxId - } - ] - const algo: ComputeAlgorithm = { - documentId: resolvedAlgoDdoWith1mTimeout.id, - serviceId: resolvedAlgoDdoWith1mTimeout.services[0].id, - transferTxId: freeEnvAlgoTxId - } - - providerInitializeComputeResults = await ProviderInstance.initializeCompute( - assets, - algo, - computeEnv.id, - computeValidUntil, - providerUrl, - consumerAccount - ) - assert( - providerInitializeComputeResults.algorithm.validOrder, - 'We should have a valid order for algorithm' - ) - assert( - !providerInitializeComputeResults.algorithm.providerFee, - 'We should not pay providerFees again for algorithm' - ) - assert( - providerInitializeComputeResults.datasets[0].validOrder, - 'We should have a valid order for dataset' - ) - assert( - !providerInitializeComputeResults.datasets[0].providerFee, - 'We should not pay providerFees again for dataset' - ) - algo.transferTxId = providerInitializeComputeResults.algorithm.validOrder - assets[0].transferTxId = providerInitializeComputeResults.datasets[0].validOrder - assert( - algo.transferTxId === freeEnvAlgoTxId && - assets[0].transferTxId === freeEnvDatasetTxId, - 'We should use the same orders, because no fess must be paid' - ) - const computeJobs = await ProviderInstance.computeStart( - providerUrl, - web3, - consumerAccount, - computeEnv.id, - assets[0], - algo - ) - assert(computeJobs, 'Cannot start compute job') - }) + delay(60000) it('should restart a computeJob on paid environment, without paying anything, because order is valid and providerFees are still valid', async () => { sleep(10000)