diff --git a/integration/ocean/Compute.test.ts b/integration/ocean/Compute.test.ts new file mode 100644 index 0000000..51c7070 --- /dev/null +++ b/integration/ocean/Compute.test.ts @@ -0,0 +1,29 @@ +import { assert } from 'chai' + +import { config } from '../config' +import { Ocean, Account, DDO, MetaData } from '../../src' // @oceanprotocol/squid +import { getMetadata } from '../utils' + +describe('Compute', () => { + let ocean: Ocean + let account: Account + let ddoAsset: DDO + let ddoAlgorithm: DDO + + const metadataAsset = getMetadata() + const metadataAlgorithm = getMetadata(0, 'algorithm') + + before(async () => { + ocean = await Ocean.getInstance(config) + ;[account] = await ocean.accounts.list() + ddoAsset = await ocean.assets.create(metadataAsset as MetaData, account) + ddoAlgorithm = await ocean.assets.create(metadataAlgorithm as MetaData, account) + }) + + it('should order & start a compute job', async () => { + const agreementId = await ocean.compute.order(account, ddoAsset.id) + const response = await ocean.compute.start(account, agreementId, ddoAlgorithm.id) + + // assert.deepEqual(response) + }) +}) diff --git a/integration/utils/ddo-metadata-generator.ts b/integration/utils/ddo-metadata-generator.ts index 8608aad..94078ae 100644 --- a/integration/utils/ddo-metadata-generator.ts +++ b/integration/utils/ddo-metadata-generator.ts @@ -3,7 +3,7 @@ import { MetaData } from '../../src' // @oceanprotocol/squid const metadata: Partial = { main: { name: undefined, - type: 'dataset', + type: undefined, dateCreated: '2012-10-10T17:00:00Z', datePublished: '2012-10-10T17:00:00Z', author: 'Met Office', @@ -46,11 +46,16 @@ const metadata: Partial = { } } -export const generateMetadata = (name: string, price?: number): Partial => ({ +export const generateMetadata = ( + name: string, + type?: 'dataset' | 'algorithm', + price?: number +): Partial => ({ ...metadata, main: { ...metadata.main, name, + type: type || 'dataset', price: (price || 21) + '0'.repeat(18) }, additionalInformation: { @@ -58,4 +63,5 @@ export const generateMetadata = (name: string, price?: number): Partial generateMetadata('TestAsset', price) +export const getMetadata = (price?: number, type?: 'dataset' | 'algorithm') => + generateMetadata('TestAsset', type, price)