1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

update compute.start interface.

This commit is contained in:
ssallam 2020-07-10 16:28:39 +02:00
parent 3179a23375
commit 7a47201ca4
2 changed files with 42 additions and 4 deletions

View File

@ -53,17 +53,22 @@ export class Compute extends Instantiable {
/**
* Start the execution of a compute job.
* @param {Account} consumerAccount The account of the consumer ordering the service.
* @param {string} did Decentralized identifer for the asset
* @param {string} txId
* @param {string} tokenAddress
* @param {Account} consumerAccount The account of the consumer ordering the service.
* @param {string} algorithmDid The DID of the algorithm asset (of type `algorithm`) to run on the asset.
* @param {MetaData} algorithmMeta Metadata about the algorithm being run if `algorithm` is being used. This is ignored when `algorithmDid` is specified.
* @param {Output} output Define algorithm output publishing. Publishing the result of a compute job is turned off by default.
* @return {Promise<ComputeJob>} Returns compute job ID under status.jobId
*/
public async start(
consumerAccount: Account,
did: string,
txId: string,
tokenAddress: string,
consumerAccount: Account,
algorithmDid?: string,
algorithmTokenAddress?: string,
algorithmMeta?: MetadataAlgorithm,
output?: Output
): Promise<ComputeJob> {

View File

@ -121,7 +121,7 @@ describe('Marketplace flow', () => {
assert(computeService.attributes.main.cost === price)
})
it('Bob buys datatokens from open market and order a compute service', async () => {
it('Bob gets datatokens from Alice to be able to try the compute service', async () => {
const dTamount = 20
await datatoken
.transfer(tokenAddress, bob.getId(), dTamount, alice.getId())
@ -131,7 +131,40 @@ describe('Marketplace flow', () => {
})
})
// it('Bob starts compute job', async () => {})
it('Bob starts compute job', async () => {
// TODO
const algorithmMeta = {
}
// TODO
const output = {
}
await ocean.assets
.order(ddo.id, computeService.type, bob.getId())
.then(async (res: string) => {
res = JSON.parse(res)
return await datatoken.transfer(
res['dataToken'],
res['to'],
res['numTokens'],
res['from']
)
})
.then(async (tx) => {
await ocean.compute.start(
ddo.id,
tx.transactionHash,
tokenAddress,
bob,
algorithmMeta,
output
)
})
})
// it('Bob gets the compute job status', async () => {})