Skip to content

Commit

Permalink
more typings updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kremalicious committed Oct 12, 2020
1 parent f086d59 commit 410f6d7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
3 changes: 2 additions & 1 deletion src/ocean/Compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ export class Compute extends Instantiable {
did?: string,
jobId?: string
): Promise<ComputeJob[]> {
let provider
let provider: Provider

if (did) {
const ddo = await this.ocean.assets.resolve(did)
const service = ddo.findServiceByType('compute')
Expand Down
3 changes: 2 additions & 1 deletion src/provider/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const apiPath = '/api/v1/services'
export class Provider extends Instantiable {
public nonce: string
private baseUrl: string
public get url() {

public get url(): string {
return this.baseUrl
}

Expand Down
69 changes: 35 additions & 34 deletions test/integration/ComputeFlow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,50 @@ import { TestContractHandler } from '../TestContractHandler'
import { DataTokens } from '../../src/datatokens/Datatokens'
import { Ocean } from '../../src/ocean/Ocean'
import { ConfigHelper } from '../../src/utils/ConfigHelper'

import { assert } from 'chai'
import { ServiceCommon, ServiceComputePrivacy } from '../../src/ddo/interfaces/Service'
import { Service, ServiceComputePrivacy } from '../../src/ddo/interfaces/Service'
import Web3 from 'web3'
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
import datatokensTemplate from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
import { Account, DDO, Metadata } from '../../src/lib'
import { Cluster, Container, Server } from '../../src/ocean/Compute'
const web3 = new Web3('http://127.0.0.1:8545')

function sleep(ms) {
function sleep(ms: number) {
return new Promise((resolve) => {
setTimeout(resolve, ms)
})
}

describe('Compute flow', () => {
let owner
let bob
let ddo
let alice
let asset
let datasetNoRawAlgo
let datasetWithTrustedAlgo
let algorithmAsset
let contracts
let owner: Account
let bob: Account
let ddo: DDO
let alice: Account
let asset: Metadata
let datasetNoRawAlgo: DDO
let datasetWithTrustedAlgo: DDO
let algorithmAsset: DDO
let contracts: TestContractHandler
let datatoken: DataTokens
let tokenAddress
let tokenAddressNoRawAlgo
let tokenAddressWithTrustedAlgo
let tokenAddressAlgorithm
let tokenAddress: string
let tokenAddressNoRawAlgo: string
let tokenAddressWithTrustedAlgo: string
let tokenAddressAlgorithm: string
let price: string
let ocean
let computeService: ServiceCommon
let data
let blob
let jobId
let ocean: Ocean
let computeService: Service
let data: { t: number; url: string }
let blob: string
let jobId: string

let cluster
let servers
let containers
let provider
let cluster: Cluster
let servers: Server[]
let containers: Container[]
let providerAttributes: any

const dateCreated = new Date(Date.now()).toISOString().split('.')[0] + 'Z' // remove milliseconds

const marketplaceAllowance = '20'
const tokenAmount = '100'

const timeout = 86400
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('Compute flow', () => {
'sha256:cb57ecfa6ebbefd8ffc7f75c0f00e57a7fa739578a429b6f72a0df19315deadc'
)
]
provider = ocean.compute.createProviderAttributes(
providerAttributes = ocean.compute.createProviderAttributes(
'Azure',
'Compute service with 16gb ram for each node.',
cluster,
Expand All @@ -186,7 +186,7 @@ describe('Compute flow', () => {
alice,
price,
dateCreated,
provider,
providerAttributes,
origComputePrivacy as ServiceComputePrivacy
)
ddo = await ocean.assets.create(asset, alice, [computeService], tokenAddress)
Expand All @@ -205,7 +205,7 @@ describe('Compute flow', () => {
alice,
'1000',
dateCreated,
provider,
providerAttributes,
origComputePrivacy as ServiceComputePrivacy
)
datasetNoRawAlgo = await ocean.assets.create(
Expand All @@ -229,7 +229,7 @@ describe('Compute flow', () => {
alice,
'1000',
dateCreated,
provider,
providerAttributes,
origComputePrivacy as ServiceComputePrivacy
)
datasetWithTrustedAlgo = await ocean.assets.create(
Expand All @@ -243,7 +243,7 @@ describe('Compute flow', () => {
})

it('should publish an algorithm', async () => {
const algoAsset = {
const algoAsset: Metadata = {
main: {
type: 'algorithm',
name: 'Test Algo',
Expand Down Expand Up @@ -344,7 +344,7 @@ describe('Compute flow', () => {
undefined,
algorithmMeta,
output,
computeService.index,
`${computeService.index}`,
computeService.type
)
jobId = response.jobId
Expand All @@ -365,7 +365,8 @@ describe('Compute flow', () => {
assert(jobId != null)
await ocean.compute.stop(bob, ddo.id, jobId)
const response = await ocean.compute.status(bob, ddo.id, jobId)
assert(response[0].stopreq === 1)
// TODO: typings say that `stopreq` does not exist
assert((response[0] as any).stopreq === 1)
})
it('should not allow order the compute service with raw algo for dataset that does not allow raw algo', async () => {
const service1 = datasetNoRawAlgo.findServiceByType('compute')
Expand Down Expand Up @@ -416,7 +417,7 @@ describe('Compute flow', () => {
algorithmAsset.id,
undefined,
output,
computeService.index,
`${computeService.index}`,
computeService.type,
orderalgo,
algorithmAsset.dataToken
Expand Down
4 changes: 2 additions & 2 deletions test/integration/Marketplaceflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import spies from 'chai-spies'
import Web3 from 'web3'
import { AbiItem } from 'web3-utils/types'
import { DataTokens } from '../../src/datatokens/Datatokens'
import { Account, EditableMetadata, ServiceAccess, ServiceCommon } from '../../src/lib'
import { Account, EditableMetadata, Service, ServiceAccess } from '../../src/lib'
import { Ocean } from '../../src/ocean/Ocean'
import { ConfigHelper } from '../../src/utils/ConfigHelper'
import { TestContractHandler } from '../TestContractHandler'
Expand Down Expand Up @@ -33,7 +33,7 @@ describe('Marketplace flow', () => {
let service1: ServiceAccess
let price: string
let ocean: Ocean
let accessService: ServiceCommon
let accessService: Service
let data
let blob

Expand Down

0 comments on commit 410f6d7

Please sign in to comment.