@@ -29,7 +29,7 @@ const factory = createFactory({
29
29
endpoint : 'http://localhost:57583'
30
30
} )
31
31
32
- async function spawnNode ( bootstrap : any [ ] = [ ] ) {
32
+ async function spawnNode ( bootstrap : any [ ] = [ ] ) : Promise < { node : Controller , id : IDResult } > {
33
33
const node = await factory . spawn ( {
34
34
// Lock down the nodes so testing can be deterministic
35
35
ipfsOptions : {
@@ -46,7 +46,7 @@ async function spawnNode (bootstrap: any[] = []) {
46
46
}
47
47
}
48
48
49
- function createIpfsClient ( opts : Options ) {
49
+ function createIpfsClient ( opts : Options ) : any {
50
50
const client = create ( opts )
51
51
52
52
return {
@@ -119,7 +119,7 @@ describe('DelegatedPeerRouting', function () {
119
119
port : 8000 ,
120
120
host : 'localhost'
121
121
} )
122
- // @ts -expect-error ipfs-http-client types are out of date
122
+
123
123
const router = delegatedPeerRouting ( client ) ( )
124
124
125
125
expect ( router ) . to . have . property ( 'client' )
@@ -138,33 +138,30 @@ describe('DelegatedPeerRouting', function () {
138
138
it ( 'should be able to find peers via the delegate with a peer id string' , async ( ) => {
139
139
const opts = delegatedNode . apiAddr . toOptions ( )
140
140
141
- // @ts -expect-error ipfs-http-client types are out of date
142
141
const router = delegatedPeerRouting ( createIpfsClient ( {
143
142
protocol : 'http' ,
144
143
port : opts . port ,
145
144
host : opts . host
146
145
} ) ) ( )
147
146
148
- // @ts -expect-error ipfs-http-client types are out of date
149
147
const peer = await router . findPeer ( peerIdToFind . id )
150
148
151
149
const { id, multiaddrs } = peer
152
150
expect ( id ) . to . exist ( )
153
151
expect ( multiaddrs ) . to . exist ( )
154
- // @ts -expect-error ipfs-http-client types are out of date
152
+
155
153
expect ( id . equals ( peerIdToFind . id ) ) . to . be . true ( )
156
154
} )
157
155
158
156
it ( 'should be able to find peers via the delegate with a peerid' , async ( ) => {
159
157
const opts = delegatedNode . apiAddr . toOptions ( )
160
- // @ts -expect-error ipfs-http-client types are out of date
158
+
161
159
const router = delegatedPeerRouting ( createIpfsClient ( {
162
160
protocol : 'http' ,
163
161
port : opts . port ,
164
162
host : opts . host
165
163
} ) ) ( )
166
164
167
- // @ts -expect-error ipfs-http-client types are out of date
168
165
const peer = await router . findPeer ( peerIdToFind . id )
169
166
170
167
const { id, multiaddrs } = peer
@@ -176,15 +173,14 @@ describe('DelegatedPeerRouting', function () {
176
173
177
174
it ( 'should be able to specify a timeout' , async ( ) => {
178
175
const opts = delegatedNode . apiAddr . toOptions ( )
179
- // @ts -expect-error ipfs-http-client types are out of date
176
+
180
177
const router = delegatedPeerRouting ( createIpfsClient ( {
181
178
protocol : 'http' ,
182
179
port : opts . port ,
183
180
host : opts . host
184
181
} ) ) ( )
185
182
const controller = new TimeoutController ( 5e3 )
186
183
187
- // @ts -expect-error ipfs-http-client types are out of date
188
184
const peer = await router . findPeer ( peerIdToFind . id , { signal : controller . signal } )
189
185
190
186
const { id, multiaddrs } = peer
@@ -198,7 +194,7 @@ describe('DelegatedPeerRouting', function () {
198
194
199
195
it ( 'should not be able to find peers not on the network' , async ( ) => {
200
196
const opts = delegatedNode . apiAddr . toOptions ( )
201
- // @ts -expect-error ipfs-http-client types are out of date
197
+
202
198
const router = delegatedPeerRouting ( createIpfsClient ( {
203
199
protocol : 'http' ,
204
200
port : opts . port ,
@@ -216,7 +212,6 @@ describe('DelegatedPeerRouting', function () {
216
212
it ( 'should be able to query for the closest peers' , async ( ) => {
217
213
const opts = delegatedNode . apiAddr . toOptions ( )
218
214
219
- // @ts -expect-error ipfs-http-client types are out of date
220
215
const router = delegatedPeerRouting ( createIpfsClient ( {
221
216
protocol : 'http' ,
222
217
port : opts . port ,
@@ -234,7 +229,7 @@ describe('DelegatedPeerRouting', function () {
234
229
expect ( closerPeers . length ) . to . equal ( 2 )
235
230
closerPeers . forEach ( result => {
236
231
// shouldn't be the delegate
237
- // @ts -expect-error ipfs-http-client types are out of date
232
+
238
233
expect ( delegatePeerId . equals ( result . id ) ) . to . equal ( false )
239
234
expect ( result . multiaddrs ) . to . be . an ( 'array' )
240
235
} )
@@ -243,7 +238,6 @@ describe('DelegatedPeerRouting', function () {
243
238
it ( 'should find closest peers even if the peer does not exist' , async ( ) => {
244
239
const opts = delegatedNode . apiAddr . toOptions ( )
245
240
246
- // @ts -expect-error ipfs-http-client types are out of date
247
241
const router = delegatedPeerRouting ( createIpfsClient ( {
248
242
protocol : 'http' ,
249
243
port : opts . port ,
@@ -260,7 +254,7 @@ describe('DelegatedPeerRouting', function () {
260
254
expect ( closerPeers . length ) . to . equal ( 2 )
261
255
closerPeers . forEach ( result => {
262
256
// shouldnt be the delegate
263
- // @ts -expect-error ipfs-http-client types are out of date
257
+
264
258
expect ( delegatePeerId . equals ( result . id ) ) . to . equal ( false )
265
259
expect ( result . multiaddrs ) . to . be . an ( 'array' )
266
260
} )
@@ -270,7 +264,7 @@ describe('DelegatedPeerRouting', function () {
270
264
describe ( 'stop' , ( ) => {
271
265
it ( 'should cancel in-flight requests when stopping' , async ( ) => {
272
266
const opts = delegatedNode . apiAddr . toOptions ( )
273
- // @ts -expect-error ipfs-http-client types are out of date
267
+
274
268
const router = delegatedPeerRouting ( createIpfsClient ( {
275
269
protocol : 'http' ,
276
270
port : opts . port ,
0 commit comments