@@ -14,6 +14,7 @@ module.exports = (common) => {
14
14
let ipfsA
15
15
let ipfsB
16
16
let withGo
17
+ let ipfsBId
17
18
const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR'
18
19
19
20
before ( function ( done ) {
@@ -29,18 +30,18 @@ module.exports = (common) => {
29
30
ipfsA = node
30
31
withGo = node . peerId . agentVersion . startsWith ( 'go-ipfs' )
31
32
cb ( )
32
- //ipfsA.block.get(key)
33
- //.then(() => {})
34
- //.catch(() => {})
35
- //cb()
36
33
} ) ,
37
34
( cb ) => spawn . spawnNodeWithId ( factory , ( err , node ) => {
38
35
expect ( err ) . to . not . exist ( )
39
36
ipfsB = node
37
+ ipfsBId = node . peerId
40
38
ipfsB . block . get ( new CID ( key ) )
41
39
. then ( ( ) => { } )
42
40
. catch ( ( ) => { } )
43
- ipfsA . swarm . connect ( node . peerId . addresses [ 0 ] , cb )
41
+ ipfsA . swarm . connect ( ipfsBId . addresses [ 0 ] , ( err ) => {
42
+ expect ( err ) . to . not . exist ( )
43
+ setTimeout ( cb , 350 )
44
+ } )
44
45
} )
45
46
] , done )
46
47
} )
@@ -49,15 +50,15 @@ module.exports = (common) => {
49
50
after ( ( done ) => common . teardown ( done ) )
50
51
51
52
it ( '.stat' , ( done ) => {
52
- ipfsA . bitswap . stat ( ( err , stats ) => {
53
+ ipfsB . bitswap . stat ( ( err , stats ) => {
53
54
expect ( err ) . to . not . exist ( )
54
55
statsTests . expectIsBitswap ( err , stats )
55
56
done ( )
56
57
} )
57
58
} )
58
59
59
60
it ( '.wantlist' , ( done ) => {
60
- ipfsA . bitswap . wantlist ( ( err , list ) => {
61
+ ipfsB . bitswap . wantlist ( ( err , list ) => {
61
62
expect ( err ) . to . not . exist ( )
62
63
expect ( list . Keys ) . to . have . length ( 1 ) ;
63
64
expect ( list . Keys [ 0 ] [ '/' ] ) . to . equal ( key )
@@ -66,7 +67,7 @@ module.exports = (common) => {
66
67
} )
67
68
68
69
it ( '.wantlist peerid' , ( done ) => {
69
- ipfsA . bitswap . wantlist ( ipfsBId , ( err , list ) => {
70
+ ipfsA . bitswap . wantlist ( ipfsBId . id , ( err , list ) => {
70
71
expect ( err ) . to . not . exist ( )
71
72
expect ( list . Keys [ 0 ] [ '/' ] ) . to . equal ( key )
72
73
done ( )
@@ -77,9 +78,9 @@ module.exports = (common) => {
77
78
if ( withGo ) {
78
79
this . skip ( )
79
80
}
80
- ipfsA . bitswap . unwant ( key , ( err ) => {
81
+ ipfsB . bitswap . unwant ( key , ( err ) => {
81
82
expect ( err ) . to . not . exist ( ) ;
82
- ipfsA . bitswap . wantlist ( ( err , list ) => {
83
+ ipfsB . bitswap . wantlist ( ( err , list ) => {
83
84
expect ( err ) . to . not . exist ( ) ;
84
85
expect ( list . Keys ) . to . be . empty ( )
85
86
done ( )
@@ -115,7 +116,7 @@ module.exports = (common) => {
115
116
} )
116
117
} )
117
118
118
- it ( '.stat gives error while offline' , ( ) => {
119
+ it ( '.stat gives error while offline' , ( done ) => {
119
120
ipfs . bitswap . stat ( ( err , stats ) => {
120
121
expect ( err ) . to . exist ( )
121
122
//When run against core we get our expected error, when run
@@ -124,10 +125,11 @@ module.exports = (common) => {
124
125
expect ( err ) . to . match ( / o n l i n e m o d e / )
125
126
}
126
127
expect ( stats ) . to . not . exist ( )
128
+ done ( )
127
129
} )
128
130
} )
129
131
130
- it ( '.wantlist gives error if offline' , ( ) => {
132
+ it ( '.wantlist gives error if offline' , ( done ) => {
131
133
ipfs . bitswap . wantlist ( ( err , list ) => {
132
134
expect ( err ) . to . exist ( )
133
135
//When run against core we get our expected error, when run
@@ -136,18 +138,21 @@ module.exports = (common) => {
136
138
expect ( err ) . to . match ( / o n l i n e m o d e / )
137
139
}
138
140
expect ( list ) . to . not . exist ( )
141
+ done ( )
139
142
} )
140
143
} )
141
144
142
- it ( '.unwant gives error if offline' , ( ) => {
143
- expect ( ( ) => ipfs . bitswap . unwant ( key , ( err ) => {
145
+ it ( '.unwant gives error if offline' , ( done ) => {
146
+ const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR'
147
+ ipfs . bitswap . unwant ( key , ( err ) => {
144
148
expect ( err ) . to . exist ( )
145
149
//When run against core we get our expected error, when run
146
150
//as part of the http tests we get a connection refused
147
151
if ( err . code !== 'ECONNREFUSED' ) {
148
152
expect ( err ) . to . match ( / o n l i n e m o d e / )
149
153
}
150
- } ) )
154
+ done ( )
155
+ } )
151
156
} )
152
157
} )
153
158
}
0 commit comments