4
4
const isIpfs = require ( 'is-ipfs' )
5
5
const loadFixture = require ( 'aegir/fixtures' )
6
6
const hat = require ( 'hat' )
7
+ const waterfall = require ( 'async/waterfall' )
8
+ const { spawnNodeWithId } = require ( '../utils/spawn' )
9
+ const { connect } = require ( '../utils/swarm' )
7
10
const { getDescribe, getIt, expect } = require ( '../utils/mocha' )
8
11
9
12
module . exports = ( createCommon , options ) => {
@@ -12,15 +15,16 @@ module.exports = (createCommon, options) => {
12
15
const common = createCommon ( )
13
16
14
17
describe ( '.resolve' , ( ) => {
15
- let ipfs
18
+ let factory , ipfs
16
19
17
20
before ( function ( done ) {
18
21
// CI takes longer to instantiate the daemon, so we need to increase the
19
22
// timeout for the before step
20
23
this . timeout ( 60 * 1000 )
21
24
22
- common . setup ( ( err , factory ) => {
25
+ common . setup ( ( err , f ) => {
23
26
expect ( err ) . to . not . exist ( )
27
+ factory = f
24
28
factory . spawnNode ( ( err , node ) => {
25
29
expect ( err ) . to . not . exist ( )
26
30
ipfs = node
@@ -97,18 +101,25 @@ module.exports = (createCommon, options) => {
97
101
98
102
// Test resolve turns /ipns/QmPeerHash into /ipns/domain.com into /ipfs/QmHash
99
103
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 )
112
123
} )
113
124
} )
114
125
}
0 commit comments