From 03dcab94cf98fe9dad1dad82f3a30ece50bf23ec Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Thu, 18 Apr 2019 16:53:49 +0100 Subject: [PATCH] feat: add support to ipns resolve /ipns/ fixes: #1918 --- package.json | 1 + test/core/name.spec.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/package.json b/package.json index ad8413336d..d156c7ae1c 100644 --- a/package.json +++ b/package.json @@ -113,6 +113,7 @@ "ipns": "~0.5.2", "is-domain-name": "^1.0.1", "is-ipfs": "~0.6.1", + "is-domain-name": "^1.0.1", "is-pull-stream": "~0.0.0", "is-stream": "^2.0.0", "iso-url": "~0.4.6", diff --git a/test/core/name.spec.js b/test/core/name.spec.js index 1191eba711..9cdb4309dd 100644 --- a/test/core/name.spec.js +++ b/test/core/name.spec.js @@ -500,4 +500,43 @@ 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() + } + }) + }) })