Fix style issues and failing unit tests.

This commit is contained in:
ssallam 2020-03-06 11:35:31 +01:00
parent e2ed974af2
commit c26ae88fa3
10 changed files with 50 additions and 24 deletions

View File

@ -24,9 +24,9 @@ before_script:
- git clone https://github.com/oceanprotocol/barge
- cd barge
- export AQUARIUS_VERSION=v1.0.7
- export BRIZO_VERSION=v0.9.0
- export BRIZO_VERSION=v0.9.3
- export KEEPER_VERSION=v0.13.2
- export EVENTS_HANDLER_VERSION=v0.4.4
- export EVENTS_HANDLER_VERSION=v0.4.5
- export KEEPER_OWNER_ROLE_ADDRESS="0xe2DD09d719Da89e5a3D0F2549c7E24566e947260"
- rm -rf "${HOME}/.ocean/keeper-contracts/artifacts"
- bash -x start_ocean.sh --no-commons --no-dashboard 2>&1 > start_ocean.log &

View File

@ -137,10 +137,10 @@ export class Brizo extends Instantiable {
url += `?signature=${signature}`
url += `&consumerAddress=${address}`
url += `&serviceAgreementId=${noZeroX(serviceAgreementId)}`
url += algorithmDid && `&algorithmDid=${algorithmDid}` || ''
url += algorithmMeta && `&algorithmMeta=${algorithmMeta}` || ''
url += output && `&output=${JSON.stringify(output)}` || ''
url += jobId && `&jobId=${jobId}` || ''
url += (algorithmDid && `&algorithmDid=${algorithmDid}`) || ''
url += (algorithmMeta && `&algorithmMeta=${algorithmMeta}`) || ''
url += (output && `&output=${JSON.stringify(output)}`) || ''
url += (jobId && `&jobId=${jobId}`) || ''
// switch fetch method
let fetch

View File

@ -159,12 +159,16 @@ export class OceanAssets extends Instantiable {
})
// Overwrite initial service agreement conditions
let rawConditions = await templates.escrowAccessSecretStoreTemplate.getServiceAgreementTemplateConditions()
serviceAgreementTemplate.conditions = fillConditionsWithDDO(rawConditions, ddo)
for (let service of services) {
serviceAgreementTemplate.conditions = fillConditionsWithDDO(
await templates.escrowAccessSecretStoreTemplate.getServiceAgreementTemplateConditions(),
ddo
)
for (const service of services) {
if (service.type === 'compute') {
const rawConditions = await templates.escrowComputeExecutionTemplate.getServiceAgreementTemplateConditions()
service.attributes.serviceAgreementTemplate.conditions = fillConditionsWithDDO(rawConditions, ddo)
service.attributes.serviceAgreementTemplate.conditions = fillConditionsWithDDO(
await templates.escrowComputeExecutionTemplate.getServiceAgreementTemplateConditions(),
ddo
)
}
}

View File

@ -6,7 +6,6 @@ import { SubscribablePromise } from '../utils'
import { OrderProgressStep } from './utils/ServiceUtils'
import { DID } from '../squid'
export const ComputeJobStatus = Object.freeze({
Started: 10,
ConfiguringVolumes: 20,
@ -250,7 +249,7 @@ export class OceanCompute extends Instantiable {
consumerAccount: Account,
agreementId: string,
jobId: string
): Promise<ComputeJob> {
): Promise<ComputeJob> {
const computeJobsList = await this.ocean.brizo.compute(
'get',
agreementId,

View File

@ -86,7 +86,12 @@ describe('Asset Owners', () => {
// Granting access
try {
await account2.requestTokens(
parseInt((+metadata.main.price * 10 ** -(await ocean.keeper.token.decimals())).toString())
parseInt(
(
+metadata.main.price *
10 ** -(await ocean.keeper.token.decimals())
).toString()
)
)
} catch {}

View File

@ -70,8 +70,12 @@ describe('Compute', () => {
const steps = []
try {
await account.requestTokens(
parseInt((+computeService.attributes.main.price *
10 ** -(await ocean.keeper.token.decimals())).toString())
parseInt(
(
+computeService.attributes.main.price *
10 ** -(await ocean.keeper.token.decimals())
).toString()
)
)
agreementId = await ocean.compute

View File

@ -45,8 +45,12 @@ describe('Consume Asset', () => {
it('should be able to request tokens for consumer', async () => {
const initialBalance = (await consumer.getBalance()).ocn
const claimedTokens =
parseInt((+metadata.main.price * 10 ** -(await ocean.keeper.token.decimals())).toString())
const claimedTokens = parseInt(
(
+metadata.main.price *
10 ** -(await ocean.keeper.token.decimals())
).toString()
)
try {
await consumer.requestTokens(claimedTokens)

View File

@ -54,7 +54,12 @@ describe('Consume Asset (Brizo)', () => {
try {
await consumer.requestTokens(
parseInt((+metadata.main.price * 10 ** -(await ocean.keeper.token.decimals())).toString())
parseInt(
(
+metadata.main.price *
10 ** -(await ocean.keeper.token.decimals())
).toString()
)
)
agreementId = await ocean.assets

View File

@ -52,7 +52,12 @@ xdescribe('Consume Asset (Large size)', () => {
it('should order the asset', async () => {
try {
await consumer.requestTokens(
parseInt((+metadata.main.price * 10 ** -(await ocean.keeper.token.decimals())).toString())
parseInt(
(
+metadata.main.price *
10 ** -(await ocean.keeper.token.decimals())
).toString()
)
)
} catch {}

View File

@ -27,7 +27,7 @@ describe('OceanCompute', () => {
describe('#start()', () => {
it('should start a new job', async () => {
sinon.stub(ocean.brizo, 'compute').returns({ jobId: 'my-job-id' } as any)
sinon.stub(ocean.brizo, 'compute').returns([{ jobId: 'my-job-id' }] as any)
const response = await compute.start(account, agreementId, 'did:op:0xxx')
assert(response.jobId === 'my-job-id')
})
@ -37,7 +37,7 @@ describe('OceanCompute', () => {
it('should stop a job', async () => {
sinon
.stub(ocean.brizo, 'compute')
.returns({ status: ComputeJobStatus.Completed } as any)
.returns([{ status: ComputeJobStatus.Completed }] as any)
const response = await compute.stop(account, agreementId, 'xxx')
assert(response.status === ComputeJobStatus.Completed)
@ -48,7 +48,7 @@ describe('OceanCompute', () => {
it('should restart a job', async () => {
sinon
.stub(ocean.brizo, 'compute')
.returns({ status: ComputeJobStatus.Started, jobId: 'my-job-id' } as any)
.returns([{ status: ComputeJobStatus.Started, jobId: 'my-job-id' }] as any)
const response = await compute.restart(account, agreementId, 'xxx')
assert(response.jobId === 'my-job-id')
@ -59,7 +59,7 @@ describe('OceanCompute', () => {
it('should delete a job', async () => {
sinon
.stub(ocean.brizo, 'compute')
.returns({ status: ComputeJobStatus.Deleted } as any)
.returns([{ status: ComputeJobStatus.Deleted }] as any)
const response = await compute.delete(account, agreementId, 'xxx')
assert(response.status === ComputeJobStatus.Deleted)