@@ -14,6 +14,7 @@ module.exports = (common) => {
14
14
describe ( '.dht' , function ( ) {
15
15
this . timeout ( 80 * 1000 )
16
16
17
+ let withGo
17
18
let nodeA
18
19
let nodeB
19
20
let nodeC
@@ -47,7 +48,12 @@ module.exports = (common) => {
47
48
( cb ) => nodeE . swarm . connect ( nodeB . peerId . addresses [ 0 ] , cb ) ,
48
49
( cb ) => nodeD . swarm . connect ( nodeC . peerId . addresses [ 0 ] , cb ) ,
49
50
( cb ) => nodeE . swarm . connect ( nodeC . peerId . addresses [ 0 ] , cb ) ,
50
- ( cb ) => nodeD . swarm . connect ( nodeE . peerId . addresses [ 0 ] , cb )
51
+ ( cb ) => nodeD . swarm . connect ( nodeE . peerId . addresses [ 0 ] , cb ) ,
52
+ ( cb ) => nodeA . id ( ( err , id ) => {
53
+ expect ( err ) . to . not . exist ( )
54
+ withGo = id . agentVersion . startsWith ( 'go-ipfs' )
55
+ cb ( )
56
+ } )
51
57
] , done )
52
58
} )
53
59
} )
@@ -63,14 +69,21 @@ module.exports = (common) => {
63
69
} )
64
70
} )
65
71
66
- // TODO: fix - go-ipfs errors with Error: key was not found (type 6)
67
- // https://github.com/ipfs/go-ipfs/issues/3862
68
- it . skip ( 'fetches value after it was put on another node' , ( done ) => {
72
+ it ( 'fetches value after it was put on another node' , function ( done ) {
73
+ this . timeout ( 80 * 1000 )
74
+
75
+ if ( withGo ) {
76
+ // go-ipfs errors with Error: key was not found (type 6)
77
+ // https://github.com/ipfs/go-ipfs/issues/3862
78
+ this . skip ( )
79
+ }
80
+
81
+ // TODO - this test needs to keep tryingl instead of the setTimeout
69
82
waterfall ( [
70
83
( cb ) => nodeB . object . new ( 'unixfs-dir' , cb ) ,
71
- ( node , cb ) => setTimeout ( ( ) => cb ( null , node ) , 1000 ) ,
72
- ( node , cb ) => {
73
- const multihash = node . toJSON ( ) . multihash
84
+ ( dagNode , cb ) => setTimeout ( ( ) => cb ( null , dagNode ) , 20000 ) ,
85
+ ( dagNode , cb ) => {
86
+ const multihash = dagNode . toJSON ( ) . multihash
74
87
75
88
nodeA . dht . get ( multihash , cb )
76
89
} ,
@@ -80,14 +93,6 @@ module.exports = (common) => {
80
93
}
81
94
] , done )
82
95
} )
83
-
84
- it ( 'Promises support' , ( done ) => {
85
- nodeA . dht . get ( 'non-existing' , { timeout : '100ms' } )
86
- . catch ( ( err ) => {
87
- expect ( err ) . to . exist ( )
88
- done ( )
89
- } )
90
- } )
91
96
} )
92
97
93
98
describe ( '.findpeer' , ( ) => {
@@ -100,9 +105,13 @@ module.exports = (common) => {
100
105
} )
101
106
} )
102
107
103
- // TODO checking what is exactly go-ipfs returning
104
- // https://github.com/ipfs/go-ipfs/issues/3862#issuecomment-294168090
105
- it . skip ( 'fails to find other peer, if peer doesnt exist()s' , ( done ) => {
108
+ it ( 'fails to find other peer, if peer does not exist' , function ( done ) {
109
+ if ( withGo ) {
110
+ // TODO checking what is exactly go-ipfs returning
111
+ // https://github.com/ipfs/go-ipfs/issues/3862#issuecomment-294168090
112
+ this . skip ( )
113
+ }
114
+
106
115
nodeA . dht . findpeer ( 'Qmd7qZS4T7xXtsNFdRoK1trfMs5zU94EpokQ9WFtxdPxsZ' , ( err , peer ) => {
107
116
expect ( err ) . to . not . exist ( )
108
117
expect ( peer ) . to . be . equal ( null )
@@ -177,37 +186,36 @@ module.exports = (common) => {
177
186
it . skip ( 'recursive' , ( ) => { } )
178
187
} )
179
188
180
- describe . skip ( 'findprovs' , ( ) => {
181
- it ( 'basic' , ( done ) => {
182
- const cid = new CID ( 'Qmd7qZS4T7xXtsNFdRoK1trfMs5zU94EpokQ9WFtxdPxxx' )
189
+ describe ( 'findprovs' , ( ) => {
190
+ it ( 'provide from one node and find it through another node' , function ( done ) {
191
+ if ( withGo ) {
192
+ // TODO go-ipfs endpoint doesn't conform with the others
193
+ // https://github.com/ipfs/go-ipfs/issues/5047
194
+ this . skip ( )
195
+ }
183
196
184
197
waterfall ( [
185
- ( cb ) => nodeB . dht . provide ( cid , cb ) ,
186
- ( cb ) => nodeC . dht . findprovs ( cid , cb ) ,
198
+ ( cb ) => nodeE . object . new ( 'unixfs-dir' , cb ) ,
199
+ ( dagNode , cb ) => {
200
+ const cidV0 = new CID ( dagNode . toJSON ( ) . multihash )
201
+ nodeE . dht . provide ( cidV0 , ( err ) => cb ( err , cidV0 ) )
202
+ } ,
203
+ ( cidV0 , cb ) => nodeC . dht . findprovs ( cidV0 , cb ) ,
187
204
( provs , cb ) => {
188
205
expect ( provs . map ( ( p ) => p . toB58String ( ) ) )
189
- . to . eql ( [ nodeB . peerId . id ] )
206
+ . to . eql ( [ nodeE . peerId . id ] )
190
207
cb ( )
191
208
}
192
209
] , done )
193
210
} )
194
-
195
- it ( 'Promises support' , ( done ) => {
196
- nodeB . dht . findprovs ( 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
197
- . then ( ( res ) => {
198
- expect ( res ) . to . be . an ( 'array' )
199
- done ( )
200
- } )
201
- . catch ( ( err ) => done ( err ) )
202
- } )
203
211
} )
204
212
205
213
describe ( '.query' , ( ) => {
206
214
it ( 'returns the other node in the query' , function ( done ) {
207
215
const timeout = 150 * 1000
208
216
this . timeout ( timeout )
209
217
210
- // This test is flaky . DHT works best with >= 20 nodes. Therefore a
218
+ // This test is meh . DHT works best with >= 20 nodes. Therefore a
211
219
// failure might happen, but we don't want to report it as such.
212
220
// Hence skip the test before the timeout is reached
213
221
const timeoutId = setTimeout ( function ( ) {
0 commit comments