squid-js/integration/ocean/Compute.test.ts

36 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-01-21 22:09:32 +01:00
import { assert } from 'chai'
import { config } from '../config'
import { Ocean, Account, DDO, MetaData } from '../../src' // @oceanprotocol/squid
2020-01-27 16:50:33 +01:00
import { getMetadata, getComputeServiceExample } from '../utils'
2020-01-21 22:09:32 +01:00
describe('Compute', () => {
let ocean: Ocean
let account: Account
let ddoAsset: DDO
let ddoAlgorithm: DDO
2020-01-27 15:59:26 +01:00
let agreementId: string
2020-01-21 22:09:32 +01:00
const metadataAsset = getMetadata()
const metadataAlgorithm = getMetadata(0, 'algorithm')
2020-01-27 16:50:33 +01:00
const computeServiceExample = getComputeServiceExample()
2020-01-21 22:09:32 +01:00
before(async () => {
ocean = await Ocean.getInstance(config)
;[account] = await ocean.accounts.list()
2020-01-24 15:23:50 +01:00
ddoAsset = await ocean.assets.create(metadataAsset as MetaData, account, [
2020-01-27 16:50:33 +01:00
computeServiceExample
2020-01-24 15:23:50 +01:00
])
2020-01-21 22:09:32 +01:00
ddoAlgorithm = await ocean.assets.create(metadataAlgorithm as MetaData, account)
2020-01-27 15:59:26 +01:00
// order compute service
agreementId = await ocean.compute.order(account, ddoAsset.id)
2020-01-21 22:09:32 +01:00
})
2020-01-27 15:59:26 +01:00
it('should start a compute job', async () => {
2020-01-21 22:09:32 +01:00
const response = await ocean.compute.start(account, agreementId, ddoAlgorithm.id)
2020-01-27 15:59:26 +01:00
assert.equal(response.status, 1)
2020-01-21 22:09:32 +01:00
})
})