Skip to content

Commit

Permalink
Merge pull request #398 from oceanprotocol/feature/compute_updates
Browse files Browse the repository at this point in the history
update compute status
  • Loading branch information
alexcos20 authored Oct 22, 2020
2 parents 6cfd79d + 1aefaf8 commit 7f1ae2c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/ocean/Compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,16 @@ export class Compute extends Instantiable {
* Returns information about the status of all compute jobs, or a single compute job.
* @param {Account} consumerAccount The account of the consumer ordering the service.
* @param {string} did Decentralized identifier.
* @param {string} jobId The ID of the compute job to be stopped
* @param {string} jobId The jobId of the compute job
* @param {string} jobId The Order transaction id
* @param {boolean} sign If the provider request is going to be signed(default) (full status) or not (short status)
* @return {Promise<ComputeJob[]>} Returns the status
*/
public async status(
consumerAccount: Account,
did?: string,
jobId?: string,
txId?: string,
sign = true
): Promise<ComputeJob[]> {
let provider: Provider
Expand All @@ -204,7 +206,7 @@ export class Compute extends Instantiable {
undefined,
jobId,
undefined,
undefined,
txId,
undefined,
undefined,
undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/provider/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class Provider extends Instantiable {
''
url += (jobId && `&jobId=${jobId}`) || ''
url += `&consumerAddress=${address}`
url += `&transferTxId=${txId}` || ''
url += (txId && `&transferTxId=${txId}`) || ''
url +=
(algorithmTransferTxId && `&algorithmTransferTxId=${algorithmTransferTxId}`) || ''
url += (algorithmDataToken && `&algorithmDataToken=${algorithmDataToken}`) || ''
Expand Down
28 changes: 23 additions & 5 deletions test/integration/ComputeFlow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('Compute flow', () => {
let data: { t: number; url: string }
let blob: string
let jobId: string
let computeOrderId: string

let cluster: Cluster
let servers: Server[]
Expand Down Expand Up @@ -330,17 +331,17 @@ describe('Compute flow', () => {

it('Bob starts compute job with a raw Algo', async () => {
const output = {}
const order = await ocean.compute.order(
computeOrderId = await ocean.compute.order(
bob.getId(),
ddo.id,
computeService.index,
undefined,
algorithmMeta
)
assert(order != null)
assert(computeOrderId != null)
const response = await ocean.compute.start(
ddo.id,
order,
computeOrderId,
tokenAddress,
bob,
undefined,
Expand All @@ -352,14 +353,31 @@ describe('Compute flow', () => {
jobId = response.jobId
assert(response.status >= 10)
})
it('Bob should get status of a compute job with a specific order txId', async () => {
assert(jobId != null)
const response = await ocean.compute.status(
bob,
undefined,
undefined,
computeOrderId,
true
)
assert(response[0].jobId === jobId)
})
it('Bob should get status of a compute job without signing', async () => {
assert(jobId != null)
const response = await ocean.compute.status(bob, ddo.id, jobId, false)
const response = await ocean.compute.status(bob, ddo.id, jobId, undefined, false)
assert(response[0].jobId === jobId)
})

it('should get status of all compute jobs for an address without signing', async () => {
const response = await ocean.compute.status(bob, undefined, undefined, false)
const response = await ocean.compute.status(
bob,
undefined,
undefined,
undefined,
false
)
assert(response.length > 0)
})
it('Bob should get status of a compute job', async () => {
Expand Down

0 comments on commit 7f1ae2c

Please sign in to comment.