Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
fix: Initialise the DAGLink name to empty string if a falsey value is…
Browse files Browse the repository at this point in the history
… passed
  • Loading branch information
achingbrain authored and vmx committed Apr 25, 2018
1 parent 8e01deb commit 575a03f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dag-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DAGLink {
// note - links should include size, but this assert is disabled
// for now to maintain consistency with go-ipfs pinset

this._name = name
this._name = name || ''
this._size = size

if (typeof multihash === 'string') {
Expand Down
23 changes: 23 additions & 0 deletions test/dag-node-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,29 @@ module.exports = (repo) => {
})
})

it('create with undefined link name', (done) => {
waterfall([
(cb) => DAGNode.create(Buffer.from('hello'), [
new DAGLink(undefined, 10, 'QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39U')
], cb),
(node, cb) => {
expect(node.links[0].name).to.be.eql('')

waterfall([
(cb) => dagPB.util.serialize(node, cb),
(buffer, cb) => dagPB.util.deserialize(buffer, cb),
(deserialized, cb) => {
Object.getOwnPropertyNames(node).forEach(key => {
expect(node[key]).to.deep.equal(deserialized[key])
})

cb()
}
], cb)
}
], done)
})

it('create an empty node', (done) => {
// this node is not in the repo as we don't copy node data to the browser
expect(7).checks(done)
Expand Down

0 comments on commit 575a03f

Please sign in to comment.