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

test fixes

This commit is contained in:
Matthias Kretschmann 2020-01-29 14:38:44 +01:00
parent 768c69bdbd
commit 09c2f9f818
Signed by: m
GPG Key ID: 606EEEF3C479A91F
11 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,6 @@
import { MetaData, MetaDataAlgorithm } from '../../src' // @oceanprotocol/squid import { MetaData, MetaDataAlgorithm } from '../../src' // @oceanprotocol/squid
import { ServiceType } from '../../src/ddo/Service' import { ServiceType } from '../../src/ddo/Service'
import ddoExample from '../../test/testdata/ddo.json' import ddoExample from '../../test/__fixtures__/ddo.json'
const metadata: Partial<MetaData> = { const metadata: Partial<MetaData> = {
main: { main: {

View File

@ -7,6 +7,7 @@ import { AgreementConditionsStatus } from '../keeper/contracts/templates/Agreeme
import { ConditionState } from '../keeper/contracts/conditions/Condition.abstract' import { ConditionState } from '../keeper/contracts/conditions/Condition.abstract'
import { OceanAgreementsConditions } from './OceanAgreementsConditions' import { OceanAgreementsConditions } from './OceanAgreementsConditions'
import { Service } from '../ddo/Service'
export interface AgreementPrepareResult { export interface AgreementPrepareResult {
agreementId: string agreementId: string
@ -121,7 +122,7 @@ export class OceanAgreements extends Instantiable {
) { ) {
const d: DID = DID.parse(did) const d: DID = DID.parse(did)
const ddo = await this.ocean.aquarius.retrieveDDO(d) const ddo = await this.ocean.aquarius.retrieveDDO(d)
const service = ddo.findServiceById(index) const service: Service = ddo.findServiceById(index)
const templateName = service.attributes.serviceAgreementTemplate.contractName const templateName = service.attributes.serviceAgreementTemplate.contractName
return this.ocean.keeper return this.ocean.keeper
.getTemplateByName(templateName) .getTemplateByName(templateName)

View File

@ -3,7 +3,7 @@ import Account from '../Account'
import { zeroX, Logger, generateId } from '../../utils' import { zeroX, Logger, generateId } from '../../utils'
import { Ocean } from '../../squid' import { Ocean } from '../../squid'
import { Condition } from '../../keeper/contracts/conditions' import { Condition } from '../../keeper/contracts/conditions'
import { ServiceType } from '../../ddo/Service' import { ServiceType, Service } from '../../ddo/Service'
export enum OrderProgressStep { export enum OrderProgressStep {
CreatingAgreement, CreatingAgreement,
@ -32,16 +32,18 @@ export class ServiceUtils {
const { keeper, agreements } = this.ocean const { keeper, agreements } = this.ocean
const agreementId = zeroX(generateId()) const agreementId = zeroX(generateId())
const { index, attributes } = ddo.findServiceByType(type) const service: Service = ddo.findServiceByType(type)
const metadata = ddo.findServiceByType('metadata') const metadata = ddo.findServiceByType('metadata')
const templateName = attributes.serviceAgreementTemplate.contractName const templateName = service.attributes.serviceAgreementTemplate.contractName
const template = keeper.getTemplateByName(templateName) const template = keeper.getTemplateByName(templateName)
// use price from compute service, // use price from compute service,
// otherwise always take the price from metadata // otherwise always take the price from metadata
const price = const price =
type === 'compute' ? attributes.main.price : metadata.attributes.main.price type === 'compute'
? service.attributes.main.price
: metadata.attributes.main.price
// eslint-disable-next-line no-async-promise-executor // eslint-disable-next-line no-async-promise-executor
const paymentFlow = new Promise(async (resolve, reject) => { const paymentFlow = new Promise(async (resolve, reject) => {
@ -94,7 +96,7 @@ export class ServiceUtils {
await agreements.create( await agreements.create(
ddo.id, ddo.id,
agreementId, agreementId,
index, service.index,
undefined, undefined,
consumerAccount, consumerAccount,
_provider, _provider,

View File

@ -7,7 +7,7 @@ import { Ocean } from '../../src/ocean/Ocean'
import config from '../config' import config from '../config'
import TestContractHandler from '../keeper/TestContractHandler' import TestContractHandler from '../keeper/TestContractHandler'
import * as jsonDDO from '../testdata/ddo.json' import * as jsonDDO from '../__fixtures__/ddo.json'
use(spies) use(spies)

View File

@ -2,7 +2,7 @@ import { assert } from 'chai'
import Account from '../../src/ocean/Account' import Account from '../../src/ocean/Account'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../src/ocean/Ocean'
import config from '../config' import config from '../config'
import ContractBaseMock from '../mocks/ContractBase.Mock' import ContractBaseMock from '../__mocks__/ContractBase.Mock'
import TestContractHandler from './TestContractHandler' import TestContractHandler from './TestContractHandler'
const wrappedContract = new ContractBaseMock('OceanToken') const wrappedContract = new ContractBaseMock('OceanToken')