|
1 | 1 | /* eslint-env mocha */ |
| 2 | +/* eslint max-nested-callbacks: ["error", 5] */ |
2 | 3 | 'use strict' |
3 | 4 |
|
4 | 5 | const isIpfs = require('is-ipfs') |
5 | 6 | const loadFixture = require('aegir/fixtures') |
6 | 7 | const hat = require('hat') |
7 | 8 | const multibase = require('multibase') |
8 | 9 | const { spawnNodeWithId } = require('../utils/spawn') |
| 10 | +const { connect } = require('../utils/swarm') |
9 | 11 | const { getDescribe, getIt, expect } = require('../utils/mocha') |
10 | 12 |
|
11 | 13 | module.exports = (createCommon, options) => { |
@@ -88,11 +90,23 @@ module.exports = (createCommon, options) => { |
88 | 90 | it('should resolve IPNS link recursively', async function () { |
89 | 91 | this.timeout(20 * 1000) |
90 | 92 |
|
| 93 | + // Ensure another node exists for publishing to |
| 94 | + await new Promise((resolve, reject) => { |
| 95 | + common.setup((err, factory) => { |
| 96 | + if (err) return reject(err) |
| 97 | + spawnNodeWithId(factory, (err, node) => { |
| 98 | + if (err) return reject(err) |
| 99 | + const addr = node.peerId.addresses.find((a) => a.includes('127.0.0.1')) |
| 100 | + connect(ipfs, addr, resolve) |
| 101 | + }) |
| 102 | + }) |
| 103 | + }) |
| 104 | + |
91 | 105 | const [{ path }] = await ipfs.add(Buffer.from('should resolve a record recursive === true')) |
92 | 106 | const { id: keyId } = await ipfs.key.gen('key-name', { type: 'rsa', size: 2048 }) |
93 | 107 |
|
94 | 108 | await ipfs.name.publish(path, { 'allow-offline': true }) |
95 | | - await ipfs.name.publish(`/ipns/${nodeId}`, { 'allow-offline': true, key: 'key-name' }) |
| 109 | + await ipfs.name.publish(`/ipns/${nodeId}`, { 'allow-offline': true, key: 'key-name', resolve: false }) |
96 | 110 |
|
97 | 111 | return expect(await ipfs.resolve(`/ipns/${keyId}`, { recursive: true })) |
98 | 112 | .to.eq(`/ipfs/${path}`) |
|
0 commit comments