44const isIpfs = require ( 'is-ipfs' )
55const loadFixture = require ( 'aegir/fixtures' )
66const hat = require ( 'hat' )
7+ const waterfall = require ( 'async/waterfall' )
8+ const { spawnNodeWithId } = require ( '../utils/spawn' )
9+ const { connect } = require ( '../utils/swarm' )
710const { getDescribe, getIt, expect } = require ( '../utils/mocha' )
811
912module . 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