This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree 1 file changed +43
-1
lines changed 1 file changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -82,8 +82,50 @@ describe('ipfs node api', function () {
82
82
}
83
83
} )
84
84
85
- it ( 'connect Node a to b and c' , function ( ) {
85
+ it ( 'connect Node a to b and c' , function ( done ) {
86
+ var addrs = { }
87
+ var counter = 0
88
+ collectAddr ( 'b' , finish )
89
+ collectAddr ( 'c' , finish )
90
+
91
+ function finish ( ) {
92
+ counter ++
93
+ if ( counter === 2 ) {
94
+ dial ( )
95
+ }
96
+ }
97
+
98
+ function collectAddr ( key , cb ) {
99
+ apiClients [ key ] . id ( function ( err , id ) {
100
+ if ( err ) {
101
+ throw err
102
+ }
103
+ addrs [ key ] = ipfsNodes [ key ] . apiAddr + '/ipfs/' + id . ID
104
+ cb ( )
105
+ } )
106
+ }
86
107
108
+ function dial ( ) {
109
+ apiClients [ 'a' ] . swarm . connect ( addrs [ 'b' ] , function ( err ) {
110
+ if ( err ) {
111
+ throw err
112
+ }
113
+ apiClients [ 'a' ] . swarm . connect ( addrs [ 'c' ] , function ( err ) {
114
+ if ( err ) {
115
+ throw err
116
+ }
117
+ done ( )
118
+ } )
119
+ } )
120
+ }
121
+ // apiClients['a'].id(function (err, id) {
122
+ // if (err) {
123
+ // throw err
124
+ // }
125
+ // console.log(id)
126
+ // })
127
+ // console.log(ipfsNodes['a'].apiAddr)
128
+ // localDaemon.swarm.connect(CUBE_NODE, function (err) {})
87
129
} )
88
130
89
131
it ( 'has the api object' , function ( ) {
You can’t perform that action at this time.
0 commit comments