diff --git a/src/ocean/Compute.ts b/src/ocean/Compute.ts index 6a7e8a9d..bf5893dd 100644 --- a/src/ocean/Compute.ts +++ b/src/ocean/Compute.ts @@ -68,7 +68,9 @@ export class Compute extends Instantiable { algorithmMeta?: MetadataAlgorithm, output?: Output, serviceIndex?: string, - serviceType?: string + serviceType?: string, + algorithmTransferTxId?: string, + algorithmDataToken?: string ): Promise { output = this.checkOutput(consumerAccount, output) if (did) { @@ -83,7 +85,9 @@ export class Compute extends Instantiable { txId, serviceIndex, serviceType, - tokenAddress + tokenAddress, + algorithmTransferTxId, + algorithmDataToken ) return computeJobsList[0] as ComputeJob } else return null diff --git a/src/provider/Provider.ts b/src/provider/Provider.ts index 9c94eafa..2ef4cb36 100644 --- a/src/provider/Provider.ts +++ b/src/provider/Provider.ts @@ -144,10 +144,11 @@ export class Provider extends Instantiable { txId?: string, serviceIndex?: string, serviceType?: string, - tokenAddress?: string + tokenAddress?: string, + algorithmTransferTxId?: string, + algorithmDataToken?: string ): Promise { const address = consumerAccount.getId() - let signatureMessage = address signatureMessage += jobId || '' signatureMessage += (did && `${noZeroX(did)}`) || '' @@ -169,6 +170,11 @@ export class Provider extends Instantiable { url += (jobId && `&jobId=${jobId}`) || '' url += `&consumerAddress=${address}` url += `&transferTxId=${txId}` || '' + url += + (algorithmTransferTxId && + `&algorithmTransferTxId=${algorithmTransferTxId}`) || + '' + url += (algorithmDataToken && `&algorithmDataToken=${algorithmDataToken}`) || '' url += `&serviceId=${serviceIndex}` || '' url += `&serviceType=${serviceType}` || '' url += `&dataToken=${tokenAddress}` || '' diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index bf5520fb..36cc4ec2 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -114,7 +114,7 @@ describe('Marketplace flow', () => { }) it('Alice publishes dataset with a compute service that allows Raw Algo', async () => { - price = 10 // in datatoken + price = 2 // in datatoken cluster = ocean.compute.createClusterAttributes( 'Kubernetes', 'http://10.0.0.17/xxx' @@ -337,7 +337,53 @@ describe('Marketplace flow', () => { ) assert(order === null) }) - // it('should start a compute job with a published algo', async () => { + it('should start a compute job with a published algo', async () => { + const output = {} + const serviceAlgo = algorithmAsset.findServiceByType('access') + const orderalgo = await ocean.assets.order( + algorithmAsset.id, + serviceAlgo.type, + bob.getId() + ) + const algoOrder = JSON.parse(orderalgo) + const algoTx = await datatoken.transfer( + algoOrder['dataToken'], + algoOrder['to'], + algoOrder['numTokens'], + algoOrder['from'] + ) + const order = await ocean.compute.order( + bob.getId(), + ddo.id, + computeService.index, + algorithmAsset.id, + undefined + ) + assert(order != null) + const computeOrder = JSON.parse(order) + const tx = await datatoken.transfer( + computeOrder['dataToken'], + computeOrder['to'], + computeOrder['numTokens'], + computeOrder['from'] + ) + const response = await ocean.compute.start( + ddo.id, + tx.transactionHash, + tokenAddress, + bob, + undefined, + undefined, + algorithmMeta, + output, + computeService.index, + computeService.type, + algoTx, + algorithmAsset.datatoken + ) + jobId = response.jobId + assert(response.status >= 10) + }) // it('Bob restarts compute job', async () => {}) // it('Bob gets outputs', async () => {}) })