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

test data consolidation

This commit is contained in:
Matthias Kretschmann 2020-01-27 16:50:33 +01:00
parent e7acadb2fe
commit ac39369543
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 15 additions and 202 deletions

View File

@ -2,7 +2,7 @@ import { assert } from 'chai'
import { config } from '../config' import { config } from '../config'
import { Ocean, Account, DDO, MetaData } from '../../src' // @oceanprotocol/squid import { Ocean, Account, DDO, MetaData } from '../../src' // @oceanprotocol/squid
import { getMetadata, computeService } from '../utils' import { getMetadata, getComputeServiceExample } from '../utils'
describe('Compute', () => { describe('Compute', () => {
let ocean: Ocean let ocean: Ocean
@ -13,12 +13,13 @@ describe('Compute', () => {
const metadataAsset = getMetadata() const metadataAsset = getMetadata()
const metadataAlgorithm = getMetadata(0, 'algorithm') const metadataAlgorithm = getMetadata(0, 'algorithm')
const computeServiceExample = getComputeServiceExample()
before(async () => { before(async () => {
ocean = await Ocean.getInstance(config) ocean = await Ocean.getInstance(config)
;[account] = await ocean.accounts.list() ;[account] = await ocean.accounts.list()
ddoAsset = await ocean.assets.create(metadataAsset as MetaData, account, [ ddoAsset = await ocean.assets.create(metadataAsset as MetaData, account, [
computeService computeServiceExample
]) ])
ddoAlgorithm = await ocean.assets.create(metadataAlgorithm as MetaData, account) ddoAlgorithm = await ocean.assets.create(metadataAlgorithm as MetaData, account)

View File

@ -1,5 +1,6 @@
import { MetaData } from '../../src' // @oceanprotocol/squid import { MetaData } from '../../src' // @oceanprotocol/squid
import { ServiceType } from '../../src/ddo/Service' import { ServiceType } from '../../src/ddo/Service'
import ddoCompute from '../../test/testdata/ddo-compute.json'
const metadata: Partial<MetaData> = { const metadata: Partial<MetaData> = {
main: { main: {
@ -81,204 +82,15 @@ export const generateMetadata = (
export const getMetadata = (price?: number, type?: 'dataset' | 'algorithm') => export const getMetadata = (price?: number, type?: 'dataset' | 'algorithm') =>
generateMetadata('TestAsset', type, price) generateMetadata('TestAsset', type, price)
export const computeService = { export const getComputeServiceExample = () => {
const computeService = ddoCompute.service.find(service => service.type === 'compute')
const { index, serviceEndpoint, templateId, attributes } = computeService
return {
type: 'compute' as ServiceType, type: 'compute' as ServiceType,
index: 2, index,
serviceEndpoint: 'http://mybrizo.org/api/v1/brizo/services/compute', serviceEndpoint,
templateId: '', templateId,
attributes: { attributes
main: {
name: 'dataAssetComputingServiceAgreement',
creator: '0x00Bd138aBD70e2F00903268F3Db08f2D25677C9e',
price: '10',
timeout: 86400,
provider: {
type: 'Azure',
description: '',
environment: {
cluster: {
type: 'Kubernetes',
url: 'http://10.0.0.17/xxx'
},
supportedContainers: [
{
image: 'tensorflow/tensorflow',
tag: 'latest',
checksum:
'sha256:cb57ecfa6ebbefd8ffc7f75c0f00e57a7fa739578a429b6f72a0df19315deadc'
},
{
image: 'tensorflow/tensorflow',
tag: 'latest',
checksum:
'sha256:cb57ecfa6ebbefd8ffc7f75c0f00e57a7fa739578a429b6f72a0df19315deadc'
}
],
supportedServers: [
{
serverId: '1',
serverType: 'xlsize',
price: '50',
cpu: '16',
gpu: '0',
memory: '128gb',
disk: '160gb',
maxExecutionTime: 86400
},
{
serverId: '2',
serverType: 'medium',
price: '10',
cpu: '2',
gpu: '0',
memory: '8gb',
disk: '80gb',
maxExecutionTime: 86400
}
]
}
}
},
additionalInformation: {}
},
serviceAgreementTemplate: {
contractName: 'EscrowComputeExecutionTemplate',
events: [
{
name: 'AgreementCreated',
actorType: 'consumer',
handler: {
moduleName: 'serviceExecutionTemplate',
functionName: 'fulfillLockRewardCondition',
version: '0.1'
}
}
],
fulfillmentOrder: [
'lockReward.fulfill',
'serviceExecution.fulfill',
'escrowReward.fulfill'
],
conditionDependency: {
lockReward: [],
serviceExecution: [],
releaseReward: ['lockReward', 'serviceExecution']
},
conditions: [
{
name: 'lockReward',
timelock: 0,
timeout: 0,
contractName: 'LockRewardCondition',
functionName: 'fulfill',
parameters: [
{
name: '_rewardAddress',
type: 'address',
value: ''
},
{
name: '_amount',
type: 'uint256',
value: ''
}
],
events: [
{
name: 'Fulfilled',
actorType: 'publisher',
handler: {
moduleName: 'lockRewardCondition',
functionName: 'fulfillServiceExecutionCondition',
version: '0.1'
}
}
]
},
{
name: 'serviceExecution',
timelock: 0,
timeout: 0,
contractName: 'ComputeExecutionCondition',
functionName: 'fulfill',
parameters: [
{
name: '_documentId',
type: 'bytes32',
value: ''
},
{
name: '_grantee',
type: 'address',
value: ''
}
],
events: [
{
name: 'Fulfilled',
actorType: 'publisher',
handler: {
moduleName: 'serviceExecution',
functionName: 'fulfillServiceExecutionCondition',
version: '0.1'
}
},
{
name: 'TimedOut',
actorType: 'consumer',
handler: {
moduleName: 'serviceExec',
functionName: 'fulfillServiceExecutionCondition',
version: '0.1'
}
}
]
},
{
name: 'escrowReward',
timelock: 0,
timeout: 0,
contractName: 'EscrowReward',
functionName: 'fulfill',
parameters: [
{
name: '_amount',
type: 'uint256',
value: ''
},
{
name: '_receiver',
type: 'address',
value: ''
},
{
name: '_sender',
type: 'address',
value: ''
},
{
name: '_lockCondition',
type: 'bytes32',
value: ''
},
{
name: '_releaseCondition',
type: 'bytes32',
value: ''
}
],
events: [
{
name: 'Fulfilled',
actorType: 'publisher',
handler: {
moduleName: 'escrowRewardCondition',
functionName: 'verifyRewardTokens',
version: '0.1'
}
}
]
}
]
} }
} }

View File

@ -46,7 +46,7 @@
}, },
{ {
"type": "compute", "type": "compute",
"index": 2, "index": 1,
"serviceEndpoint": "http://mybrizo.org/api/v1/brizo/services/compute", "serviceEndpoint": "http://mybrizo.org/api/v1/brizo/services/compute",
"templateId": "", "templateId": "",
"attributes": { "attributes": {