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

Commit

Permalink
test: check inlined pubkey support
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobheun committed Aug 13, 2020
1 parent 71949a2 commit 5e33b53
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/ipfs/src/core/ipns/resolver.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
1 change: 0 additions & 1 deletion packages/ipfs/test/core/name-pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
15 changes: 15 additions & 0 deletions packages/ipfs/test/core/name.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 5e33b53

Please sign in to comment.