Skip to content

Commit

Permalink
remove asset sample link if not send on metadata update
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanfazakas committed Feb 8, 2021
1 parent c417fc4 commit 3608472
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ocean/Assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,11 @@ export class Assets extends Instantiable {
if (newMetadata.description)
ddo.service[i].attributes.additionalInformation.description =
newMetadata.description
if (newMetadata.links)
if (newMetadata.links) {
ddo.service[i].attributes.additionalInformation.links = newMetadata.links
} else {
ddo.service[i].attributes.additionalInformation.links = []
}
}
return ddo
}
Expand Down
19 changes: 19 additions & 0 deletions test/integration/Marketplaceflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,25 @@ describe('Marketplace flow', () => {
assert.deepEqual(metaData.attributes.additionalInformation.links, newMetaData.links)
})

it('Alice updates metadata and removes sample links', async () => {
const newMetaData: EditableMetadata = {
description: 'new description no links',
title: 'new title no links'
}
const newDdo = await ocean.assets.editMetadata(ddo, newMetaData)
assert(newDdo !== null)
const txid = await ocean.onChainMetadata.update(newDdo.id, newDdo, alice.getId())
assert(txid !== null)
await sleep(60000)
const metaData = await ocean.assets.getServiceByType(ddo.id, 'metadata')
assert.equal(metaData.attributes.main.name, newMetaData.title)
assert.equal(
metaData.attributes.additionalInformation.description,
newMetaData.description
)
assert.deepEqual(metaData.attributes.additionalInformation.links, [])
})

it('Alice updates timeout for the access service', async () => {
const service = ddo.findServiceByType('access')
assert(service !== null)
Expand Down

0 comments on commit 3608472

Please sign in to comment.