Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Commit f5b85fc

Browse files
authored
fix: update p-queue types (#428)
[email protected] contained a breaking change so update it's use to get the correct return types.
1 parent a70ab3f commit f5b85fc

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/providers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ export class Providers implements Startable {
216216
return [...provs.keys()].map(peerIdStr => {
217217
return peerIdFromString(peerIdStr)
218218
})
219+
}, {
220+
// no timeout is specified for this queue so it will not
221+
// throw, but this is required to get the right return
222+
// type since [email protected]
223+
throwOnTimeout: true
219224
})
220225
}
221226
}

test/network.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type { PeerId } from '@libp2p/interface-peer-id'
1515
import type { Sink } from 'it-stream-types'
1616
import { Uint8ArrayList } from 'uint8arraylist'
1717
import map from 'it-map'
18+
import type { Multiaddr } from '@multiformats/multiaddr'
1819

1920
describe('Network', () => {
2021
let dht: DualKadDHT
@@ -53,7 +54,7 @@ describe('Network', () => {
5354
const msg = new Message(MESSAGE_TYPE.PING, uint8ArrayFromString('hello'), 0)
5455

5556
// mock it
56-
dht.components.connectionManager.openConnection = async (peer: PeerId) => {
57+
dht.components.connectionManager.openConnection = async (peer: PeerId | Multiaddr) => {
5758
// @ts-expect-error incomplete implementation
5859
const connection: Connection = {
5960
newStream: async (protocols: string | string[]) => {

test/providers.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ describe('Providers', () => {
6868
cacheSize: 10
6969
})
7070

71-
const hashes = await Promise.all([...new Array(100)].map((i: number) => {
72-
return sha256.digest(uint8ArrayFromString(`hello ${i}`))
71+
const hashes = await Promise.all([...new Array(100)].map(async (i: number) => {
72+
return await sha256.digest(uint8ArrayFromString(`hello ${i}`))
7373
}))
7474

7575
const cids = hashes.map((h) => CID.createV0(h))

test/routing-table.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ describe('Routing Table', () => {
113113
let fn: (() => Promise<any>) | undefined
114114

115115
// execute queued functions immediately
116+
// @ts-expect-error incomplete implementation
116117
table.pingQueue = {
117-
// @ts-expect-error
118118
add: async (f: () => Promise<any>) => {
119119
fn = f
120120
},
@@ -175,8 +175,8 @@ describe('Routing Table', () => {
175175
let fn: (() => Promise<any>) | undefined
176176

177177
// execute queued functions immediately
178+
// @ts-expect-error incomplete implementation
178179
table.pingQueue = {
179-
// @ts-expect-error
180180
add: async (f: () => Promise<any>) => {
181181
fn = f
182182
},

0 commit comments

Comments
 (0)