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:
parent
e7acadb2fe
commit
ac39369543
@ -2,7 +2,7 @@ import { assert } from 'chai'
|
||||
|
||||
import { config } from '../config'
|
||||
import { Ocean, Account, DDO, MetaData } from '../../src' // @oceanprotocol/squid
|
||||
import { getMetadata, computeService } from '../utils'
|
||||
import { getMetadata, getComputeServiceExample } from '../utils'
|
||||
|
||||
describe('Compute', () => {
|
||||
let ocean: Ocean
|
||||
@ -13,12 +13,13 @@ describe('Compute', () => {
|
||||
|
||||
const metadataAsset = getMetadata()
|
||||
const metadataAlgorithm = getMetadata(0, 'algorithm')
|
||||
const computeServiceExample = getComputeServiceExample()
|
||||
|
||||
before(async () => {
|
||||
ocean = await Ocean.getInstance(config)
|
||||
;[account] = await ocean.accounts.list()
|
||||
ddoAsset = await ocean.assets.create(metadataAsset as MetaData, account, [
|
||||
computeService
|
||||
computeServiceExample
|
||||
])
|
||||
ddoAlgorithm = await ocean.assets.create(metadataAlgorithm as MetaData, account)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { MetaData } from '../../src' // @oceanprotocol/squid
|
||||
import { ServiceType } from '../../src/ddo/Service'
|
||||
import ddoCompute from '../../test/testdata/ddo-compute.json'
|
||||
|
||||
const metadata: Partial<MetaData> = {
|
||||
main: {
|
||||
@ -81,204 +82,15 @@ export const generateMetadata = (
|
||||
export const getMetadata = (price?: number, type?: 'dataset' | 'algorithm') =>
|
||||
generateMetadata('TestAsset', type, price)
|
||||
|
||||
export const computeService = {
|
||||
type: 'compute' as ServiceType,
|
||||
index: 2,
|
||||
serviceEndpoint: 'http://mybrizo.org/api/v1/brizo/services/compute',
|
||||
templateId: '',
|
||||
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'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
export const getComputeServiceExample = () => {
|
||||
const computeService = ddoCompute.service.find(service => service.type === 'compute')
|
||||
const { index, serviceEndpoint, templateId, attributes } = computeService
|
||||
|
||||
return {
|
||||
type: 'compute' as ServiceType,
|
||||
index,
|
||||
serviceEndpoint,
|
||||
templateId,
|
||||
attributes
|
||||
}
|
||||
}
|
||||
|
2
test/testdata/ddo-compute.json
vendored
2
test/testdata/ddo-compute.json
vendored
@ -46,7 +46,7 @@
|
||||
},
|
||||
{
|
||||
"type": "compute",
|
||||
"index": 2,
|
||||
"index": 1,
|
||||
"serviceEndpoint": "http://mybrizo.org/api/v1/brizo/services/compute",
|
||||
"templateId": "",
|
||||
"attributes": {
|
||||
|
Loading…
Reference in New Issue
Block a user