|
4 | 4 | const expect = require('chai').expect
|
5 | 5 | const DAGNode = require('ipfs-merkle-dag').DAGNode
|
6 | 6 | const bs58 = require('bs58')
|
7 |
| -const jsonToYaml = require('json2yaml') |
8 | 7 |
|
9 | 8 | module.exports = (common) => {
|
10 | 9 | describe('.object', () => {
|
@@ -79,21 +78,15 @@ module.exports = (common) => {
|
79 | 78 | })
|
80 | 79 | })
|
81 | 80 |
|
82 |
| - // TODO verify that yaml encoded buffers still work in go-ipfs |
83 |
| - it.skip('of yaml encoded buffer', (done) => { |
84 |
| - const obj = { |
85 |
| - Data: new Buffer('Some data').toString(), |
86 |
| - Links: [] |
87 |
| - } |
88 |
| - |
89 |
| - const buf = new Buffer(jsonToYaml.stringify(obj)) |
| 81 | + it('of protobuf encoded buffer', (done) => { |
| 82 | + const dNode = new DAGNode(new Buffer('Some data')) |
| 83 | + const buf = dNode.marshal() |
90 | 84 |
|
91 |
| - ipfs.object.put(buf, { enc: 'yaml' }, (err, node) => { |
| 85 | + ipfs.object.put(buf, { enc: 'protobuf' }, (err, node) => { |
92 | 86 | expect(err).to.not.exist
|
93 |
| - const nodeJSON = node.toJSON() |
94 |
| - expect(obj.Data).to.deep.equal(nodeJSON.Data) |
95 |
| - expect(obj.Links).to.deep.equal(nodeJSON.Links) |
96 |
| - expect(nodeJSON.Hash).to.equal('QmPb5f92FxKPYdT3QNBd1GKiL4tZUXUrzF4Hkpdr3Gf1gK') |
| 87 | + expect(dNode.data).to.deep.equal(node.data) |
| 88 | + expect(dNode.links).to.deep.equal(node.links) |
| 89 | + expect(dNode.multihash()).to.deep.equal(node.multihash()) |
97 | 90 | done()
|
98 | 91 | })
|
99 | 92 | })
|
@@ -137,7 +130,11 @@ module.exports = (common) => {
|
137 | 130 | ipfs.object.put(dNode1, (err, node) => {
|
138 | 131 | expect(err).to.not.exist
|
139 | 132 | expect(dNode1.data).to.deep.equal(node.data)
|
140 |
| - expect(dNode1.links).to.deep.equal(node.links) |
| 133 | + expect( |
| 134 | + dNode1.links.map((l) => l.toJSON()) |
| 135 | + ).to.deep.equal( |
| 136 | + node.links.map((l) => l.toJSON()) |
| 137 | + ) |
141 | 138 | expect(dNode1.multihash()).to.deep.equal(node.multihash())
|
142 | 139 | done()
|
143 | 140 | })
|
|
0 commit comments