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

Commit

Permalink
fix: resolve IPNS recursively test (#507)
Browse files Browse the repository at this point in the history
name.publish needs at least one other node to publish to.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
  • Loading branch information
Alan Shaw authored Jul 26, 2019
1 parent 2893423 commit 1db8abe
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/miscellaneous/resolve.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 5] */
'use strict'

const isIpfs = require('is-ipfs')
const loadFixture = require('aegir/fixtures')
const hat = require('hat')
const multibase = require('multibase')
const { spawnNodeWithId } = require('../utils/spawn')
const { connect } = require('../utils/swarm')
const { getDescribe, getIt, expect } = require('../utils/mocha')

module.exports = (createCommon, options) => {
Expand Down Expand Up @@ -88,11 +90,23 @@ module.exports = (createCommon, options) => {
it('should resolve IPNS link recursively', async function () {
this.timeout(20 * 1000)

// Ensure another node exists for publishing to
await new Promise((resolve, reject) => {
common.setup((err, factory) => {
if (err) return reject(err)
spawnNodeWithId(factory, (err, node) => {
if (err) return reject(err)
const addr = node.peerId.addresses.find((a) => a.includes('127.0.0.1'))
connect(ipfs, addr, resolve)
})
})
})

const [{ path }] = await ipfs.add(Buffer.from('should resolve a record recursive === true'))
const { id: keyId } = await ipfs.key.gen('key-name', { type: 'rsa', size: 2048 })

await ipfs.name.publish(path, { 'allow-offline': true })
await ipfs.name.publish(`/ipns/${nodeId}`, { 'allow-offline': true, key: 'key-name' })
await ipfs.name.publish(`/ipns/${nodeId}`, { 'allow-offline': true, key: 'key-name', resolve: false })

return expect(await ipfs.resolve(`/ipns/${keyId}`, { recursive: true }))
.to.eq(`/ipfs/${path}`)
Expand Down

0 comments on commit 1db8abe

Please sign in to comment.