@libp2p/interface-compliance-tests 3.0.7-05abd49f → 3.0.7-06f4901a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/mocks/connection-manager.d.ts +2 -0
- package/dist/src/mocks/connection-manager.d.ts.map +1 -1
- package/dist/src/mocks/connection-manager.js.map +1 -1
- package/dist/src/pubsub/api.d.ts +6 -0
- package/dist/src/pubsub/api.d.ts.map +1 -0
- package/dist/src/pubsub/api.js +87 -0
- package/dist/src/pubsub/api.js.map +1 -0
- package/dist/src/pubsub/connection-handlers.d.ts +6 -0
- package/dist/src/pubsub/connection-handlers.d.ts.map +1 -0
- package/dist/src/pubsub/connection-handlers.js +329 -0
- package/dist/src/pubsub/connection-handlers.js.map +1 -0
- package/dist/src/pubsub/emit-self.d.ts +6 -0
- package/dist/src/pubsub/emit-self.d.ts.map +1 -0
- package/dist/src/pubsub/emit-self.js +80 -0
- package/dist/src/pubsub/emit-self.js.map +1 -0
- package/dist/src/pubsub/index.d.ts +18 -0
- package/dist/src/pubsub/index.d.ts.map +1 -0
- package/dist/src/pubsub/index.js +17 -0
- package/dist/src/pubsub/index.js.map +1 -0
- package/dist/src/pubsub/messages.d.ts +6 -0
- package/dist/src/pubsub/messages.d.ts.map +1 -0
- package/dist/src/pubsub/messages.js +48 -0
- package/dist/src/pubsub/messages.js.map +1 -0
- package/dist/src/pubsub/multiple-nodes.d.ts +6 -0
- package/dist/src/pubsub/multiple-nodes.d.ts.map +1 -0
- package/dist/src/pubsub/multiple-nodes.js +350 -0
- package/dist/src/pubsub/multiple-nodes.js.map +1 -0
- package/dist/src/pubsub/two-nodes.d.ts +6 -0
- package/dist/src/pubsub/two-nodes.d.ts.map +1 -0
- package/dist/src/pubsub/two-nodes.js +217 -0
- package/dist/src/pubsub/two-nodes.js.map +1 -0
- package/dist/src/pubsub/utils.d.ts +6 -0
- package/dist/src/pubsub/utils.d.ts.map +1 -0
- package/dist/src/pubsub/utils.js +22 -0
- package/dist/src/pubsub/utils.js.map +1 -0
- package/package.json +13 -8
- package/src/mocks/connection-manager.ts +2 -0
- package/src/pubsub/api.ts +114 -0
- package/src/pubsub/connection-handlers.ts +413 -0
- package/src/pubsub/emit-self.ts +99 -0
- package/src/pubsub/index.ts +34 -0
- package/src/pubsub/messages.ts +59 -0
- package/src/pubsub/multiple-nodes.ts +440 -0
- package/src/pubsub/two-nodes.ts +273 -0
- package/src/pubsub/utils.ts +29 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EventEmitter } from '@libp2p/interface/events'
|
|
2
|
+
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
|
|
3
|
+
import { pEvent } from 'p-event'
|
|
4
|
+
import pWaitFor from 'p-wait-for'
|
|
5
|
+
import { mockConnectionManager, mockRegistrar, mockNetwork } from '../mocks/index.js'
|
|
6
|
+
import type { MockNetworkComponents } from '../mocks/index.js'
|
|
7
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
8
|
+
import type { PubSub, SubscriptionChangeData } from '@libp2p/interface/pubsub'
|
|
9
|
+
|
|
10
|
+
export async function waitForSubscriptionUpdate (a: PubSub, b: PeerId): Promise<void> {
|
|
11
|
+
await pWaitFor(async () => {
|
|
12
|
+
const event = await pEvent<'subscription-change', CustomEvent<SubscriptionChangeData>>(a, 'subscription-change')
|
|
13
|
+
|
|
14
|
+
return event.detail.peerId.equals(b)
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function createComponents (): Promise<MockNetworkComponents> {
|
|
19
|
+
const components: any = {
|
|
20
|
+
peerId: await createEd25519PeerId(),
|
|
21
|
+
registrar: mockRegistrar(),
|
|
22
|
+
events: new EventEmitter()
|
|
23
|
+
}
|
|
24
|
+
components.connectionManager = mockConnectionManager(components)
|
|
25
|
+
|
|
26
|
+
mockNetwork.addNode(components)
|
|
27
|
+
|
|
28
|
+
return components
|
|
29
|
+
}
|