Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: moves tests to interface-core and removes path from output
Browse files Browse the repository at this point in the history
`ipns name resolve` dns tests moved to interface-core
resolve call now return a string as per documention
  • Loading branch information
hugomrdias committed Apr 22, 2019
1 parent 35f577a commit 314c70a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 50 deletions.
8 changes: 2 additions & 6 deletions src/core/ipns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ class IPNS {
const result = this.cache.get(id)

if (result) {
return callback(null, {
path: result
})
return callback(null, result)
}
}

Expand All @@ -91,9 +89,7 @@ class IPNS {

log(`IPNS record from ${name} was resolved correctly`)

callback(null, {
path: result
})
callback(null, result)
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/http/api/resources/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports.resolve = {
const res = await ipfs.name.resolve(arg, request.query)

return h.response({
Path: res.path
Path: res
})
}
}
Expand Down
47 changes: 4 additions & 43 deletions test/core/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const publishAndResolve = (publisher, resolver, ipfsRef, publishOpts, nodeId, re
expect(err).to.not.exist()
expect(res[0]).to.exist()
expect(res[1]).to.exist()
expect(res[1].path).to.equal(ipfsRef)
expect(res[1]).to.equal(ipfsRef)
callback()
})
}
Expand Down Expand Up @@ -117,7 +117,7 @@ describe('name', function () {
], (err, res) => {
expect(err).to.not.exist()
expect(res[2]).to.exist()
expect(res[2].path).to.equal(ipfsRef)
expect(res[2]).to.equal(ipfsRef)
done()
})
})
Expand All @@ -136,7 +136,7 @@ describe('name', function () {
], (err, res) => {
expect(err).to.not.exist()
expect(res[2]).to.exist()
expect(res[2].path).to.equal(`/ipns/${nodeId}`)
expect(res[2]).to.equal(`/ipns/${nodeId}`)
done()
})
})
Expand Down Expand Up @@ -277,7 +277,7 @@ describe('name', function () {
], (err, res) => {
expect(err).to.not.exist()
expect(res[2]).to.exist()
expect(res[2].path).to.equal(ipfsRef)
expect(res[2]).to.equal(ipfsRef)
done()
})
})
Expand Down Expand Up @@ -618,43 +618,4 @@ describe('name', function () {
done()
})
})

describe('working with dns', function () {
let node
let ipfsd

before(function (done) {
df.spawn({
exec: IPFS,
args: [`--pass ${hat()}`, '--offline'],
config: { Bootstrap: [] }
}, (err, _ipfsd) => {
expect(err).to.not.exist()
ipfsd = _ipfsd
node = _ipfsd.api
done()
})
})

after((done) => ipfsd.stop(done))

it('should resolve ipfs.io', async () => {
const r = await node.name.resolve('ipfs.io', { recursive: false })
return expect(r).to.eq('/ipns/website.ipfs.io')
})

it('should resolve /ipns/ipfs.io recursive', async () => {
const r = await node.name.resolve('ipfs.io', { recursive: true })

return expect(r.substr(0, 6)).to.eql('/ipfs/')
})

it('should fail to resolve /ipns/ipfs.a', async () => {
try {
await node.name.resolve('ipfs.a')
} catch (err) {
expect(err).to.exist()
}
})
})
})

0 comments on commit 314c70a

Please sign in to comment.