import { assert } from 'chai' import { ethers, Signer } from 'ethers' import { getTestConfig, getAddresses, provider } from '../config' import { Config, ProviderInstance, Aquarius, Datatoken, sendTx, amountToUnits } from '../../src' import { ComputeJob, ComputeAsset, ComputeAlgorithm, Files } from '../../src/@types' import { createAsset, handleComputeOrder } from './helpers' let config: Config let aquarius: Aquarius let datatoken: Datatoken let providerUrl: string let consumerAccount: Signer let publisherAccount: Signer let providerInitializeComputeResults let computeEnvs let addresses: any let ddoWith5mTimeoutId let ddoWithNoTimeoutId let algoDdoWith5mTimeoutId let algoDdoWithNoTimeoutId let freeComputeJobId: string let paidComputeJobId: string let resolvedDdoWith5mTimeout let resolvedDdoWithNoTimeout let resolvedAlgoDdoWith5mTimeout let resolvedAlgoDdoWithNoTimeout let freeEnvDatasetTxId let freeEnvAlgoTxId let paidEnvDatasetTxId let paidEnvAlgoTxId let computeValidUntil const assetUrl: Files = { datatokenAddress: '0x0', nftAddress: '0x0', files: [ { type: 'url', url: 'https://raw.githubusercontent.com/oceanprotocol/testdatasets/main/shs_dataset_test.txt', method: 'GET' } ] } const ddoWithNoTimeout = { '@context': ['https://w3id.org/did/v1'], id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c', version: '4.1.0', chainId: 4, nftAddress: '0x0', metadata: { created: '2021-12-20T14:35:20Z', updated: '2021-12-20T14:35:20Z', type: 'dataset', name: 'dfgdfgdg', description: 'd dfgd fgd dfg dfgdfgd dfgdf', tags: [''], author: 'dd', license: 'https://market.oceanprotocol.com/terms', additionalInformation: { termsAndConditions: true } }, services: [ { id: 'notAnId', type: 'compute', files: '', datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3', serviceEndpoint: 'http://172.15.0.4:8030', timeout: 0, compute: { publisherTrustedAlgorithmPublishers: [], publisherTrustedAlgorithms: [], allowRawAlgorithm: true, allowNetworkAccess: true } } ] } const ddoWith5mTimeout = { '@context': ['https://w3id.org/did/v1'], id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c', version: '4.1.0', chainId: 4, nftAddress: '0x0', metadata: { created: '2021-12-20T14:35:20Z', updated: '2021-12-20T14:35:20Z', type: 'dataset', name: 'dfgdfgdg', description: 'd dfgd fgd dfg dfgdfgd dfgdf', tags: [''], author: 'dd', license: 'https://market.oceanprotocol.com/terms', additionalInformation: { termsAndConditions: true } }, services: [ { id: 'notAnId', type: 'compute', files: '', datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3', serviceEndpoint: 'http://172.15.0.4:8030', timeout: 300, compute: { publisherTrustedAlgorithmPublishers: [], publisherTrustedAlgorithms: [], allowRawAlgorithm: true, allowNetworkAccess: true } } ] } const algoAssetUrl: Files = { datatokenAddress: '0x0', nftAddress: '0x0', files: [ { type: 'url', url: 'https://raw.githubusercontent.com/oceanprotocol/test-algorithm/master/javascript/algo.js', method: 'GET' } ] } const algoDdoWithNoTimeout = { '@context': ['https://w3id.org/did/v1'], id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c', version: '4.1.0', chainId: 4, nftAddress: '0x0', metadata: { created: '2021-12-20T14:35:20Z', updated: '2021-12-20T14:35:20Z', type: 'algorithm', name: 'dfgdfgdg', description: 'd dfgd fgd dfg dfgdfgd dfgdf', tags: [''], author: 'dd', license: 'https://market.oceanprotocol.com/terms', additionalInformation: { termsAndConditions: true }, algorithm: { language: 'Node.js', version: '1.0.0', container: { entrypoint: 'node $ALGO', image: 'ubuntu', tag: 'latest', checksum: 'sha256:2d7ecc9c5e08953d586a6e50c29b91479a48f69ac1ba1f9dc0420d18a728dfc5' } } }, services: [ { id: 'notAnId', type: 'access', files: '', datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3', serviceEndpoint: 'http://172.15.0.4:8030', timeout: 0 } ] } const algoDdoWith5mTimeout = { '@context': ['https://w3id.org/did/v1'], id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c', version: '4.1.0', chainId: 4, nftAddress: '0x0', metadata: { created: '2021-12-20T14:35:20Z', updated: '2021-12-20T14:35:20Z', type: 'algorithm', name: 'dfgdfgdg', description: 'd dfgd fgd dfg dfgdfgd dfgdf', tags: [''], author: 'dd', license: 'https://market.oceanprotocol.com/terms', additionalInformation: { termsAndConditions: true }, algorithm: { language: 'Node.js', version: '1.0.0', container: { entrypoint: 'node $ALGO', image: 'ubuntu', tag: 'latest', checksum: 'sha256:2d7ecc9c5e08953d586a6e50c29b91479a48f69ac1ba1f9dc0420d18a728dfc5' } } }, services: [ { id: 'notAnId', type: 'access', files: '', datatokenAddress: '0xa15024b732A8f2146423D14209eFd074e61964F3', serviceEndpoint: 'http://172.15.0.4:8030', timeout: 300 } ] } function delay(interval: number) { return it('should delay', (done) => { setTimeout(() => done(), interval) }).timeout(interval + 100) } async function waitTillJobEnds(): Promise { return new Promise((resolve) => { const interval = setInterval(async () => { const jobStatus = (await ProviderInstance.computeStatus( providerUrl, await consumerAccount.getAddress(), freeComputeJobId, resolvedDdoWith5mTimeout.id )) as ComputeJob if (jobStatus?.status === 70) { clearInterval(interval) resolve(jobStatus.status) } }, 10000) }) } describe('Compute flow tests', async () => { before(async () => { publisherAccount = (await provider.getSigner(0)) as Signer consumerAccount = (await provider.getSigner(1)) as Signer config = await getTestConfig(publisherAccount) aquarius = new Aquarius(config?.metadataCacheUri) providerUrl = config?.providerUri addresses = getAddresses() }) it('should publish datasets and algorithms', async () => { // mint Ocean ///