@libp2p/interface-compliance-tests 1.1.16 → 1.1.19
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/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +30 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/peer-discovery/index.d.ts.map +1 -1
- package/dist/src/peer-discovery/index.js +11 -10
- package/dist/src/peer-discovery/index.js.map +1 -1
- package/dist/src/pubsub/api.d.ts +2 -2
- package/dist/src/pubsub/api.d.ts.map +1 -1
- package/dist/src/pubsub/api.js.map +1 -1
- package/dist/src/pubsub/connection-handlers.d.ts +2 -2
- package/dist/src/pubsub/connection-handlers.d.ts.map +1 -1
- package/dist/src/pubsub/connection-handlers.js +8 -14
- package/dist/src/pubsub/connection-handlers.js.map +1 -1
- package/dist/src/pubsub/emit-self.d.ts +2 -2
- package/dist/src/pubsub/emit-self.d.ts.map +1 -1
- package/dist/src/pubsub/emit-self.js +5 -4
- package/dist/src/pubsub/emit-self.js.map +1 -1
- package/dist/src/pubsub/index.d.ts +2 -11
- package/dist/src/pubsub/index.d.ts.map +1 -1
- package/dist/src/pubsub/index.js.map +1 -1
- package/dist/src/pubsub/messages.d.ts +2 -2
- package/dist/src/pubsub/messages.d.ts.map +1 -1
- package/dist/src/pubsub/messages.js +3 -2
- package/dist/src/pubsub/messages.js.map +1 -1
- package/dist/src/pubsub/multiple-nodes.d.ts +2 -2
- package/dist/src/pubsub/multiple-nodes.d.ts.map +1 -1
- package/dist/src/pubsub/multiple-nodes.js +5 -4
- package/dist/src/pubsub/multiple-nodes.js.map +1 -1
- package/dist/src/pubsub/two-nodes.d.ts +2 -2
- package/dist/src/pubsub/two-nodes.d.ts.map +1 -1
- package/dist/src/pubsub/two-nodes.js +3 -4
- package/dist/src/pubsub/two-nodes.js.map +1 -1
- package/dist/src/transport/listen-test.d.ts.map +1 -1
- package/dist/src/transport/listen-test.js +3 -2
- package/dist/src/transport/listen-test.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +49 -0
- package/src/peer-discovery/index.ts +14 -10
- package/src/pubsub/api.ts +3 -3
- package/src/pubsub/connection-handlers.ts +18 -24
- package/src/pubsub/emit-self.ts +8 -7
- package/src/pubsub/index.ts +2 -12
- package/src/pubsub/messages.ts +6 -5
- package/src/pubsub/multiple-nodes.ts +15 -22
- package/src/pubsub/two-nodes.ts +7 -8
- package/src/transport/listen-test.ts +3 -2
|
@@ -11,22 +11,23 @@ import { CustomEvent } from '@libp2p/interfaces'
|
|
|
11
11
|
import { waitForSubscriptionUpdate } from './utils.js'
|
|
12
12
|
import type { TestSetup } from '../index.js'
|
|
13
13
|
import type { Message } from '@libp2p/interfaces/pubsub'
|
|
14
|
-
import type {
|
|
14
|
+
import type { PubSubArgs } from './index.js'
|
|
15
15
|
import type { PeerId } from '@libp2p/interfaces/peer-id'
|
|
16
16
|
import type { Registrar } from '@libp2p/interfaces/registrar'
|
|
17
17
|
import type { PubSubBaseProtocol } from '@libp2p/pubsub'
|
|
18
18
|
import { Components } from '@libp2p/interfaces/components'
|
|
19
|
+
import { start, stop } from '../index.js'
|
|
19
20
|
|
|
20
|
-
export default (common: TestSetup<PubSubBaseProtocol
|
|
21
|
+
export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
21
22
|
describe('pubsub with multiple nodes', function () {
|
|
22
23
|
describe('every peer subscribes to the topic', () => {
|
|
23
24
|
describe('line', () => {
|
|
24
25
|
// line
|
|
25
26
|
// ◉────◉────◉
|
|
26
27
|
// a b c
|
|
27
|
-
let psA: PubSubBaseProtocol
|
|
28
|
-
let psB: PubSubBaseProtocol
|
|
29
|
-
let psC: PubSubBaseProtocol
|
|
28
|
+
let psA: PubSubBaseProtocol
|
|
29
|
+
let psB: PubSubBaseProtocol
|
|
30
|
+
let psC: PubSubBaseProtocol
|
|
30
31
|
let peerIdA: PeerId
|
|
31
32
|
let peerIdB: PeerId
|
|
32
33
|
let peerIdC: PeerId
|
|
@@ -73,9 +74,7 @@ export default (common: TestSetup<PubSubBaseProtocol<EventMap>, PubSubArgs>) =>
|
|
|
73
74
|
})
|
|
74
75
|
|
|
75
76
|
// Start pubsub modes
|
|
76
|
-
await
|
|
77
|
-
[psA, psB, psC].map(async (p) => await p.start())
|
|
78
|
-
)
|
|
77
|
+
await start(psA, psB, psC)
|
|
79
78
|
})
|
|
80
79
|
|
|
81
80
|
// Connect nodes
|
|
@@ -106,9 +105,7 @@ export default (common: TestSetup<PubSubBaseProtocol<EventMap>, PubSubArgs>) =>
|
|
|
106
105
|
afterEach(async () => {
|
|
107
106
|
sinon.restore()
|
|
108
107
|
|
|
109
|
-
await
|
|
110
|
-
[psA, psB, psC].map(async (p) => await p.stop())
|
|
111
|
-
)
|
|
108
|
+
await stop(psA, psB, psC)
|
|
112
109
|
|
|
113
110
|
await common.teardown()
|
|
114
111
|
})
|
|
@@ -276,11 +273,11 @@ export default (common: TestSetup<PubSubBaseProtocol<EventMap>, PubSubArgs>) =>
|
|
|
276
273
|
// │b d│
|
|
277
274
|
// ◉─┘ └─◉
|
|
278
275
|
// a
|
|
279
|
-
let psA: PubSubBaseProtocol
|
|
280
|
-
let psB: PubSubBaseProtocol
|
|
281
|
-
let psC: PubSubBaseProtocol
|
|
282
|
-
let psD: PubSubBaseProtocol
|
|
283
|
-
let psE: PubSubBaseProtocol
|
|
276
|
+
let psA: PubSubBaseProtocol
|
|
277
|
+
let psB: PubSubBaseProtocol
|
|
278
|
+
let psC: PubSubBaseProtocol
|
|
279
|
+
let psD: PubSubBaseProtocol
|
|
280
|
+
let psE: PubSubBaseProtocol
|
|
284
281
|
let peerIdA: PeerId
|
|
285
282
|
let peerIdB: PeerId
|
|
286
283
|
let peerIdC: PeerId
|
|
@@ -353,9 +350,7 @@ export default (common: TestSetup<PubSubBaseProtocol<EventMap>, PubSubArgs>) =>
|
|
|
353
350
|
})
|
|
354
351
|
|
|
355
352
|
// Start pubsub nodes
|
|
356
|
-
await
|
|
357
|
-
[psA, psB, psC, psD, psE].map(async (p) => await p.start())
|
|
358
|
-
)
|
|
353
|
+
await start(psA, psB, psC, psD, psE)
|
|
359
354
|
})
|
|
360
355
|
|
|
361
356
|
// connect nodes
|
|
@@ -400,9 +395,7 @@ export default (common: TestSetup<PubSubBaseProtocol<EventMap>, PubSubArgs>) =>
|
|
|
400
395
|
})
|
|
401
396
|
|
|
402
397
|
afterEach(async () => {
|
|
403
|
-
await
|
|
404
|
-
[psA, psB, psC, psD, psE].map(async (p) => await p.stop())
|
|
405
|
-
)
|
|
398
|
+
await stop(psA, psB, psC, psD, psE)
|
|
406
399
|
await common.teardown()
|
|
407
400
|
})
|
|
408
401
|
|
package/src/pubsub/two-nodes.ts
CHANGED
|
@@ -11,11 +11,12 @@ import { CustomEvent } from '@libp2p/interfaces'
|
|
|
11
11
|
import { waitForSubscriptionUpdate } from './utils.js'
|
|
12
12
|
import type { TestSetup } from '../index.js'
|
|
13
13
|
import type { Message } from '@libp2p/interfaces/pubsub'
|
|
14
|
-
import type {
|
|
14
|
+
import type { PubSubArgs } from './index.js'
|
|
15
15
|
import type { PeerId } from '@libp2p/interfaces/peer-id'
|
|
16
16
|
import type { Registrar } from '@libp2p/interfaces/registrar'
|
|
17
17
|
import type { PubSubBaseProtocol } from '@libp2p/pubsub'
|
|
18
18
|
import { Components } from '@libp2p/interfaces/components'
|
|
19
|
+
import { start, stop } from '../index.js'
|
|
19
20
|
|
|
20
21
|
const topic = 'foo'
|
|
21
22
|
|
|
@@ -23,10 +24,10 @@ function shouldNotHappen () {
|
|
|
23
24
|
expect.fail()
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export default (common: TestSetup<PubSubBaseProtocol
|
|
27
|
+
export default (common: TestSetup<PubSubBaseProtocol, PubSubArgs>) => {
|
|
27
28
|
describe('pubsub with two nodes', () => {
|
|
28
|
-
let psA: PubSubBaseProtocol
|
|
29
|
-
let psB: PubSubBaseProtocol
|
|
29
|
+
let psA: PubSubBaseProtocol
|
|
30
|
+
let psB: PubSubBaseProtocol
|
|
30
31
|
let peerIdA: PeerId
|
|
31
32
|
let peerIdB: PeerId
|
|
32
33
|
let registrarA: Registrar
|
|
@@ -60,8 +61,7 @@ export default (common: TestSetup<PubSubBaseProtocol<EventMap>, PubSubArgs>) =>
|
|
|
60
61
|
})
|
|
61
62
|
|
|
62
63
|
// Start pubsub and connect nodes
|
|
63
|
-
await
|
|
64
|
-
await psB.start()
|
|
64
|
+
await start(psA, psB)
|
|
65
65
|
|
|
66
66
|
expect(psA.getPeers()).to.be.empty()
|
|
67
67
|
expect(psB.getPeers()).to.be.empty()
|
|
@@ -81,8 +81,7 @@ export default (common: TestSetup<PubSubBaseProtocol<EventMap>, PubSubArgs>) =>
|
|
|
81
81
|
afterEach(async () => {
|
|
82
82
|
sinon.restore()
|
|
83
83
|
|
|
84
|
-
await
|
|
85
|
-
await psB.stop()
|
|
84
|
+
await stop(psA, psB)
|
|
86
85
|
|
|
87
86
|
await common.teardown()
|
|
88
87
|
})
|
|
@@ -9,6 +9,7 @@ import { mockUpgrader } from '../mocks/upgrader.js'
|
|
|
9
9
|
import defer from 'p-defer'
|
|
10
10
|
import { mockRegistrar } from '../mocks/registrar.js'
|
|
11
11
|
import drain from 'it-drain'
|
|
12
|
+
import { CustomEvent } from '@libp2p/interfaces'
|
|
12
13
|
import type { TestSetup } from '../index.js'
|
|
13
14
|
import type { Transport, Upgrader } from '@libp2p/interfaces/transport'
|
|
14
15
|
import type { TransportTestFixtures } from './index.js'
|
|
@@ -169,8 +170,8 @@ export default (common: TestSetup<TransportTestFixtures>) => {
|
|
|
169
170
|
expect(evt.detail).to.be.an.instanceOf(Error)
|
|
170
171
|
listener.close().then(done, done)
|
|
171
172
|
})
|
|
172
|
-
listener.dispatchEvent(new
|
|
173
|
-
|
|
173
|
+
listener.dispatchEvent(new CustomEvent('error', {
|
|
174
|
+
detail: new Error('my err')
|
|
174
175
|
}))
|
|
175
176
|
})
|
|
176
177
|
|