diff --git a/src/object.js b/src/object.js index 02387127..938aac4f 100644 --- a/src/object.js +++ b/src/object.js @@ -1,5 +1,4 @@ /* eslint-env mocha */ - 'use strict' const expect = require('chai').expect @@ -8,466 +7,478 @@ const bs58 = require('bs58') const jsonToYaml = require('json2yaml') module.exports = (common) => { - let ipfs - - before((done) => { - common.setup((err, _ipfs) => { - expect(err).to.not.exist - ipfs = _ipfs - done() - }) - }) - - after((done) => { - common.teardown(done) - }) - describe('.object', () => { - it('object.new', (done) => { - ipfs.object.new((err, node) => { + let ipfs + + before((done) => { + common.setup((err, _ipfs) => { expect(err).to.not.exist - expect(node.toJSON().Hash).to.equal('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n') + ipfs = _ipfs done() }) }) - it('object.put of object', (done) => { - const obj = { - Data: new Buffer('Some data'), - Links: [] - } + after((done) => { + common.teardown(done) + }) - ipfs.object.put(obj, (err, node) => { - expect(err).to.not.exist - const nodeJSON = node.toJSON() - expect(obj.Data).to.deep.equal(nodeJSON.Data) - expect(obj.Links).to.deep.equal(nodeJSON.Links) - expect(nodeJSON.Hash).to.equal('QmPb5f92FxKPYdT3QNBd1GKiL4tZUXUrzF4Hkpdr3Gf1gK') - done() + describe('.new', () => { + it('no layout', (done) => { + ipfs.object.new((err, node) => { + expect(err).to.not.exist + expect(node.toJSON().Hash).to.equal('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n') + done() + }) }) }) - it('object.put of json encoded buffer', (done) => { - const obj = { - Data: new Buffer('Some data'), - Links: [] - } - - const obj2 = { - Data: obj.Data.toString(), - Links: obj.Links - } + describe('.put', () => { + it('of object', (done) => { + const obj = { + Data: new Buffer('Some data'), + Links: [] + } - const buf = new Buffer(JSON.stringify(obj2)) + ipfs.object.put(obj, (err, node) => { + expect(err).to.not.exist + const nodeJSON = node.toJSON() + expect(obj.Data).to.deep.equal(nodeJSON.Data) + expect(obj.Links).to.deep.equal(nodeJSON.Links) + expect(nodeJSON.Hash).to.equal('QmPb5f92FxKPYdT3QNBd1GKiL4tZUXUrzF4Hkpdr3Gf1gK') + done() + }) + }) - ipfs.object.put(buf, { enc: 'json' }, (err, node) => { - expect(err).to.not.exist - const nodeJSON = node.toJSON() + it('of json encoded buffer', (done) => { + const obj = { + Data: new Buffer('Some data'), + Links: [] + } - // because js-ipfs-api can't - // infer if the returned Data is Buffer or String - if (typeof node.data === 'string') { - node.data = new Buffer(node.data) + const obj2 = { + Data: obj.Data.toString(), + Links: obj.Links } - expect(obj.Data).to.deep.equal(node.data) - expect(obj.Links).to.deep.equal(nodeJSON.Links) - expect(nodeJSON.Hash).to.equal('QmPb5f92FxKPYdT3QNBd1GKiL4tZUXUrzF4Hkpdr3Gf1gK') - done() - }) - }) + const buf = new Buffer(JSON.stringify(obj2)) - // TODO verify that yaml encoded buffers still work in go-ipfs - it.skip('object.put of yaml encoded buffer', (done) => { - const obj = { - Data: new Buffer('Some data').toString(), - Links: [] - } + ipfs.object.put(buf, { enc: 'json' }, (err, node) => { + expect(err).to.not.exist + const nodeJSON = node.toJSON() - const buf = new Buffer(jsonToYaml.stringify(obj)) + // because js-ipfs-api can't + // infer if the returned Data is Buffer or String + if (typeof node.data === 'string') { + node.data = new Buffer(node.data) + } - ipfs.object.put(buf, { enc: 'yaml' }, (err, node) => { - expect(err).to.not.exist - const nodeJSON = node.toJSON() - expect(obj.Data).to.deep.equal(nodeJSON.Data) - expect(obj.Links).to.deep.equal(nodeJSON.Links) - expect(nodeJSON.Hash).to.equal('QmPb5f92FxKPYdT3QNBd1GKiL4tZUXUrzF4Hkpdr3Gf1gK') - done() + expect(obj.Data).to.deep.equal(node.data) + expect(obj.Links).to.deep.equal(nodeJSON.Links) + expect(nodeJSON.Hash).to.equal('QmPb5f92FxKPYdT3QNBd1GKiL4tZUXUrzF4Hkpdr3Gf1gK') + done() + }) }) - }) - it('object.put of buffer treated as Data field', (done) => { - const data = new Buffer('Some data') - ipfs.object.put(data, (err, node) => { - expect(err).to.not.exist - const nodeJSON = node.toJSON() - expect(data).to.deep.equal(nodeJSON.Data) - expect([]).to.deep.equal(nodeJSON.Links) - expect(nodeJSON.Hash).to.equal('QmPb5f92FxKPYdT3QNBd1GKiL4tZUXUrzF4Hkpdr3Gf1gK') - done() - }) - }) + // TODO verify that yaml encoded buffers still work in go-ipfs + it.skip('of yaml encoded buffer', (done) => { + const obj = { + Data: new Buffer('Some data').toString(), + Links: [] + } - it('object.put of DAGNode', (done) => { - const dNode = new DAGNode(new Buffer('Some data')) + const buf = new Buffer(jsonToYaml.stringify(obj)) - ipfs.object.put(dNode, (err, node) => { - expect(err).to.not.exist - expect(dNode.data).to.deep.equal(node.data) - expect(dNode.links).to.deep.equal(node.links) - expect(dNode.multihash()).to.deep.equal(node.multihash()) - done() + ipfs.object.put(buf, { enc: 'yaml' }, (err, node) => { + expect(err).to.not.exist + const nodeJSON = node.toJSON() + expect(obj.Data).to.deep.equal(nodeJSON.Data) + expect(obj.Links).to.deep.equal(nodeJSON.Links) + expect(nodeJSON.Hash).to.equal('QmPb5f92FxKPYdT3QNBd1GKiL4tZUXUrzF4Hkpdr3Gf1gK') + done() + }) }) - }) - it('object.put fails if String is passed', (done) => { - ipfs.object.put('aaa', (err) => { - expect(err).to.exist - done() + it('of buffer treated as Data field', (done) => { + const data = new Buffer('Some data') + ipfs.object.put(data, (err, node) => { + expect(err).to.not.exist + const nodeJSON = node.toJSON() + expect(data).to.deep.equal(nodeJSON.Data) + expect([]).to.deep.equal(nodeJSON.Links) + expect(nodeJSON.Hash).to.equal('QmPb5f92FxKPYdT3QNBd1GKiL4tZUXUrzF4Hkpdr3Gf1gK') + done() + }) }) - }) - it('object.put DAGNode with some DAGLinks', (done) => { - const dNode1 = new DAGNode(new Buffer('Some data 1')) - const dNode2 = new DAGNode(new Buffer('Some data 2')) - dNode1.addNodeLink('some-link', dNode2) + it('of DAGNode', (done) => { + const dNode = new DAGNode(new Buffer('Some data')) - ipfs.object.put(dNode1, (err, node) => { - expect(err).to.not.exist - expect(dNode1.data).to.deep.equal(node.data) - expect(dNode1.links).to.deep.equal(node.links) - expect(dNode1.multihash()).to.deep.equal(node.multihash()) - done() + ipfs.object.put(dNode, (err, node) => { + expect(err).to.not.exist + expect(dNode.data).to.deep.equal(node.data) + expect(dNode.links).to.deep.equal(node.links) + expect(dNode.multihash()).to.deep.equal(node.multihash()) + done() + }) }) - }) - it('object.get with multihash', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } + it('fails if String is passed', (done) => { + ipfs.object.put('aaa', (err) => { + expect(err).to.exist + done() + }) + }) - ipfs.object.put(testObj, (err, node1) => { - expect(err).to.not.exist + it('DAGNode with some DAGLinks', (done) => { + const dNode1 = new DAGNode(new Buffer('Some data 1')) + const dNode2 = new DAGNode(new Buffer('Some data 2')) + dNode1.addNodeLink('some-link', dNode2) - ipfs.object.get(node1.multihash(), (err, node2) => { + ipfs.object.put(dNode1, (err, node) => { expect(err).to.not.exist - // because js-ipfs-api can't infer if the returned Data is Buffer - // or String - if (typeof node2.data === 'string') { - node2.data = new Buffer(node2.data) - } - expect(node1.multihash()).to.deep.equal(node2.multihash()) - expect(node1.data).to.deep.equal(node2.data) - expect(node1.links).to.deep.equal(node2.links) + expect(dNode1.data).to.deep.equal(node.data) + expect(dNode1.links).to.deep.equal(node.links) + expect(dNode1.multihash()).to.deep.equal(node.multihash()) done() }) }) }) - it('object.get with multihash (+ links)', (done) => { - const dNode1 = new DAGNode(new Buffer('Some data 1')) - const dNode2 = new DAGNode(new Buffer('Some data 2')) - dNode1.addNodeLink('some-link', dNode2) - - ipfs.object.put(dNode1, (err, node1) => { - expect(err).to.not.exist + describe('.get', () => { + it('with multihash', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.get(node1.multihash(), (err, node2) => { + ipfs.object.put(testObj, (err, node1) => { expect(err).to.not.exist - // because js-ipfs-api can't infer if the returned Data is Buffer - // or String - if (typeof node2.data === 'string') { - node2.data = new Buffer(node2.data) - } - expect(node1.multihash()).to.deep.equal(node2.multihash()) - expect(node1.data).to.deep.equal(node2.data) - done() + + ipfs.object.get(node1.multihash(), (err, node2) => { + expect(err).to.not.exist + // because js-ipfs-api can't infer if the returned Data is Buffer + // or String + if (typeof node2.data === 'string') { + node2.data = new Buffer(node2.data) + } + expect(node1.multihash()).to.deep.equal(node2.multihash()) + expect(node1.data).to.deep.equal(node2.data) + expect(node1.links).to.deep.equal(node2.links) + done() + }) }) }) - }) - it('object.get with multihash base58 encoded', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } + it('with multihash (+ links)', (done) => { + const dNode1 = new DAGNode(new Buffer('Some data 1')) + const dNode2 = new DAGNode(new Buffer('Some data 2')) + dNode1.addNodeLink('some-link', dNode2) - ipfs.object.put(testObj, (err, node1) => { - expect(err).to.not.exist - - ipfs.object.get(bs58.encode(node1.multihash()), { enc: 'base58' }, (err, node2) => { + ipfs.object.put(dNode1, (err, node1) => { expect(err).to.not.exist - // because js-ipfs-api can't infer if the returned Data is Buffer - // or String - if (typeof node2.data === 'string') { - node2.data = new Buffer(node2.data) - } - expect(node1.multihash()).to.deep.equal(node2.multihash()) - expect(node1.data).to.deep.equal(node2.data) - expect(node1.links).to.deep.equal(node2.links) - done() + + ipfs.object.get(node1.multihash(), (err, node2) => { + expect(err).to.not.exist + // because js-ipfs-api can't infer if the returned Data is Buffer + // or String + if (typeof node2.data === 'string') { + node2.data = new Buffer(node2.data) + } + expect(node1.multihash()).to.deep.equal(node2.multihash()) + expect(node1.data).to.deep.equal(node2.data) + done() + }) }) }) - }) - - it('object.get with multihash base58 encoded toString', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } - ipfs.object.put(testObj, (err, node1) => { - expect(err).to.not.exist + it('with multihash base58 encoded', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.get(bs58.encode(node1.multihash()).toString(), { enc: 'base58' }, (err, node2) => { + ipfs.object.put(testObj, (err, node1) => { expect(err).to.not.exist - // because js-ipfs-api can't infer if the returned Data is Buffer - // or String - if (typeof node2.data === 'string') { - node2.data = new Buffer(node2.data) - } - expect(node1.multihash()).to.deep.equal(node2.multihash()) - expect(node1.data).to.deep.equal(node2.data) - expect(node1.links).to.deep.equal(node2.links) - done() + + ipfs.object.get(bs58.encode(node1.multihash()), { enc: 'base58' }, (err, node2) => { + expect(err).to.not.exist + // because js-ipfs-api can't infer if the returned Data is Buffer + // or String + if (typeof node2.data === 'string') { + node2.data = new Buffer(node2.data) + } + expect(node1.multihash()).to.deep.equal(node2.multihash()) + expect(node1.data).to.deep.equal(node2.data) + expect(node1.links).to.deep.equal(node2.links) + done() + }) }) }) - }) - it('object.data with multihash', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } - - ipfs.object.put(testObj, (err, node) => { - expect(err).to.not.exist + it('with multihash base58 encoded toString', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.data(node.multihash(), (err, data) => { + ipfs.object.put(testObj, (err, node1) => { expect(err).to.not.exist - // because js-ipfs-api can't infer - // if the returned Data is Buffer or String - if (typeof data === 'string') { - data = new Buffer(data) - } - expect(node.data).to.deep.equal(data) - done() + + ipfs.object.get(bs58.encode(node1.multihash()).toString(), { enc: 'base58' }, (err, node2) => { + expect(err).to.not.exist + // because js-ipfs-api can't infer if the returned Data is Buffer + // or String + if (typeof node2.data === 'string') { + node2.data = new Buffer(node2.data) + } + expect(node1.multihash()).to.deep.equal(node2.multihash()) + expect(node1.data).to.deep.equal(node2.data) + expect(node1.links).to.deep.equal(node2.links) + done() + }) }) }) }) - it('object.data with multihash base58 encoded', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } - - ipfs.object.put(testObj, (err, node) => { - expect(err).to.not.exist + describe('.data', () => { + it('with multihash', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.data(bs58.encode(node.multihash()), { enc: 'base58' }, (err, data) => { + ipfs.object.put(testObj, (err, node) => { expect(err).to.not.exist - // because js-ipfs-api can't infer - // if the returned Data is Buffer or String - if (typeof data === 'string') { - data = new Buffer(data) - } - expect(node.data).to.deep.equal(data) - done() + + ipfs.object.data(node.multihash(), (err, data) => { + expect(err).to.not.exist + // because js-ipfs-api can't infer + // if the returned Data is Buffer or String + if (typeof data === 'string') { + data = new Buffer(data) + } + expect(node.data).to.deep.equal(data) + done() + }) }) }) - }) - it('object.data with multihash base58 encoded toString', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } - - ipfs.object.put(testObj, (err, node) => { - expect(err).to.not.exist + it('with multihash base58 encoded', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.data(bs58.encode(node.multihash()).toString(), { enc: 'base58' }, (err, data) => { + ipfs.object.put(testObj, (err, node) => { expect(err).to.not.exist - // because js-ipfs-api can't infer if the returned Data is Buffer - // or String - if (typeof data === 'string') { - data = new Buffer(data) - } - expect(node.data).to.deep.equal(data) - done() + + ipfs.object.data(bs58.encode(node.multihash()), { enc: 'base58' }, (err, data) => { + expect(err).to.not.exist + // because js-ipfs-api can't infer + // if the returned Data is Buffer or String + if (typeof data === 'string') { + data = new Buffer(data) + } + expect(node.data).to.deep.equal(data) + done() + }) }) }) - }) - - it('object.links with multihash', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } - ipfs.object.put(testObj, (err, node) => { - expect(err).to.not.exist + it('with multihash base58 encoded toString', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.links(node.multihash(), (err, links) => { + ipfs.object.put(testObj, (err, node) => { expect(err).to.not.exist - expect(node.links).to.deep.equal(links) - done() + + ipfs.object.data(bs58.encode(node.multihash()).toString(), { enc: 'base58' }, (err, data) => { + expect(err).to.not.exist + // because js-ipfs-api can't infer if the returned Data is Buffer + // or String + if (typeof data === 'string') { + data = new Buffer(data) + } + expect(node.data).to.deep.equal(data) + done() + }) }) }) }) - it('object.links with multihash (+ links)', (done) => { - const dNode1 = new DAGNode(new Buffer('Some data 1')) - const dNode2 = new DAGNode(new Buffer('Some data 2')) - dNode1.addNodeLink('some-link', dNode2) - - ipfs.object.put(dNode1, (err, node) => { - expect(err).to.not.exist + describe('.links', () => { + it('object.links with multihash', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.links(node.multihash(), (err, links) => { + ipfs.object.put(testObj, (err, node) => { expect(err).to.not.exist - expect(node.links[0].toJSON()).to.deep.equal(links[0].toJSON()) - done() + + ipfs.object.links(node.multihash(), (err, links) => { + expect(err).to.not.exist + expect(node.links).to.deep.equal(links) + done() + }) }) }) - }) - it('object.links with multihash base58 encoded', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } - - ipfs.object.put(testObj, (err, node) => { - expect(err).to.not.exist + it('with multihash (+ links)', (done) => { + const dNode1 = new DAGNode(new Buffer('Some data 1')) + const dNode2 = new DAGNode(new Buffer('Some data 2')) + dNode1.addNodeLink('some-link', dNode2) - ipfs.object.links(bs58.encode(node.multihash()), { enc: 'base58' }, (err, links) => { + ipfs.object.put(dNode1, (err, node) => { expect(err).to.not.exist - expect(node.links).to.deep.equal(links) - done() + + ipfs.object.links(node.multihash(), (err, links) => { + expect(err).to.not.exist + expect(node.links[0].toJSON()).to.deep.equal(links[0].toJSON()) + done() + }) }) }) - }) - - it('object.links with multihash base58 encoded toString', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } - ipfs.object.put(testObj, (err, node) => { - expect(err).to.not.exist + it('with multihash base58 encoded', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.links(bs58.encode(node.multihash()).toString(), { enc: 'base58' }, (err, links) => { + ipfs.object.put(testObj, (err, node) => { expect(err).to.not.exist - expect(node.links).to.deep.equal(links) - done() + + ipfs.object.links(bs58.encode(node.multihash()), { enc: 'base58' }, (err, links) => { + expect(err).to.not.exist + expect(node.links).to.deep.equal(links) + done() + }) }) }) - }) - it('object.stat with multihash', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } - - ipfs.object.put(testObj, (err, node) => { - expect(err).to.not.exist + it('with multihash base58 encoded toString', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.stat(node.multihash(), (err, stats) => { + ipfs.object.put(testObj, (err, node) => { expect(err).to.not.exist - const expected = { - Hash: 'QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', - NumLinks: 0, - BlockSize: 17, - LinksSize: 2, - DataSize: 15, - CumulativeSize: 17 - } - expect(expected).to.deep.equal(stats) - done() + + ipfs.object.links(bs58.encode(node.multihash()).toString(), { enc: 'base58' }, (err, links) => { + expect(err).to.not.exist + expect(node.links).to.deep.equal(links) + done() + }) }) }) }) - it('object.stat with multihash (+ Links)', (done) => { - const dNode1 = new DAGNode(new Buffer('Some data 1')) - const dNode2 = new DAGNode(new Buffer('Some data 2')) - dNode1.addNodeLink('some-link', dNode2) - - ipfs.object.put(dNode1, (err, node) => { - expect(err).to.not.exist + describe('.stat', () => { + it('with multihash', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.stat(node.multihash(), (err, stats) => { + ipfs.object.put(testObj, (err, node) => { expect(err).to.not.exist - const expected = { - Hash: 'QmPR7W4kaADkAo4GKEVVPQN81EDUFCHJtqejQZ5dEG7pBC', - NumLinks: 1, - BlockSize: 64, - LinksSize: 53, - DataSize: 11, - CumulativeSize: 77 - } - expect(expected).to.deep.equal(stats) - done() + + ipfs.object.stat(node.multihash(), (err, stats) => { + expect(err).to.not.exist + const expected = { + Hash: 'QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', + NumLinks: 0, + BlockSize: 17, + LinksSize: 2, + DataSize: 15, + CumulativeSize: 17 + } + expect(expected).to.deep.equal(stats) + done() + }) }) }) - }) - it('object.stat with multihash base58 encoded', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } + it('with multihash (+ Links)', (done) => { + const dNode1 = new DAGNode(new Buffer('Some data 1')) + const dNode2 = new DAGNode(new Buffer('Some data 2')) + dNode1.addNodeLink('some-link', dNode2) - ipfs.object.put(testObj, (err, node) => { - expect(err).to.not.exist - - ipfs.object.stat(bs58.encode(node.multihash()), { enc: 'base58' }, (err, stats) => { + ipfs.object.put(dNode1, (err, node) => { expect(err).to.not.exist - const expected = { - Hash: 'QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', - NumLinks: 0, - BlockSize: 17, - LinksSize: 2, - DataSize: 15, - CumulativeSize: 17 - } - expect(expected).to.deep.equal(stats) - done() + + ipfs.object.stat(node.multihash(), (err, stats) => { + expect(err).to.not.exist + const expected = { + Hash: 'QmPR7W4kaADkAo4GKEVVPQN81EDUFCHJtqejQZ5dEG7pBC', + NumLinks: 1, + BlockSize: 64, + LinksSize: 53, + DataSize: 11, + CumulativeSize: 77 + } + expect(expected).to.deep.equal(stats) + done() + }) }) }) - }) - it('object.stat with multihash base58 encoded toString', (done) => { - const testObj = { - Data: new Buffer('get test object'), - Links: [] - } + it('with multihash base58 encoded', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.put(testObj, (err, node) => { - expect(err).to.not.exist + ipfs.object.put(testObj, (err, node) => { + expect(err).to.not.exist + + ipfs.object.stat(bs58.encode(node.multihash()), { enc: 'base58' }, (err, stats) => { + expect(err).to.not.exist + const expected = { + Hash: 'QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', + NumLinks: 0, + BlockSize: 17, + LinksSize: 2, + DataSize: 15, + CumulativeSize: 17 + } + expect(expected).to.deep.equal(stats) + done() + }) + }) + }) + + it('with multihash base58 encoded toString', (done) => { + const testObj = { + Data: new Buffer('get test object'), + Links: [] + } - ipfs.object.stat(bs58.encode(node.multihash()).toString(), { enc: 'base58' }, (err, stats) => { + ipfs.object.put(testObj, (err, node) => { expect(err).to.not.exist - const expected = { - Hash: 'QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', - NumLinks: 0, - BlockSize: 17, - LinksSize: 2, - DataSize: 15, - CumulativeSize: 17 - } - expect(expected).to.deep.equal(stats) - done() + + ipfs.object.stat(bs58.encode(node.multihash()).toString(), { enc: 'base58' }, (err, stats) => { + expect(err).to.not.exist + const expected = { + Hash: 'QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', + NumLinks: 0, + BlockSize: 17, + LinksSize: 2, + DataSize: 15, + CumulativeSize: 17 + } + expect(expected).to.deep.equal(stats) + done() + }) }) }) }) - describe('object.patch', () => { + describe('.patch', () => { let testNode let testNodeWithLink let testLink @@ -579,9 +590,9 @@ module.exports = (common) => { expect(node1.links).to.deep.equal(node2.links) done() }) - .catch((err) => { - expect(err).to.not.exist - }) + .catch((err) => { + expect(err).to.not.exist + }) }) }) @@ -632,9 +643,9 @@ module.exports = (common) => { done() }) }) - .catch((err) => { - expect(err).to.not.exist - }) + .catch((err) => { + expect(err).to.not.exist + }) }) it('object.links', (done) => { @@ -647,13 +658,13 @@ module.exports = (common) => { expect(err).to.not.exist ipfs.object.links(node.multihash()) - .then((links) => { - expect(node.links).to.deep.equal(links) - done() - }) - .catch((err) => { - expect(err).to.not.exist - }) + .then((links) => { + expect(node.links).to.deep.equal(links) + done() + }) + .catch((err) => { + expect(err).to.not.exist + }) }) }) @@ -725,9 +736,9 @@ module.exports = (common) => { expect(node.multihash()).to.not.deep.equal(testNode.multihash()) done() }) - .catch((err) => { - expect(err).to.not.exist - }) + .catch((err) => { + expect(err).to.not.exist + }) }) }) })