1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

test tweaks

This commit is contained in:
Matthias Kretschmann 2020-01-29 20:24:28 +01:00
parent 1f552812f1
commit 1336036067
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -4,16 +4,16 @@ import { config } from '../config'
import { Ocean, Account, DDO, MetaData, ComputeJobStatus } from '../../src' // @oceanprotocol/squid import { Ocean, Account, DDO, MetaData, ComputeJobStatus } from '../../src' // @oceanprotocol/squid
import { getMetadata, getComputeServiceExample } from '../utils' import { getMetadata, getComputeServiceExample } from '../utils'
const metadataAsset = getMetadata()
const metadataAlgorithm = getMetadata(0, 'algorithm')
const computeServiceExample = getComputeServiceExample()
describe('Compute', () => { describe('Compute', () => {
let ocean: Ocean let ocean: Ocean
let account: Account let account: Account
let ddoAsset: DDO
let ddoAlgorithm: DDO
let agreementId: string let agreementId: string
let dataset: DDO
const metadataAsset = getMetadata() let algorithm: DDO
const metadataAlgorithm = getMetadata(0, 'algorithm')
const computeServiceExample = getComputeServiceExample()
before(async () => { before(async () => {
ocean = await Ocean.getInstance(config) ocean = await Ocean.getInstance(config)
@ -24,25 +24,27 @@ describe('Compute', () => {
await account.authenticate() await account.authenticate()
}) })
it('should publish a dataset and an algorithm', async () => { it('should publish a dataset with a compute service object', async () => {
const stepsAsset = [] const stepsAsset = []
ddoAsset = await ocean.assets dataset = await ocean.assets
.create(metadataAsset as MetaData, account, [computeServiceExample]) .create(metadataAsset as MetaData, account, [computeServiceExample])
.next(step => stepsAsset.push(step)) .next(step => stepsAsset.push(step))
assert.instanceOf(ddoAsset, DDO) assert.instanceOf(dataset, DDO)
assert.deepEqual(stepsAsset, [0, 1, 2, 3, 4, 5, 6, 7]) assert.deepEqual(stepsAsset, [0, 1, 2, 3, 4, 5, 6, 7])
})
it('should publish an algorithm', async () => {
const stepsAlgorithm = [] const stepsAlgorithm = []
ddoAlgorithm = await ocean.assets algorithm = await ocean.assets
.create(metadataAlgorithm as MetaData, account) .create(metadataAlgorithm as MetaData, account)
.next(step => stepsAlgorithm.push(step)) .next(step => stepsAlgorithm.push(step))
assert.instanceOf(ddoAlgorithm, DDO) assert.instanceOf(algorithm, DDO)
assert.deepEqual(stepsAlgorithm, [0, 1, 2, 3, 4, 5, 6, 7]) assert.deepEqual(stepsAlgorithm, [0, 1, 2, 3, 4, 5, 6, 7])
}) })
it('should order the compute service', async () => { it('should order the compute service of the dataset', async () => {
const steps = [] const steps = []
try { try {
await account.requestTokens( await account.requestTokens(
@ -51,7 +53,7 @@ describe('Compute', () => {
) )
agreementId = await ocean.compute agreementId = await ocean.compute
.order(account, ddoAsset.id) .order(account, dataset.id)
.next(step => steps.push(step)) .next(step => steps.push(step))
} catch {} } catch {}
@ -60,7 +62,7 @@ describe('Compute', () => {
}) })
it('should start a compute job', async () => { it('should start a compute job', async () => {
const response = await ocean.compute.start(account, agreementId, ddoAlgorithm.id) const response = await ocean.compute.start(account, agreementId, algorithm.id)
assert.equal(response.status, ComputeJobStatus.Started) assert.equal(response.status, ComputeJobStatus.Started)
}) })