diff --git a/packages/ipfs/src/core/ipns/resolver.js b/packages/ipfs/src/core/ipns/resolver.js index 96eaae99e9..e17fb46999 100644 --- a/packages/ipfs/src/core/ipns/resolver.js +++ b/packages/ipfs/src/core/ipns/resolver.js @@ -1,7 +1,6 @@ 'use strict' const ipns = require('ipns') -const crypto = require('libp2p-crypto') const PeerId = require('peer-id') const errcode = require('err-code') const debug = require('debug') diff --git a/packages/ipfs/test/core/name-pubsub.js b/packages/ipfs/test/core/name-pubsub.js index 02fddc716c..a663f7f34c 100644 --- a/packages/ipfs/test/core/name-pubsub.js +++ b/packages/ipfs/test/core/name-pubsub.js @@ -2,7 +2,6 @@ /* eslint-env mocha */ 'use strict' -const { nanoid } = require('nanoid') const { Buffer } = require('buffer') const { expect } = require('interface-ipfs-core/src/utils/mocha') const base64url = require('base64url') diff --git a/packages/ipfs/test/core/name.spec.js b/packages/ipfs/test/core/name.spec.js index 993fd868ba..d7ddb36dfc 100644 --- a/packages/ipfs/test/core/name.spec.js +++ b/packages/ipfs/test/core/name.spec.js @@ -9,6 +9,7 @@ const { Key } = require('interface-datastore') const last = require('it-last') const PeerId = require('peer-id') const errCode = require('err-code') +const ipns = require('ipns') const getIpnsRoutingConfig = require('../../src/core/ipns/routing/config') const IpnsPublisher = require('../../src/core/ipns/publisher') const IpnsRepublisher = require('../../src/core/ipns/republisher') @@ -199,6 +200,20 @@ describe('name', function () { }) describe('resolver', () => { + it('should resolve an inlined public key', async () => { + const peerId = await PeerId.create({ keyType: 'ed25519' }) + const value = `/ipfs/${peerId.toB58String()}` + const record = await ipns.create(peerId.privKey, value, 1, 10e3) + + const routing = { + get: sinon.stub().returns(ipns.marshal(record)) + } + const resolver = new IpnsResolver(routing) + + const resolved = await resolver.resolve(`/ipns/${peerId.toB58String()}`) + expect(resolved).to.equal(value) + }) + it('should fail to resolve if the received name is not a string', () => { const resolver = new IpnsResolver() return expect(resolver.resolve(false))