@libp2p/interface-compliance-tests 1.1.6 → 1.1.10
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.d.ts +13 -2
- package/dist/src/mocks/connection.d.ts.map +1 -1
- package/dist/src/mocks/connection.js +56 -24
- package/dist/src/mocks/connection.js.map +1 -1
- package/dist/src/mocks/multiaddr-connection.d.ts +2 -1
- package/dist/src/mocks/multiaddr-connection.d.ts.map +1 -1
- package/dist/src/mocks/multiaddr-connection.js +2 -2
- package/dist/src/mocks/multiaddr-connection.js.map +1 -1
- package/dist/src/mocks/muxer.d.ts +2 -2
- package/dist/src/mocks/muxer.d.ts.map +1 -1
- package/dist/src/mocks/muxer.js +175 -26
- package/dist/src/mocks/muxer.js.map +1 -1
- package/dist/src/mocks/registrar.d.ts +11 -2
- package/dist/src/mocks/registrar.d.ts.map +1 -1
- package/dist/src/mocks/registrar.js +47 -5
- package/dist/src/mocks/registrar.js.map +1 -1
- package/dist/src/mocks/upgrader.d.ts.map +1 -1
- package/dist/src/mocks/upgrader.js +8 -4
- package/dist/src/mocks/upgrader.js.map +1 -1
- package/dist/src/pubsub/api.d.ts +3 -2
- package/dist/src/pubsub/api.d.ts.map +1 -1
- package/dist/src/pubsub/api.js +23 -13
- package/dist/src/pubsub/api.js.map +1 -1
- package/dist/src/pubsub/connection-handlers.d.ts +3 -2
- package/dist/src/pubsub/connection-handlers.d.ts.map +1 -1
- package/dist/src/pubsub/connection-handlers.js +165 -69
- package/dist/src/pubsub/connection-handlers.js.map +1 -1
- package/dist/src/pubsub/emit-self.d.ts +3 -2
- package/dist/src/pubsub/emit-self.d.ts.map +1 -1
- package/dist/src/pubsub/emit-self.js +15 -4
- package/dist/src/pubsub/emit-self.js.map +1 -1
- package/dist/src/pubsub/index.d.ts +6 -3
- 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 +3 -2
- package/dist/src/pubsub/messages.d.ts.map +1 -1
- package/dist/src/pubsub/messages.js +42 -39
- package/dist/src/pubsub/messages.js.map +1 -1
- package/dist/src/pubsub/multiple-nodes.d.ts +3 -2
- package/dist/src/pubsub/multiple-nodes.d.ts.map +1 -1
- package/dist/src/pubsub/multiple-nodes.js +163 -65
- package/dist/src/pubsub/multiple-nodes.js.map +1 -1
- package/dist/src/pubsub/two-nodes.d.ts +3 -2
- package/dist/src/pubsub/two-nodes.d.ts.map +1 -1
- package/dist/src/pubsub/two-nodes.js +80 -38
- package/dist/src/pubsub/two-nodes.js.map +1 -1
- package/dist/src/stream-muxer/base-test.js +1 -1
- package/dist/src/stream-muxer/base-test.js.map +1 -1
- package/dist/src/stream-muxer/close-test.d.ts.map +1 -1
- package/dist/src/stream-muxer/close-test.js +12 -10
- package/dist/src/stream-muxer/close-test.js.map +1 -1
- package/dist/src/transport/dial-test.d.ts.map +1 -1
- package/dist/src/transport/dial-test.js +2 -1
- package/dist/src/transport/dial-test.js.map +1 -1
- package/dist/src/transport/filter-test.js +1 -1
- package/dist/src/transport/filter-test.js.map +1 -1
- package/dist/src/transport/listen-test.d.ts.map +1 -1
- package/dist/src/transport/listen-test.js +2 -1
- package/dist/src/transport/listen-test.js.map +1 -1
- package/dist/src/utils/is-valid-tick.d.ts +6 -0
- package/dist/src/utils/is-valid-tick.d.ts.map +1 -0
- package/dist/src/utils/is-valid-tick.js +15 -0
- package/dist/src/utils/is-valid-tick.js.map +1 -0
- package/package.json +7 -5
- package/src/mocks/connection.ts +80 -24
- package/src/mocks/multiaddr-connection.ts +3 -2
- package/src/mocks/muxer.ts +230 -28
- package/src/mocks/registrar.ts +65 -7
- package/src/mocks/upgrader.ts +8 -5
- package/src/pubsub/api.ts +29 -15
- package/src/pubsub/connection-handlers.ts +186 -75
- package/src/pubsub/emit-self.ts +19 -7
- package/src/pubsub/index.ts +6 -3
- package/src/pubsub/messages.ts +59 -44
- package/src/pubsub/multiple-nodes.ts +189 -76
- package/src/pubsub/two-nodes.ts +94 -46
- package/src/stream-muxer/base-test.ts +1 -1
- package/src/stream-muxer/close-test.ts +13 -12
- package/src/transport/dial-test.ts +2 -1
- package/src/transport/filter-test.ts +1 -1
- package/src/transport/listen-test.ts +2 -1
- package/src/utils/is-valid-tick.ts +18 -0
- package/dist/src/pubsub/utils.d.ts +0 -3
- package/dist/src/pubsub/utils.d.ts.map +0 -1
- package/dist/src/pubsub/utils.js +0 -11
- package/dist/src/pubsub/utils.js.map +0 -1
- package/dist/src/transport/utils/index.d.ts +0 -15
- package/dist/src/transport/utils/index.d.ts.map +0 -1
- package/dist/src/transport/utils/index.js +0 -137
- package/dist/src/transport/utils/index.js.map +0 -1
- package/src/pubsub/utils.ts +0 -13
- package/src/transport/utils/index.ts +0 -172
|
@@ -2,7 +2,18 @@ import type { MultiaddrConnection } from '@libp2p/interfaces/transport';
|
|
|
2
2
|
import type { Connection, Stream } from '@libp2p/interfaces/connection';
|
|
3
3
|
import type { Muxer } from '@libp2p/interfaces/stream-muxer';
|
|
4
4
|
import type { Duplex } from 'it-stream-types';
|
|
5
|
-
|
|
5
|
+
import type { PeerId } from '@libp2p/interfaces/src/peer-id';
|
|
6
|
+
import type { Registrar } from '@libp2p/interfaces/registrar';
|
|
7
|
+
export interface MockConnectionOptions {
|
|
8
|
+
direction?: 'inbound' | 'outbound';
|
|
9
|
+
muxer?: Muxer;
|
|
10
|
+
registrar?: Registrar;
|
|
11
|
+
}
|
|
12
|
+
export declare function mockConnection(maConn: MultiaddrConnection, opts?: MockConnectionOptions): Connection;
|
|
6
13
|
export declare function mockStream(stream: Duplex<Uint8Array>): Stream;
|
|
7
|
-
export
|
|
14
|
+
export interface Peer {
|
|
15
|
+
peerId: PeerId;
|
|
16
|
+
registrar: Registrar;
|
|
17
|
+
}
|
|
18
|
+
export declare function connectionPair(a: Peer, b: Peer): [Connection, Connection];
|
|
8
19
|
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/mocks/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/mocks/connection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAA4B,MAAM,+BAA+B,CAAA;AACjG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAQ7D,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IAClC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAED,wBAAgB,cAAc,CAAE,MAAM,EAAE,mBAAmB,EAAE,IAAI,GAAE,qBAA0B,GAAG,UAAU,CAiGzG;AAED,wBAAgB,UAAU,CAAE,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAW9D;AAED,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,CAAA;CACrB;AAED,wBAAgB,cAAc,CAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,CAAE,UAAU,EAAE,UAAU,CAAE,CAe5E"}
|
|
@@ -1,17 +1,51 @@
|
|
|
1
1
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
2
|
-
import { createEd25519PeerId } from '@libp2p/peer-id-factory';
|
|
3
2
|
import { pipe } from 'it-pipe';
|
|
4
3
|
import { duplexPair } from 'it-pair/duplex';
|
|
5
4
|
import { mockMuxer } from './muxer.js';
|
|
6
|
-
|
|
5
|
+
import { mockMultiaddrConnection } from './multiaddr-connection.js';
|
|
6
|
+
import { mockRegistrar } from './registrar.js';
|
|
7
|
+
import { Dialer, Listener } from '@libp2p/multistream-select';
|
|
8
|
+
import { logger } from '@libp2p/logger';
|
|
9
|
+
import { CustomEvent } from '@libp2p/interfaces';
|
|
10
|
+
const log = logger('libp2p:mock-connection');
|
|
11
|
+
export function mockConnection(maConn, opts = {}) {
|
|
7
12
|
const remoteAddr = maConn.remoteAddr;
|
|
8
13
|
const remotePeerIdStr = remoteAddr.getPeerId();
|
|
9
|
-
|
|
14
|
+
if (remotePeerIdStr == null) {
|
|
15
|
+
throw new Error('Remote multiaddr must contain a peer id');
|
|
16
|
+
}
|
|
17
|
+
const remotePeer = peerIdFromString(remotePeerIdStr);
|
|
10
18
|
const registry = new Map();
|
|
11
19
|
const streams = [];
|
|
12
|
-
|
|
20
|
+
const direction = opts.direction ?? 'inbound';
|
|
21
|
+
const registrar = opts.registrar ?? mockRegistrar();
|
|
22
|
+
const muxer = opts.muxer ?? mockMuxer({
|
|
23
|
+
onStream: (muxedStream) => {
|
|
24
|
+
const mss = new Listener(muxedStream);
|
|
25
|
+
try {
|
|
26
|
+
mss.handle(registrar.getProtocols())
|
|
27
|
+
.then(({ stream, protocol }) => {
|
|
28
|
+
log('%s: incoming stream opened on %s', direction, protocol);
|
|
29
|
+
muxedStream = { ...muxedStream, ...stream };
|
|
30
|
+
connection.addStream(muxedStream, { protocol, metadata: {} });
|
|
31
|
+
const handler = registrar.getHandler(protocol);
|
|
32
|
+
handler(new CustomEvent('incomingStream', {
|
|
33
|
+
detail: { connection, stream: muxedStream, protocol }
|
|
34
|
+
}));
|
|
35
|
+
}).catch(err => {
|
|
36
|
+
log.error(err);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
log.error(err);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
onStreamEnd: (stream) => {
|
|
44
|
+
connection.removeStream(stream.id);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
13
47
|
void pipe(maConn, muxer, maConn);
|
|
14
|
-
|
|
48
|
+
const connection = {
|
|
15
49
|
id: 'mock-connection',
|
|
16
50
|
remoteAddr,
|
|
17
51
|
remotePeer,
|
|
@@ -32,11 +66,16 @@ export async function mockConnection(maConn, direction = 'inbound', muxer = mock
|
|
|
32
66
|
if (protocols.length === 0) {
|
|
33
67
|
throw new Error('protocols must have a length');
|
|
34
68
|
}
|
|
35
|
-
const id = `${
|
|
69
|
+
const id = `${Math.random()}`;
|
|
36
70
|
const stream = muxer.newStream(id);
|
|
71
|
+
const mss = new Dialer(stream);
|
|
72
|
+
const result = await mss.select(protocols);
|
|
37
73
|
const streamData = {
|
|
38
|
-
protocol:
|
|
39
|
-
stream
|
|
74
|
+
protocol: result.protocol,
|
|
75
|
+
stream: {
|
|
76
|
+
...stream,
|
|
77
|
+
...result.stream
|
|
78
|
+
}
|
|
40
79
|
};
|
|
41
80
|
registry.set(id, streamData);
|
|
42
81
|
return streamData;
|
|
@@ -50,6 +89,7 @@ export async function mockConnection(maConn, direction = 'inbound', muxer = mock
|
|
|
50
89
|
await maConn.close();
|
|
51
90
|
}
|
|
52
91
|
};
|
|
92
|
+
return connection;
|
|
53
93
|
}
|
|
54
94
|
export function mockStream(stream) {
|
|
55
95
|
return {
|
|
@@ -63,23 +103,15 @@ export function mockStream(stream) {
|
|
|
63
103
|
id: `stream-${Date.now()}`
|
|
64
104
|
};
|
|
65
105
|
}
|
|
66
|
-
export function connectionPair() {
|
|
67
|
-
const [
|
|
106
|
+
export function connectionPair(a, b) {
|
|
107
|
+
const [peerBtoPeerA, peerAtoPeerB] = duplexPair();
|
|
68
108
|
return [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
// @ts-expect-error not a complete implementation
|
|
77
|
-
{
|
|
78
|
-
newStream: async (multicodecs) => await Promise.resolve({
|
|
79
|
-
stream: mockStream(d1),
|
|
80
|
-
protocol: multicodecs[0]
|
|
81
|
-
})
|
|
82
|
-
}
|
|
109
|
+
mockConnection(mockMultiaddrConnection(peerAtoPeerB, b.peerId), {
|
|
110
|
+
registrar: a.registrar
|
|
111
|
+
}),
|
|
112
|
+
mockConnection(mockMultiaddrConnection(peerBtoPeerA, a.peerId), {
|
|
113
|
+
registrar: b.registrar
|
|
114
|
+
})
|
|
83
115
|
];
|
|
84
116
|
}
|
|
85
117
|
//# sourceMappingURL=connection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/mocks/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/mocks/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAK3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,MAAM,GAAG,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAA;AAQ5C,MAAM,UAAU,cAAc,CAAE,MAA2B,EAAE,OAA8B,EAAE;IAC3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B,CACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MultiaddrConnection } from '@libp2p/interfaces/transport';
|
|
2
2
|
import type { Duplex } from 'it-stream-types';
|
|
3
|
-
|
|
3
|
+
import type { PeerId } from '@libp2p/interfaces/peer-id';
|
|
4
|
+
export declare function mockMultiaddrConnection(source: Duplex<Uint8Array> & Partial<MultiaddrConnection>, peerId: PeerId): MultiaddrConnection;
|
|
4
5
|
//# sourceMappingURL=multiaddr-connection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiaddr-connection.d.ts","sourceRoot":"","sources":["../../../src/mocks/multiaddr-connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"multiaddr-connection.d.ts","sourceRoot":"","sources":["../../../src/mocks/multiaddr-connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAExD,wBAAgB,uBAAuB,CAAE,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAavI"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Multiaddr } from '@multiformats/multiaddr';
|
|
2
|
-
export function mockMultiaddrConnection(source) {
|
|
2
|
+
export function mockMultiaddrConnection(source, peerId) {
|
|
3
3
|
const maConn = {
|
|
4
4
|
async close() {
|
|
5
5
|
},
|
|
6
6
|
timeline: {
|
|
7
7
|
open: Date.now()
|
|
8
8
|
},
|
|
9
|
-
remoteAddr: new Multiaddr(
|
|
9
|
+
remoteAddr: new Multiaddr(`/ip4/127.0.0.1/tcp/4001/p2p/${peerId.toString()}`),
|
|
10
10
|
...source
|
|
11
11
|
};
|
|
12
12
|
return maConn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiaddr-connection.js","sourceRoot":"","sources":["../../../src/mocks/multiaddr-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"multiaddr-connection.js","sourceRoot":"","sources":["../../../src/mocks/multiaddr-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAKnD,MAAM,UAAU,uBAAuB,CAAE,MAAyD,EAAE,MAAc;IAChH,MAAM,MAAM,GAAwB;QAClC,KAAK,CAAC,KAAK;QAEX,CAAC;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;SACjB;QACD,UAAU,EAAE,IAAI,SAAS,CAAC,+BAA+B,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;QAC7E,GAAG,MAAM;KACV,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Muxer } from '@libp2p/interfaces/stream-muxer';
|
|
2
|
-
export declare function mockMuxer(): Muxer;
|
|
1
|
+
import type { Muxer, MuxerOptions } from '@libp2p/interfaces/stream-muxer';
|
|
2
|
+
export declare function mockMuxer(options?: MuxerOptions): Muxer;
|
|
3
3
|
//# sourceMappingURL=muxer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"muxer.d.ts","sourceRoot":"","sources":["../../../src/mocks/muxer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"muxer.d.ts","sourceRoot":"","sources":["../../../src/mocks/muxer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAwI1E,wBAAgB,SAAS,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,KAAK,CAuGxD"}
|
package/dist/src/mocks/muxer.js
CHANGED
|
@@ -1,35 +1,184 @@
|
|
|
1
|
-
import { pair } from 'it-pair';
|
|
2
1
|
import { pushable } from 'it-pushable';
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
3
|
+
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
4
|
+
import { abortableSource } from 'abortable-iterator';
|
|
5
|
+
class MuxedStream {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
const { id, push, onEnd } = opts;
|
|
8
|
+
this.id = id;
|
|
9
|
+
this.controller = new AbortController();
|
|
10
|
+
this.onEnd = onEnd;
|
|
11
|
+
this.sourceClosed = false;
|
|
12
|
+
this.sinkClosed = false;
|
|
13
|
+
this.input = pushable({
|
|
14
|
+
onEnd: () => {
|
|
15
|
+
this.sourceClosed = true;
|
|
16
|
+
this.maybeEndStream();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
this.stream = {
|
|
20
|
+
id,
|
|
21
|
+
sink: async (source) => {
|
|
22
|
+
source = abortableSource(source, this.controller.signal);
|
|
23
|
+
try {
|
|
24
|
+
for await (const chunk of source) {
|
|
25
|
+
const dataMsg = {
|
|
26
|
+
id,
|
|
27
|
+
type: 'data',
|
|
28
|
+
chunk: uint8ArrayToString(chunk, 'base64')
|
|
29
|
+
};
|
|
30
|
+
push.push(dataMsg);
|
|
31
|
+
}
|
|
32
|
+
const closeMsg = {
|
|
33
|
+
id,
|
|
34
|
+
type: 'close'
|
|
35
|
+
};
|
|
36
|
+
push.push(closeMsg);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
if (!this.controller.signal.aborted) {
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
this.closeSink();
|
|
44
|
+
},
|
|
45
|
+
source: this.input,
|
|
46
|
+
close: () => {
|
|
47
|
+
const closeMsg = {
|
|
48
|
+
id,
|
|
49
|
+
type: 'close'
|
|
50
|
+
};
|
|
51
|
+
push.push(closeMsg);
|
|
52
|
+
this.closeSink();
|
|
53
|
+
this.closeSource();
|
|
54
|
+
},
|
|
55
|
+
abort: () => {
|
|
56
|
+
const resetMsg = {
|
|
57
|
+
id,
|
|
58
|
+
type: 'reset'
|
|
59
|
+
};
|
|
60
|
+
push.push(resetMsg);
|
|
61
|
+
this.closeSink();
|
|
62
|
+
this.closeSource();
|
|
63
|
+
},
|
|
64
|
+
reset: () => {
|
|
65
|
+
const resetMsg = {
|
|
66
|
+
id,
|
|
67
|
+
type: 'reset'
|
|
68
|
+
};
|
|
69
|
+
push.push(resetMsg);
|
|
70
|
+
this.closeSink();
|
|
71
|
+
this.closeSource();
|
|
72
|
+
},
|
|
73
|
+
timeline: {
|
|
74
|
+
open: Date.now()
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
maybeEndStream() {
|
|
79
|
+
if (this.stream.timeline.close != null) {
|
|
80
|
+
// already ended
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (this.sinkClosed && this.sourceClosed) {
|
|
84
|
+
this.stream.timeline.close = Date.now();
|
|
85
|
+
this.onEnd();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
closeSource() {
|
|
89
|
+
this.sourceClosed = true;
|
|
90
|
+
this.input.end();
|
|
91
|
+
}
|
|
92
|
+
closeSink() {
|
|
93
|
+
this.sinkClosed = true;
|
|
94
|
+
this.controller.abort();
|
|
95
|
+
this.maybeEndStream();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export function mockMuxer(options) {
|
|
5
99
|
let streamId = 0;
|
|
6
|
-
|
|
7
|
-
|
|
100
|
+
const streams = new Map();
|
|
101
|
+
// process incoming messages from the other muxer
|
|
102
|
+
const muxerSource = pushable({
|
|
103
|
+
onEnd: () => {
|
|
104
|
+
for (const muxedStream of streams.values()) {
|
|
105
|
+
muxedStream.stream.close();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
// receives messages from all of the muxed streams
|
|
110
|
+
const push = pushable();
|
|
111
|
+
void Promise.resolve().then(async () => {
|
|
112
|
+
for await (const message of push) {
|
|
113
|
+
if (message.type === 'data') {
|
|
114
|
+
muxerSource.push(uint8ArrayFromString(JSON.stringify({
|
|
115
|
+
id: message.id,
|
|
116
|
+
type: message.type,
|
|
117
|
+
chunk: message.chunk
|
|
118
|
+
})));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
muxerSource.push(uint8ArrayFromString(JSON.stringify({
|
|
122
|
+
id: message.id,
|
|
123
|
+
type: message.type
|
|
124
|
+
})));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
function createStream(name) {
|
|
129
|
+
const id = name ?? `${streamId++}`;
|
|
130
|
+
const muxedStream = new MuxedStream({
|
|
131
|
+
id,
|
|
132
|
+
push,
|
|
133
|
+
onEnd: () => {
|
|
134
|
+
streams.delete(id);
|
|
135
|
+
if (options?.onStreamEnd != null) {
|
|
136
|
+
options?.onStreamEnd(muxedStream.stream);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
return muxedStream;
|
|
141
|
+
}
|
|
8
142
|
const muxer = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
await
|
|
143
|
+
// receive incoming messages
|
|
144
|
+
async sink(source) {
|
|
145
|
+
for await (const buf of source) {
|
|
146
|
+
const message = JSON.parse(uint8ArrayToString(buf));
|
|
147
|
+
let muxedStream = streams.get(message.id);
|
|
148
|
+
if (muxedStream == null) {
|
|
149
|
+
muxedStream = createStream(message.id);
|
|
150
|
+
streams.set(muxedStream.stream.id, muxedStream);
|
|
151
|
+
if (options?.onStream != null) {
|
|
152
|
+
options.onStream(muxedStream.stream);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (message.type === 'data') {
|
|
156
|
+
muxedStream.input.push(uint8ArrayFromString(message.chunk, 'base64'));
|
|
157
|
+
}
|
|
158
|
+
else if (message.type === 'reset') {
|
|
159
|
+
muxedStream.closeSink();
|
|
160
|
+
muxedStream.closeSource();
|
|
161
|
+
}
|
|
162
|
+
else if (message.type === 'close') {
|
|
163
|
+
muxedStream.closeSource();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
for (const muxedStream of streams.values()) {
|
|
167
|
+
muxedStream.stream.close();
|
|
168
|
+
}
|
|
169
|
+
muxerSource.end();
|
|
12
170
|
},
|
|
171
|
+
source: muxerSource,
|
|
13
172
|
get streams() {
|
|
14
|
-
return streams;
|
|
173
|
+
return Array.from(streams.values()).map(({ stream }) => stream);
|
|
15
174
|
},
|
|
16
|
-
newStream
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
close: () => {
|
|
24
|
-
streams = streams.filter(s => s !== stream);
|
|
25
|
-
},
|
|
26
|
-
abort: () => { },
|
|
27
|
-
reset: () => { },
|
|
28
|
-
timeline: {
|
|
29
|
-
open: 0
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
return stream;
|
|
175
|
+
newStream(name) {
|
|
176
|
+
const storedStream = createStream(name);
|
|
177
|
+
streams.set(storedStream.stream.id, storedStream);
|
|
178
|
+
if (options?.onStream != null) {
|
|
179
|
+
options.onStream(storedStream.stream);
|
|
180
|
+
}
|
|
181
|
+
return storedStream.stream;
|
|
33
182
|
}
|
|
34
183
|
};
|
|
35
184
|
return muxer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"muxer.js","sourceRoot":"","sources":["../../../src/mocks/muxer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
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,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import type { Registrar, StreamHandler } from '@libp2p/interfaces/registrar';
|
|
1
|
+
import type { IncomingStreamData, Registrar, StreamHandler } from '@libp2p/interfaces/registrar';
|
|
2
|
+
import type { Connection } from '@libp2p/interfaces/src/connection';
|
|
3
|
+
import type { PeerId } from '@libp2p/interfaces/src/peer-id';
|
|
2
4
|
import type { Topology } from '@libp2p/interfaces/topology';
|
|
3
5
|
export declare class MockRegistrar implements Registrar {
|
|
4
6
|
private readonly topologies;
|
|
5
7
|
private readonly handlers;
|
|
8
|
+
getProtocols(): string[];
|
|
6
9
|
handle(protocols: string | string[], handler: StreamHandler): Promise<string>;
|
|
7
10
|
unhandle(id: string): Promise<void>;
|
|
8
|
-
|
|
11
|
+
getHandler(protocol: string): StreamHandler;
|
|
9
12
|
register(protocols: string | string[], topology: Topology): string;
|
|
10
13
|
unregister(id: string | string[]): void;
|
|
11
14
|
getTopologies(protocol: string): Topology[];
|
|
12
15
|
}
|
|
13
16
|
export declare function mockRegistrar(): MockRegistrar;
|
|
17
|
+
export declare function mockIncomingStreamEvent(protocol: string, conn: Connection, remotePeer: PeerId): Promise<CustomEvent<IncomingStreamData>>;
|
|
18
|
+
export interface Peer {
|
|
19
|
+
peerId: PeerId;
|
|
20
|
+
registrar: Registrar;
|
|
21
|
+
}
|
|
22
|
+
export declare function connectPeers(protocol: string, a: Peer, b: Peer): Promise<void>;
|
|
14
23
|
//# sourceMappingURL=registrar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registrar.d.ts","sourceRoot":"","sources":["../../../src/mocks/registrar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"registrar.d.ts","sourceRoot":"","sources":["../../../src/mocks/registrar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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
5
|
this.topologies = new Map();
|
|
4
6
|
this.handlers = new Map();
|
|
5
7
|
}
|
|
8
|
+
getProtocols() {
|
|
9
|
+
const protocols = new Set();
|
|
10
|
+
for (const topology of this.topologies.values()) {
|
|
11
|
+
topology.protocols.forEach(protocol => protocols.add(protocol));
|
|
12
|
+
}
|
|
13
|
+
for (const handler of this.handlers.values()) {
|
|
14
|
+
handler.protocols.forEach(protocol => protocols.add(protocol));
|
|
15
|
+
}
|
|
16
|
+
return Array.from(protocols).sort();
|
|
17
|
+
}
|
|
6
18
|
async handle(protocols, handler) {
|
|
7
19
|
if (!Array.isArray(protocols)) {
|
|
8
20
|
protocols = [protocols];
|
|
9
21
|
}
|
|
22
|
+
for (const protocol of protocols) {
|
|
23
|
+
for (const { protocols } of this.handlers.values()) {
|
|
24
|
+
if (protocols.includes(protocol)) {
|
|
25
|
+
throw new Error(`Handler already registered for protocol ${protocol}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
10
29
|
const id = `handler-id-${Math.random()}`;
|
|
11
30
|
this.handlers.set(id, {
|
|
12
31
|
handler,
|
|
@@ -17,14 +36,13 @@ export class MockRegistrar {
|
|
|
17
36
|
async unhandle(id) {
|
|
18
37
|
this.handlers.delete(id);
|
|
19
38
|
}
|
|
20
|
-
|
|
21
|
-
const output = [];
|
|
39
|
+
getHandler(protocol) {
|
|
22
40
|
for (const { handler, protocols } of this.handlers.values()) {
|
|
23
41
|
if (protocols.includes(protocol)) {
|
|
24
|
-
|
|
42
|
+
return handler;
|
|
25
43
|
}
|
|
26
44
|
}
|
|
27
|
-
|
|
45
|
+
throw new Error(`No handler registered for protocol ${protocol}`);
|
|
28
46
|
}
|
|
29
47
|
register(protocols, topology) {
|
|
30
48
|
if (!Array.isArray(protocols)) {
|
|
@@ -50,10 +68,34 @@ export class MockRegistrar {
|
|
|
50
68
|
output.push(topology);
|
|
51
69
|
}
|
|
52
70
|
}
|
|
53
|
-
|
|
71
|
+
if (output.length > 0) {
|
|
72
|
+
return output;
|
|
73
|
+
}
|
|
74
|
+
throw new Error(`No topologies registered for protocol ${protocol}`);
|
|
54
75
|
}
|
|
55
76
|
}
|
|
56
77
|
export function mockRegistrar() {
|
|
57
78
|
return new MockRegistrar();
|
|
58
79
|
}
|
|
80
|
+
export async function mockIncomingStreamEvent(protocol, conn, remotePeer) {
|
|
81
|
+
// @ts-expect-error incomplete implementation
|
|
82
|
+
return new CustomEvent('incomingStream', {
|
|
83
|
+
detail: {
|
|
84
|
+
...await conn.newStream([protocol]),
|
|
85
|
+
connection: {
|
|
86
|
+
remotePeer
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export async function connectPeers(protocol, a, b) {
|
|
92
|
+
// Notify peers of connection
|
|
93
|
+
const [aToB, bToA] = connectionPair(a, b);
|
|
94
|
+
for (const topology of a.registrar.getTopologies(protocol)) {
|
|
95
|
+
await topology.onConnect(b.peerId, aToB);
|
|
96
|
+
}
|
|
97
|
+
for (const topology of b.registrar.getTopologies(protocol)) {
|
|
98
|
+
await topology.onConnect(a.peerId, bToA);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
59
101
|
//# sourceMappingURL=registrar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registrar.js","sourceRoot":"","sources":["../../../src/mocks/registrar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registrar.js","sourceRoot":"","sources":["../../../src/mocks/registrar.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,MAAM,OAAO,aAAa;IAA1B;QACmB,eAAU,GAA6D,IAAI,GAAG,EAAE,CAAA;QAChF,aAAQ,GAAiE,IAAI,GAAG,EAAE,CAAA;IA2FrG,CAAC;IAzFC,YAAY;QACV,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU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d;QAED,MAAM,IAAI,KAAK,CAAC,yCAAyC,QAAQ,EAAE,CAAC,CAAA;IACtE,CAAC;CACF;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,aAAa,EAAE,CAAA;AAC5B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAE,QAAgB,EAAE,IAAgB,EAAE,UAAkB;IACnG,6CAA6C;IAC7C,OAAO,IAAI,WAAW,CAAC,gBAAgB,EAAE;QACvC,MAAM,EAAE;YACN,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;YACnC,UAAU,EAAE;gBACV,UAAU;aACX;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAOD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAE,QAAgB,EAAE,CAAO,EAAE,CAAO;IACpE,6BAA6B;IAC7B,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAEzC,KAAK,MAAM,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QAC1D,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;KACzC;IAED,KAAK,MAAM,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QAC1D,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;KACzC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrader.d.ts","sourceRoot":"","sources":["../../../src/mocks/upgrader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upgrader.d.ts","sourceRoot":"","sources":["../../../src/mocks/upgrader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAuB,MAAM,8BAA8B,CAAA;AACjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAE5D,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,wBAAgB,YAAY,CAAE,OAAO,GAAE,mBAAwB,YA0B9D"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { expect } from 'aegir/utils/chai.js';
|
|
2
|
-
import { mockMuxer } from './muxer.js';
|
|
3
2
|
import { mockConnection } from './connection.js';
|
|
4
3
|
export function mockUpgrader(options = {}) {
|
|
5
4
|
const ensureProps = (multiaddrConnection) => {
|
|
@@ -8,15 +7,20 @@ export function mockUpgrader(options = {}) {
|
|
|
8
7
|
});
|
|
9
8
|
return multiaddrConnection;
|
|
10
9
|
};
|
|
11
|
-
const muxer = options.muxer ?? mockMuxer();
|
|
12
10
|
const upgrader = {
|
|
13
11
|
async upgradeOutbound(multiaddrConnection) {
|
|
14
12
|
ensureProps(multiaddrConnection);
|
|
15
|
-
return
|
|
13
|
+
return mockConnection(multiaddrConnection, {
|
|
14
|
+
direction: 'outbound',
|
|
15
|
+
muxer: options.muxer
|
|
16
|
+
});
|
|
16
17
|
},
|
|
17
18
|
async upgradeInbound(multiaddrConnection) {
|
|
18
19
|
ensureProps(multiaddrConnection);
|
|
19
|
-
return
|
|
20
|
+
return mockConnection(multiaddrConnection, {
|
|
21
|
+
direction: 'inbound',
|
|
22
|
+
muxer: options.muxer
|
|
23
|
+
});
|
|
20
24
|
}
|
|
21
25
|
};
|
|
22
26
|
return upgrader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrader.js","sourceRoot":"","sources":["../../../src/mocks/upgrader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"upgrader.js","sourceRoot":"","sources":["../../../src/mocks/upgrader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAQhD,MAAM,UAAU,YAAY,CAAE,UAA+B,EAAE;IAC7D,MAAM,WAAW,GAAG,CAAC,mBAAwC,EAAE,EAAE;QAC/D,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACnE,MAAM,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;QACF,OAAO,mBAAmB,CAAA;IAC5B,CAAC,CAAA;IAED,MAAM,QAAQ,GAAa;QACzB,KAAK,CAAC,eAAe,CAAE,mBAAmB;YACxC,WAAW,CAAC,mBAAmB,CAAC,CAAA;YAChC,OAAO,cAAc,CAAC,mBAAmB,EAAE;gBACzC,SAAS,EAAE,UAAU;gBACrB,KAAK,EAAE,OAAO,CAAC,KAAK;aACrB,CAAC,CAAA;QACJ,CAAC;QACD,KAAK,CAAC,cAAc,CAAE,mBAAmB;YACvC,WAAW,CAAC,mBAAmB,CAAC,CAAA;YAChC,OAAO,cAAc,CAAC,mBAAmB,EAAE;gBACzC,SAAS,EAAE,SAAS;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK;aACrB,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
package/dist/src/pubsub/api.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TestSetup } from '../index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PubSubOptions } from '@libp2p/interfaces/pubsub';
|
|
3
3
|
import type { EventMap } from './index.js';
|
|
4
|
-
|
|
4
|
+
import type { PubsubBaseProtocol } from '@libp2p/pubsub';
|
|
5
|
+
declare const _default: (common: TestSetup<PubsubBaseProtocol<EventMap>, PubSubOptions>) => void;
|
|
5
6
|
export default _default;
|
|
6
7
|
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/pubsub/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/pubsub/api.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAU,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;iCAKhC,UAAU,mBAAmB,QAAQ,CAAC,EAAE,aAAa,CAAC;AAA9E,wBAmFC"}
|