Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit d9722a5

Browse files
author
Alan Shaw
committed
fix: resolve test and add resolve across multiple test
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
1 parent 7c3f8cf commit d9722a5

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/miscellaneous/resolve.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,34 @@ module.exports = (createCommon, options) => {
9595
ipfs.dag.put(content, options, (err, cid) => {
9696
expect(err).to.not.exist()
9797

98-
const path = `/ipld/${cid.toBaseEncodedString()}/path/to/file`
98+
const path = `/ipfs/${cid}/path/to/file`
9999
ipfs.resolve(path, (err, resolved) => {
100100
expect(err).to.not.exist()
101-
expect(resolved).to.be(path)
101+
expect(resolved).to.equal(path)
102+
done()
103+
})
104+
})
105+
})
106+
107+
it('should resolve up to the last node across multiple nodes', (done) => {
108+
const options = { format: 'dag-cbor', hashAlg: 'sha2-256' }
109+
110+
waterfall([
111+
cb => {
112+
const content = { node: { with: { file: hat() } } }
113+
ipfs.dag.put(content, options, cb)
114+
},
115+
(childCid, cb) => {
116+
const content = { path: { to: childCid } }
117+
ipfs.dag.put(content, options, (err, parentCid) => cb(err, { childCid, parentCid }))
118+
}
119+
], (err, res) => {
120+
expect(err).to.not.exist()
121+
122+
const path = `/ipfs/${res.parentCid}/path/to/node/with/file`
123+
ipfs.resolve(path, (err, resolved) => {
124+
expect(err).to.not.exist()
125+
expect(resolved).to.equal(`/ipfs/${res.childCid}/node/with/file`)
102126
done()
103127
})
104128
})

0 commit comments

Comments
 (0)