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:
parent
768c69bdbd
commit
09c2f9f818
@ -1,6 +1,6 @@
|
||||
import { MetaData, MetaDataAlgorithm } from '../../src' // @oceanprotocol/squid
|
||||
import { ServiceType } from '../../src/ddo/Service'
|
||||
import ddoExample from '../../test/testdata/ddo.json'
|
||||
import ddoExample from '../../test/__fixtures__/ddo.json'
|
||||
|
||||
const metadata: Partial<MetaData> = {
|
||||
main: {
|
||||
|
@ -7,6 +7,7 @@ import { AgreementConditionsStatus } from '../keeper/contracts/templates/Agreeme
|
||||
import { ConditionState } from '../keeper/contracts/conditions/Condition.abstract'
|
||||
|
||||
import { OceanAgreementsConditions } from './OceanAgreementsConditions'
|
||||
import { Service } from '../ddo/Service'
|
||||
|
||||
export interface AgreementPrepareResult {
|
||||
agreementId: string
|
||||
@ -121,7 +122,7 @@ export class OceanAgreements extends Instantiable {
|
||||
) {
|
||||
const d: DID = DID.parse(did)
|
||||
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
|
||||
return this.ocean.keeper
|
||||
.getTemplateByName(templateName)
|
||||
|
@ -3,7 +3,7 @@ import Account from '../Account'
|
||||
import { zeroX, Logger, generateId } from '../../utils'
|
||||
import { Ocean } from '../../squid'
|
||||
import { Condition } from '../../keeper/contracts/conditions'
|
||||
import { ServiceType } from '../../ddo/Service'
|
||||
import { ServiceType, Service } from '../../ddo/Service'
|
||||
|
||||
export enum OrderProgressStep {
|
||||
CreatingAgreement,
|
||||
@ -32,16 +32,18 @@ export class ServiceUtils {
|
||||
const { keeper, agreements } = this.ocean
|
||||
|
||||
const agreementId = zeroX(generateId())
|
||||
const { index, attributes } = ddo.findServiceByType(type)
|
||||
const service: Service = ddo.findServiceByType(type)
|
||||
const metadata = ddo.findServiceByType('metadata')
|
||||
|
||||
const templateName = attributes.serviceAgreementTemplate.contractName
|
||||
const templateName = service.attributes.serviceAgreementTemplate.contractName
|
||||
const template = keeper.getTemplateByName(templateName)
|
||||
|
||||
// use price from compute service,
|
||||
// otherwise always take the price from metadata
|
||||
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
|
||||
const paymentFlow = new Promise(async (resolve, reject) => {
|
||||
@ -94,7 +96,7 @@ export class ServiceUtils {
|
||||
await agreements.create(
|
||||
ddo.id,
|
||||
agreementId,
|
||||
index,
|
||||
service.index,
|
||||
undefined,
|
||||
consumerAccount,
|
||||
_provider,
|
||||
|
@ -7,7 +7,7 @@ import { Ocean } from '../../src/ocean/Ocean'
|
||||
import config from '../config'
|
||||
import TestContractHandler from '../keeper/TestContractHandler'
|
||||
|
||||
import * as jsonDDO from '../testdata/ddo.json'
|
||||
import * as jsonDDO from '../__fixtures__/ddo.json'
|
||||
|
||||
use(spies)
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { assert } from 'chai'
|
||||
import Account from '../../src/ocean/Account'
|
||||
import { Ocean } from '../../src/ocean/Ocean'
|
||||
import config from '../config'
|
||||
import ContractBaseMock from '../mocks/ContractBase.Mock'
|
||||
import ContractBaseMock from '../__mocks__/ContractBase.Mock'
|
||||
import TestContractHandler from './TestContractHandler'
|
||||
|
||||
const wrappedContract = new ContractBaseMock('OceanToken')
|
||||
|
Loading…
Reference in New Issue
Block a user