From ebe15f9dcf6d60b863da2552a154e0d180510dff Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Wed, 7 Sep 2022 17:35:40 +0300 Subject: [PATCH 1/6] debug --- test/integration/ComputeFlow.test.ts | 160 ++++++++++++++------------- 1 file changed, 86 insertions(+), 74 deletions(-) diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index feef4687..49a0c7b9 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -441,9 +441,9 @@ describe('Simple compute tests', async () => { }) it('should start a computeJob using the free environment', async () => { - // let's have 1 minute of compute access + // let's have 5 minute of compute access const mytime = new Date() - const computeMinutes = 1 + const computeMinutes = 3 mytime.setMinutes(mytime.getMinutes() + computeMinutes) computeValidUntil = Math.floor(mytime.getTime() / 1000) @@ -505,6 +505,90 @@ describe('Simple compute tests', async () => { freeComputeJobId = computeJobs[0].jobId }) + // put this flows back when we are able to handle this scenarios + // at the momement max job duration is 60 seconds, it takes the job around 100 to finish + // we are not able to to increase neither the valid until value, neither wait for the job to finish since the provider fees will expire + + delay(100000) + + it('Check compute status', async () => { + const jobStatus = (await ProviderInstance.computeStatus( + providerUrl, + consumerAccount, + freeComputeJobId, + resolvedDdoWith1mTimeout.id + )) as ComputeJob + assert(jobStatus, 'Cannot retrieve compute status!') + console.log('jobStatus', jobStatus) + }) + + // 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 + } + const mytime = new Date() + console.log('my time', mytime.getTime() / 1000) + console.log('compute valid until ==', computeValidUntil) + providerInitializeComputeResults = await ProviderInstance.initializeCompute( + assets, + algo, + computeEnv.id, + computeValidUntil, + providerUrl, + consumerAccount + ) + console.log( + 'second job 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 () => { @@ -757,78 +841,6 @@ describe('Simple compute tests', async () => { assert(downloadURL, 'Provider getComputeResultUrl failed!') }) - // put this flows back when we are able to handle this scenarios - // at the momement max job duration is 60 seconds, it takes the job around 100 to finish - // we are not able to to increase neither the valid until value, neither wait for the job to finish since the provider fees will expire - - // 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 - // } - // const mytime = new Date() - // console.log('my time', mytime.getTime() / 1000) - // console.log('compute valid until ==', computeValidUntil) - // providerInitializeComputeResults = await ProviderInstance.initializeCompute( - // assets, - // algo, - // computeEnv.id, - // computeValidUntil, - // providerUrl, - // consumerAccount - // ) - // console.log( - // 'second job 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') - // }) - // it('should restart a computeJob on paid environment, without paying anything, because order is valid and providerFees are still valid', async () => { // sleep(10000) // // we choose the paid env From 479234d806e153c0b5b81637b3b057447cdfb384 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 9 Sep 2022 10:22:16 +0300 Subject: [PATCH 2/6] add more logs --- test/integration/ComputeFlow.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index 49a0c7b9..78416258 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -443,7 +443,7 @@ describe('Simple compute tests', async () => { it('should start a computeJob using the free environment', async () => { // let's have 5 minute of compute access const mytime = new Date() - const computeMinutes = 3 + const computeMinutes = 5 mytime.setMinutes(mytime.getMinutes() + computeMinutes) computeValidUntil = Math.floor(mytime.getTime() / 1000) @@ -471,6 +471,7 @@ describe('Simple compute tests', async () => { providerUrl, consumerAccount ) + console.log('initalize compute 1st run', providerInitializeComputeResults) assert( !('error' in providerInitializeComputeResults.algorithm), 'Cannot order algorithm' @@ -519,6 +520,8 @@ describe('Simple compute tests', async () => { resolvedDdoWith1mTimeout.id )) as ComputeJob assert(jobStatus, 'Cannot retrieve compute status!') + const mytime = new Date() + console.log('my time at compute status call', mytime.getTime() / 1000) console.log('jobStatus', jobStatus) }) @@ -541,8 +544,8 @@ describe('Simple compute tests', async () => { transferTxId: freeEnvAlgoTxId } const mytime = new Date() - console.log('my time', mytime.getTime() / 1000) - console.log('compute valid until ==', computeValidUntil) + console.log('my time 2nd run ==', mytime.getTime() / 1000) + console.log('compute valid until run 2 ==', computeValidUntil) providerInitializeComputeResults = await ProviderInstance.initializeCompute( assets, algo, From 9fc8a8ebb316d0aefcce6d38f83aeb6f4fc5734d Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 9 Sep 2022 12:20:41 +0300 Subject: [PATCH 3/6] update asset timeouts --- test/integration/ComputeFlow.test.ts | 104 +++++++++++++-------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index 78416258..265ba382 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -32,16 +32,16 @@ let publisherAccount: string let providerInitializeComputeResults let computeEnvs let addresses: any -let ddoWith1mTimeoutId +let ddoWith5mTimeoutId let ddoWithNoTimeoutId -let algoDdoWith1mTimeoutId +let algoDdoWith5mTimeoutId let algoDdoWithNoTimeoutId let freeComputeJobId: string -let resolvedDdoWith1mTimeout +let resolvedDdoWith5mTimeout let resolvedDdoWithNoTimeout -let resolvedAlgoDdoWith1mTimeout +let resolvedAlgoDdoWith5mTimeout let resolvedAlgoDdoWithNoTimeout let freeEnvDatasetTxId @@ -98,7 +98,7 @@ const ddoWithNoTimeout = { ] } -const ddoWith1mTimeout = { +const ddoWith5mTimeout = { '@context': ['https://w3id.org/did/v1'], id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c', version: '4.1.0', @@ -124,7 +124,7 @@ const ddoWith1mTimeout = { files: '', datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3', serviceEndpoint: 'https://v4.provider.rinkeby.oceanprotocol.com', - timeout: 60, + timeout: 300, compute: { publisherTrustedAlgorithmPublishers: [], publisherTrustedAlgorithms: [], @@ -187,7 +187,7 @@ const algoDdoWithNoTimeout = { ] } -const algoDdoWith1mTimeout = { +const algoDdoWith5mTimeout = { '@context': ['https://w3id.org/did/v1'], id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c', version: '4.1.0', @@ -224,7 +224,7 @@ const algoDdoWith1mTimeout = { files: '', datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3', serviceEndpoint: 'https://v4.provider.rinkeby.oceanprotocol.com', - timeout: 60 + timeout: 300 } ] } @@ -360,12 +360,12 @@ describe('Simple compute tests', async () => { const accounts = await web3.eth.getAccounts() publisherAccount = accounts[0] consumerAccount = accounts[1] - ddoWith1mTimeoutId = await createAsset( + ddoWith5mTimeoutId = await createAsset( 'D1Min', 'D1M', publisherAccount, assetUrl, - ddoWith1mTimeout, + ddoWith5mTimeout, providerUrl ) ddoWithNoTimeoutId = await createAsset( @@ -376,12 +376,12 @@ describe('Simple compute tests', async () => { ddoWithNoTimeout, providerUrl ) - algoDdoWith1mTimeoutId = await createAsset( + algoDdoWith5mTimeoutId = await createAsset( 'A1Min', 'A1M', publisherAccount, algoAssetUrl, - algoDdoWith1mTimeout, + algoDdoWith5mTimeout, providerUrl ) @@ -396,12 +396,12 @@ describe('Simple compute tests', async () => { }) it('should resolve published datasets and algorithms', async () => { - resolvedDdoWith1mTimeout = await aquarius.waitForAqua(ddoWith1mTimeoutId) - assert(resolvedDdoWith1mTimeout, 'Cannot fetch DDO from Aquarius') + resolvedDdoWith5mTimeout = await aquarius.waitForAqua(ddoWith5mTimeoutId) + assert(resolvedDdoWith5mTimeout, 'Cannot fetch DDO from Aquarius') resolvedDdoWithNoTimeout = await aquarius.waitForAqua(ddoWithNoTimeoutId) assert(resolvedDdoWithNoTimeout, 'Cannot fetch DDO from Aquarius') - resolvedAlgoDdoWith1mTimeout = await aquarius.waitForAqua(algoDdoWith1mTimeoutId) - assert(resolvedAlgoDdoWith1mTimeout, 'Cannot fetch DDO from Aquarius') + resolvedAlgoDdoWith5mTimeout = await aquarius.waitForAqua(algoDdoWith5mTimeoutId) + assert(resolvedAlgoDdoWith5mTimeout, 'Cannot fetch DDO from Aquarius') resolvedAlgoDdoWithNoTimeout = await aquarius.waitForAqua(algoDdoWithNoTimeoutId) assert(resolvedAlgoDdoWithNoTimeout, 'Cannot fetch DDO from Aquarius') }) @@ -409,7 +409,7 @@ describe('Simple compute tests', async () => { it('should send DT to consumer', async () => { const datatoken = new Datatoken(web3) await datatoken.mint( - resolvedDdoWith1mTimeout.services[0].datatokenAddress, + resolvedDdoWith5mTimeout.services[0].datatokenAddress, publisherAccount, '10', consumerAccount @@ -421,7 +421,7 @@ describe('Simple compute tests', async () => { consumerAccount ) await datatoken.mint( - resolvedAlgoDdoWith1mTimeout.services[0].datatokenAddress, + resolvedAlgoDdoWith5mTimeout.services[0].datatokenAddress, publisherAccount, '10', consumerAccount @@ -453,14 +453,14 @@ describe('Simple compute tests', async () => { const assets: ComputeAsset[] = [ { - documentId: resolvedDdoWith1mTimeout.id, - serviceId: resolvedDdoWith1mTimeout.services[0].id + documentId: resolvedDdoWith5mTimeout.id, + serviceId: resolvedDdoWith5mTimeout.services[0].id } ] - const dtAddressArray = [resolvedDdoWith1mTimeout.services[0].datatokenAddress] + const dtAddressArray = [resolvedDdoWith5mTimeout.services[0].datatokenAddress] const algo: ComputeAlgorithm = { - documentId: resolvedAlgoDdoWith1mTimeout.id, - serviceId: resolvedAlgoDdoWith1mTimeout.services[0].id + documentId: resolvedAlgoDdoWith5mTimeout.id, + serviceId: resolvedAlgoDdoWith5mTimeout.services[0].id } providerInitializeComputeResults = await ProviderInstance.initializeCompute( @@ -478,7 +478,7 @@ describe('Simple compute tests', async () => { ) algo.transferTxId = await handleOrder( providerInitializeComputeResults.algorithm, - resolvedAlgoDdoWith1mTimeout.services[0].datatokenAddress, + resolvedAlgoDdoWith5mTimeout.services[0].datatokenAddress, consumerAccount, computeEnv.consumerAddress, 0 @@ -517,7 +517,7 @@ describe('Simple compute tests', async () => { providerUrl, consumerAccount, freeComputeJobId, - resolvedDdoWith1mTimeout.id + resolvedDdoWith5mTimeout.id )) as ComputeJob assert(jobStatus, 'Cannot retrieve compute status!') const mytime = new Date() @@ -533,14 +533,14 @@ describe('Simple compute tests', async () => { const assets: ComputeAsset[] = [ { - documentId: resolvedDdoWith1mTimeout.id, - serviceId: resolvedDdoWith1mTimeout.services[0].id, + documentId: resolvedDdoWith5mTimeout.id, + serviceId: resolvedDdoWith5mTimeout.services[0].id, transferTxId: freeEnvDatasetTxId } ] const algo: ComputeAlgorithm = { - documentId: resolvedAlgoDdoWith1mTimeout.id, - serviceId: resolvedAlgoDdoWith1mTimeout.services[0].id, + documentId: resolvedAlgoDdoWith5mTimeout.id, + serviceId: resolvedAlgoDdoWith5mTimeout.services[0].id, transferTxId: freeEnvAlgoTxId } const mytime = new Date() @@ -601,14 +601,14 @@ describe('Simple compute tests', async () => { const assets: ComputeAsset[] = [ { - documentId: resolvedDdoWith1mTimeout.id, - serviceId: resolvedDdoWith1mTimeout.services[0].id + documentId: resolvedDdoWith5mTimeout.id, + serviceId: resolvedDdoWith5mTimeout.services[0].id } ] - const dtAddressArray = [resolvedDdoWith1mTimeout.services[0].datatokenAddress] + const dtAddressArray = [resolvedDdoWith5mTimeout.services[0].datatokenAddress] const algo: ComputeAlgorithm = { - documentId: resolvedAlgoDdoWith1mTimeout.id, - serviceId: resolvedAlgoDdoWith1mTimeout.services[0].id + documentId: resolvedAlgoDdoWith5mTimeout.id, + serviceId: resolvedAlgoDdoWith5mTimeout.services[0].id } providerInitializeComputeResults = await ProviderInstance.initializeCompute( @@ -625,7 +625,7 @@ describe('Simple compute tests', async () => { ) algo.transferTxId = await handleOrder( providerInitializeComputeResults.algorithm, - resolvedAlgoDdoWith1mTimeout.services[0].datatokenAddress, + resolvedAlgoDdoWith5mTimeout.services[0].datatokenAddress, consumerAccount, computeEnv.consumerAddress, 0 @@ -669,15 +669,15 @@ describe('Simple compute tests', async () => { const assets: ComputeAsset[] = [ { - documentId: resolvedDdoWith1mTimeout.id, - serviceId: resolvedDdoWith1mTimeout.services[0].id, + documentId: resolvedDdoWith5mTimeout.id, + serviceId: resolvedDdoWith5mTimeout.services[0].id, transferTxId: freeEnvDatasetTxId } ] - const dtAddressArray = [resolvedDdoWith1mTimeout.services[0].datatokenAddress] + const dtAddressArray = [resolvedDdoWith5mTimeout.services[0].datatokenAddress] const algo: ComputeAlgorithm = { - documentId: resolvedAlgoDdoWith1mTimeout.id, - serviceId: resolvedAlgoDdoWith1mTimeout.services[0].id, + documentId: resolvedAlgoDdoWith5mTimeout.id, + serviceId: resolvedAlgoDdoWith5mTimeout.services[0].id, transferTxId: freeEnvAlgoTxId } @@ -710,7 +710,7 @@ describe('Simple compute tests', async () => { ) algo.transferTxId = await handleOrder( providerInitializeComputeResults.algorithm, - resolvedAlgoDdoWith1mTimeout.services[0].datatokenAddress, + resolvedAlgoDdoWith5mTimeout.services[0].datatokenAddress, consumerAccount, computeEnv.consumerAddress, 0 @@ -749,15 +749,15 @@ describe('Simple compute tests', async () => { const assets: ComputeAsset[] = [ { - documentId: resolvedDdoWith1mTimeout.id, - serviceId: resolvedDdoWith1mTimeout.services[0].id, + documentId: resolvedDdoWith5mTimeout.id, + serviceId: resolvedDdoWith5mTimeout.services[0].id, transferTxId: paidEnvDatasetTxId } ] - const dtAddressArray = [resolvedDdoWith1mTimeout.services[0].datatokenAddress] + const dtAddressArray = [resolvedDdoWith5mTimeout.services[0].datatokenAddress] const algo: ComputeAlgorithm = { - documentId: resolvedAlgoDdoWith1mTimeout.id, - serviceId: resolvedAlgoDdoWith1mTimeout.services[0].id, + documentId: resolvedAlgoDdoWith5mTimeout.id, + serviceId: resolvedAlgoDdoWith5mTimeout.services[0].id, transferTxId: paidEnvAlgoTxId } @@ -789,7 +789,7 @@ describe('Simple compute tests', async () => { ) algo.transferTxId = await handleOrder( providerInitializeComputeResults.algorithm, - resolvedAlgoDdoWith1mTimeout.services[0].datatokenAddress, + resolvedAlgoDdoWith5mTimeout.services[0].datatokenAddress, consumerAccount, computeEnv.consumerAddress, 0 @@ -828,7 +828,7 @@ describe('Simple compute tests', async () => { providerUrl, consumerAccount, freeComputeJobId, - resolvedDdoWith1mTimeout.id + resolvedDdoWith5mTimeout.id )) as ComputeJob assert(jobStatus, 'Cannot retrieve compute status!') }) @@ -852,14 +852,14 @@ describe('Simple compute tests', async () => { // const assets: ComputeAsset[] = [ // { - // documentId: resolvedDdoWith1mTimeout.id, - // serviceId: resolvedDdoWith1mTimeout.services[0].id, + // documentId: resolvedDdoWith5mTimeout.id, + // serviceId: resolvedDdoWith5mTimeout.services[0].id, // transferTxId: paidEnvDatasetTxId // } // ] // const algo: ComputeAlgorithm = { - // documentId: resolvedAlgoDdoWith1mTimeout.id, - // serviceId: resolvedAlgoDdoWith1mTimeout.services[0].id, + // documentId: resolvedAlgoDdoWith5mTimeout.id, + // serviceId: resolvedAlgoDdoWith5mTimeout.services[0].id, // transferTxId: paidEnvAlgoTxId // } From 219d4b4a1e1a2bba04cfaa2e26808b0f4a1fa717 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 9 Sep 2022 13:15:01 +0300 Subject: [PATCH 4/6] put back paid env test --- test/integration/ComputeFlow.test.ts | 138 +++++++++++++++------------ 1 file changed, 77 insertions(+), 61 deletions(-) diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index 265ba382..acd94024 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -38,6 +38,7 @@ let algoDdoWith5mTimeoutId let algoDdoWithNoTimeoutId let freeComputeJobId: string +let paidComputeJobId: string let resolvedDdoWith5mTimeout let resolvedDdoWithNoTimeout @@ -651,6 +652,82 @@ describe('Simple compute tests', async () => { paidEnvDatasetTxId = assets[0].transferTxId paidEnvAlgoTxId = algo.transferTxId assert(computeJobs, 'Cannot start compute job') + paidComputeJobId = computeJobs[0].jobId + }) + + delay(100000) + + it('Check compute status', async () => { + const jobStatus = (await ProviderInstance.computeStatus( + providerUrl, + consumerAccount, + paidComputeJobId, + resolvedDdoWith5mTimeout.id + )) as ComputeJob + assert(jobStatus, 'Cannot retrieve compute status!') + const mytime = new Date() + console.log('my time at compute status call', mytime.getTime() / 1000) + console.log('jobStatus', jobStatus) + }) + + it('should restart a computeJob on paid environment, without paying anything, because order is valid and providerFees are still valid', async () => { + // we choose the paid env + const computeEnv = computeEnvs.find((ce) => ce.priceMin !== 0) + assert(computeEnv, 'Cannot find the free compute env') + + const assets: ComputeAsset[] = [ + { + documentId: resolvedDdoWith5mTimeout.id, + serviceId: resolvedDdoWith5mTimeout.services[0].id, + transferTxId: paidEnvDatasetTxId + } + ] + const algo: ComputeAlgorithm = { + documentId: resolvedAlgoDdoWith5mTimeout.id, + serviceId: resolvedAlgoDdoWith5mTimeout.services[0].id, + transferTxId: paidEnvAlgoTxId + } + + 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 === paidEnvAlgoTxId && + assets[0].transferTxId === paidEnvDatasetTxId, + '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') }) // move to reuse Orders @@ -843,65 +920,4 @@ describe('Simple compute tests', async () => { ) assert(downloadURL, 'Provider getComputeResultUrl failed!') }) - - // it('should restart a computeJob on paid environment, without paying anything, because order is valid and providerFees are still valid', async () => { - // sleep(10000) - // // we choose the paid env - // const computeEnv = computeEnvs.find((ce) => ce.priceMin !== 0) - // assert(computeEnv, 'Cannot find the free compute env') - - // const assets: ComputeAsset[] = [ - // { - // documentId: resolvedDdoWith5mTimeout.id, - // serviceId: resolvedDdoWith5mTimeout.services[0].id, - // transferTxId: paidEnvDatasetTxId - // } - // ] - // const algo: ComputeAlgorithm = { - // documentId: resolvedAlgoDdoWith5mTimeout.id, - // serviceId: resolvedAlgoDdoWith5mTimeout.services[0].id, - // transferTxId: paidEnvAlgoTxId - // } - - // 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 === paidEnvAlgoTxId && - // assets[0].transferTxId === paidEnvDatasetTxId, - // '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') - // }) }) From 610d15b2b4cea2f2ba32274b86b44c62081df2d9 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 9 Sep 2022 14:07:30 +0300 Subject: [PATCH 5/6] removed unnecesar logs --- test/integration/ComputeFlow.test.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index acd94024..deb77627 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -472,7 +472,6 @@ describe('Simple compute tests', async () => { providerUrl, consumerAccount ) - console.log('initalize compute 1st run', providerInitializeComputeResults) assert( !('error' in providerInitializeComputeResults.algorithm), 'Cannot order algorithm' @@ -521,9 +520,6 @@ describe('Simple compute tests', async () => { resolvedDdoWith5mTimeout.id )) as ComputeJob assert(jobStatus, 'Cannot retrieve compute status!') - const mytime = new Date() - console.log('my time at compute status call', mytime.getTime() / 1000) - console.log('jobStatus', jobStatus) }) // move to start orders with initial txid's and provider fees @@ -544,9 +540,6 @@ describe('Simple compute tests', async () => { serviceId: resolvedAlgoDdoWith5mTimeout.services[0].id, transferTxId: freeEnvAlgoTxId } - const mytime = new Date() - console.log('my time 2nd run ==', mytime.getTime() / 1000) - console.log('compute valid until run 2 ==', computeValidUntil) providerInitializeComputeResults = await ProviderInstance.initializeCompute( assets, algo, @@ -555,10 +548,6 @@ describe('Simple compute tests', async () => { providerUrl, consumerAccount ) - console.log( - 'second job providerInitializeComputeResults', - providerInitializeComputeResults - ) assert( providerInitializeComputeResults.algorithm.validOrder, 'We should have a valid order for algorithm' @@ -665,9 +654,6 @@ describe('Simple compute tests', async () => { resolvedDdoWith5mTimeout.id )) as ComputeJob assert(jobStatus, 'Cannot retrieve compute status!') - const mytime = new Date() - console.log('my time at compute status call', mytime.getTime() / 1000) - console.log('jobStatus', jobStatus) }) it('should restart a computeJob on paid environment, without paying anything, because order is valid and providerFees are still valid', async () => { From 8acbbd01b60612c097d61453ceb90fa54be82a15 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 9 Sep 2022 14:21:20 +0300 Subject: [PATCH 6/6] removed missed comments and one delay --- test/integration/ComputeFlow.test.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index deb77627..6830b068 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -506,10 +506,6 @@ describe('Simple compute tests', async () => { freeComputeJobId = computeJobs[0].jobId }) - // put this flows back when we are able to handle this scenarios - // at the momement max job duration is 60 seconds, it takes the job around 100 to finish - // we are not able to to increase neither the valid until value, neither wait for the job to finish since the provider fees will expire - delay(100000) it('Check compute status', async () => { @@ -884,8 +880,6 @@ describe('Simple compute tests', async () => { assert(computeJobs, 'Cannot start compute job') }) - delay(100000) - it('Check compute status', async () => { const jobStatus = (await ProviderInstance.computeStatus( providerUrl,