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

Commit 09c2637

Browse files
authoredAug 6, 2018
fix: ensure test for resolve recursive has another node (#346)
fix: ensure test for resolve recursive has another node
1 parent e02d39f commit 09c2637

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed
 

‎js/src/miscellaneous/resolve.js

+25-14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
const isIpfs = require('is-ipfs')
55
const loadFixture = require('aegir/fixtures')
66
const hat = require('hat')
7+
const waterfall = require('async/waterfall')
8+
const { spawnNodeWithId } = require('../utils/spawn')
9+
const { connect } = require('../utils/swarm')
710
const { getDescribe, getIt, expect } = require('../utils/mocha')
811

912
module.exports = (createCommon, options) => {
@@ -12,15 +15,16 @@ module.exports = (createCommon, options) => {
1215
const common = createCommon()
1316

1417
describe('.resolve', () => {
15-
let ipfs
18+
let factory, ipfs
1619

1720
before(function (done) {
1821
// CI takes longer to instantiate the daemon, so we need to increase the
1922
// timeout for the before step
2023
this.timeout(60 * 1000)
2124

22-
common.setup((err, factory) => {
25+
common.setup((err, f) => {
2326
expect(err).to.not.exist()
27+
factory = f
2428
factory.spawnNode((err, node) => {
2529
expect(err).to.not.exist()
2630
ipfs = node
@@ -97,18 +101,25 @@ module.exports = (createCommon, options) => {
97101

98102
// Test resolve turns /ipns/QmPeerHash into /ipns/domain.com into /ipfs/QmHash
99103
it('should resolve IPNS link recursively', function (done) {
100-
this.timeout(4 * 60 * 1000)
101-
102-
ipfs.name.publish('/ipns/ipfs.io', { resolve: false }, (err, res) => {
103-
expect(err).to.not.exist()
104-
105-
ipfs.resolve(`/ipns/${res.name}`, { recursive: true }, (err, res) => {
106-
expect(err).to.not.exist()
107-
expect(res).to.not.equal('/ipns/ipfs.io')
108-
expect(isIpfs.ipfsPath(res)).to.be.true()
109-
done()
110-
})
111-
})
104+
this.timeout(5 * 60 * 1000)
105+
106+
waterfall([
107+
// Ensure node has another node to publish a name to
108+
(cb) => spawnNodeWithId(factory, cb),
109+
(ipfsB, cb) => {
110+
const addr = ipfsB.peerId.addresses.find((a) => a.includes('127.0.0.1'))
111+
connect(ipfs, addr, cb)
112+
},
113+
(cb) => ipfs.name.publish('/ipns/ipfs.io', { resolve: false }, cb),
114+
(res, cb) => {
115+
ipfs.resolve(`/ipns/${res.name}`, { recursive: true }, (err, res) => {
116+
expect(err).to.not.exist()
117+
expect(res).to.not.equal('/ipns/ipfs.io')
118+
expect(isIpfs.ipfsPath(res)).to.be.true()
119+
cb()
120+
})
121+
}
122+
], done)
112123
})
113124
})
114125
}

0 commit comments

Comments
 (0)
This repository has been archived.