@libp2p/interface-compliance-tests 6.4.16 → 6.5.0-0f07e3df5

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.
Files changed (132) hide show
  1. package/dist/src/connection-encryption/index.d.ts.map +1 -1
  2. package/dist/src/connection-encryption/index.js +24 -15
  3. package/dist/src/connection-encryption/index.js.map +1 -1
  4. package/dist/src/stream-muxer/base-test.d.ts.map +1 -1
  5. package/dist/src/stream-muxer/base-test.js +62 -341
  6. package/dist/src/stream-muxer/base-test.js.map +1 -1
  7. package/dist/src/stream-muxer/close-test.d.ts.map +1 -1
  8. package/dist/src/stream-muxer/close-test.js +254 -305
  9. package/dist/src/stream-muxer/close-test.js.map +1 -1
  10. package/dist/src/stream-muxer/index.js +2 -2
  11. package/dist/src/stream-muxer/index.js.map +1 -1
  12. package/dist/src/stream-muxer/{mega-stress-test.d.ts → stream-test.d.ts} +2 -2
  13. package/dist/src/stream-muxer/stream-test.d.ts.map +1 -0
  14. package/dist/src/stream-muxer/stream-test.js +289 -0
  15. package/dist/src/stream-muxer/stream-test.js.map +1 -0
  16. package/dist/src/stream-muxer/stress-test.d.ts.map +1 -1
  17. package/dist/src/stream-muxer/stress-test.js +70 -16
  18. package/dist/src/stream-muxer/stress-test.js.map +1 -1
  19. package/dist/src/transport/index.d.ts.map +1 -1
  20. package/dist/src/transport/index.js +232 -203
  21. package/dist/src/transport/index.js.map +1 -1
  22. package/dist/src/transport/utils.js +2 -2
  23. package/dist/src/transport/utils.js.map +1 -1
  24. package/package.json +23 -51
  25. package/src/connection-encryption/index.ts +27 -20
  26. package/src/stream-muxer/base-test.ts +75 -409
  27. package/src/stream-muxer/close-test.ts +304 -327
  28. package/src/stream-muxer/index.ts +2 -2
  29. package/src/stream-muxer/stream-test.ts +380 -0
  30. package/src/stream-muxer/stress-test.ts +92 -18
  31. package/src/transport/index.ts +280 -241
  32. package/src/transport/utils.ts +2 -2
  33. package/dist/src/connection-encryption/utils/index.d.ts +0 -3
  34. package/dist/src/connection-encryption/utils/index.d.ts.map +0 -1
  35. package/dist/src/connection-encryption/utils/index.js +0 -21
  36. package/dist/src/connection-encryption/utils/index.js.map +0 -1
  37. package/dist/src/matchers.d.ts +0 -12
  38. package/dist/src/matchers.d.ts.map +0 -1
  39. package/dist/src/matchers.js +0 -14
  40. package/dist/src/matchers.js.map +0 -1
  41. package/dist/src/mocks/connection-manager.d.ts +0 -27
  42. package/dist/src/mocks/connection-manager.d.ts.map +0 -1
  43. package/dist/src/mocks/connection-manager.js +0 -147
  44. package/dist/src/mocks/connection-manager.js.map +0 -1
  45. package/dist/src/mocks/connection.d.ts +0 -41
  46. package/dist/src/mocks/connection.d.ts.map +0 -1
  47. package/dist/src/mocks/connection.js +0 -234
  48. package/dist/src/mocks/connection.js.map +0 -1
  49. package/dist/src/mocks/duplex.d.ts +0 -4
  50. package/dist/src/mocks/duplex.d.ts.map +0 -1
  51. package/dist/src/mocks/duplex.js +0 -9
  52. package/dist/src/mocks/duplex.js.map +0 -1
  53. package/dist/src/mocks/index.d.ts +0 -12
  54. package/dist/src/mocks/index.d.ts.map +0 -1
  55. package/dist/src/mocks/index.js +0 -8
  56. package/dist/src/mocks/index.js.map +0 -1
  57. package/dist/src/mocks/multiaddr-connection.d.ts +0 -17
  58. package/dist/src/mocks/multiaddr-connection.d.ts.map +0 -1
  59. package/dist/src/mocks/multiaddr-connection.js +0 -64
  60. package/dist/src/mocks/multiaddr-connection.js.map +0 -1
  61. package/dist/src/mocks/muxer.d.ts +0 -36
  62. package/dist/src/mocks/muxer.d.ts.map +0 -1
  63. package/dist/src/mocks/muxer.js +0 -234
  64. package/dist/src/mocks/muxer.js.map +0 -1
  65. package/dist/src/mocks/registrar.d.ts +0 -16
  66. package/dist/src/mocks/registrar.d.ts.map +0 -1
  67. package/dist/src/mocks/registrar.js +0 -66
  68. package/dist/src/mocks/registrar.js.map +0 -1
  69. package/dist/src/mocks/upgrader.d.ts +0 -9
  70. package/dist/src/mocks/upgrader.d.ts.map +0 -1
  71. package/dist/src/mocks/upgrader.js +0 -46
  72. package/dist/src/mocks/upgrader.js.map +0 -1
  73. package/dist/src/pubsub/api.d.ts +0 -6
  74. package/dist/src/pubsub/api.d.ts.map +0 -1
  75. package/dist/src/pubsub/api.js +0 -88
  76. package/dist/src/pubsub/api.js.map +0 -1
  77. package/dist/src/pubsub/connection-handlers.d.ts +0 -6
  78. package/dist/src/pubsub/connection-handlers.d.ts.map +0 -1
  79. package/dist/src/pubsub/connection-handlers.js +0 -329
  80. package/dist/src/pubsub/connection-handlers.js.map +0 -1
  81. package/dist/src/pubsub/emit-self.d.ts +0 -6
  82. package/dist/src/pubsub/emit-self.d.ts.map +0 -1
  83. package/dist/src/pubsub/emit-self.js +0 -80
  84. package/dist/src/pubsub/emit-self.js.map +0 -1
  85. package/dist/src/pubsub/index.d.ts +0 -18
  86. package/dist/src/pubsub/index.d.ts.map +0 -1
  87. package/dist/src/pubsub/index.js +0 -17
  88. package/dist/src/pubsub/index.js.map +0 -1
  89. package/dist/src/pubsub/messages.d.ts +0 -6
  90. package/dist/src/pubsub/messages.d.ts.map +0 -1
  91. package/dist/src/pubsub/messages.js +0 -48
  92. package/dist/src/pubsub/messages.js.map +0 -1
  93. package/dist/src/pubsub/multiple-nodes.d.ts +0 -6
  94. package/dist/src/pubsub/multiple-nodes.d.ts.map +0 -1
  95. package/dist/src/pubsub/multiple-nodes.js +0 -350
  96. package/dist/src/pubsub/multiple-nodes.js.map +0 -1
  97. package/dist/src/pubsub/two-nodes.d.ts +0 -6
  98. package/dist/src/pubsub/two-nodes.d.ts.map +0 -1
  99. package/dist/src/pubsub/two-nodes.js +0 -216
  100. package/dist/src/pubsub/two-nodes.js.map +0 -1
  101. package/dist/src/pubsub/utils.d.ts +0 -5
  102. package/dist/src/pubsub/utils.d.ts.map +0 -1
  103. package/dist/src/pubsub/utils.js +0 -27
  104. package/dist/src/pubsub/utils.js.map +0 -1
  105. package/dist/src/stream-muxer/mega-stress-test.d.ts.map +0 -1
  106. package/dist/src/stream-muxer/mega-stress-test.js +0 -11
  107. package/dist/src/stream-muxer/mega-stress-test.js.map +0 -1
  108. package/dist/src/stream-muxer/spawner.d.ts +0 -4
  109. package/dist/src/stream-muxer/spawner.d.ts.map +0 -1
  110. package/dist/src/stream-muxer/spawner.js +0 -37
  111. package/dist/src/stream-muxer/spawner.js.map +0 -1
  112. package/dist/typedoc-urls.json +0 -44
  113. package/src/connection-encryption/utils/index.ts +0 -27
  114. package/src/matchers.ts +0 -18
  115. package/src/mocks/connection-manager.ts +0 -216
  116. package/src/mocks/connection.ts +0 -307
  117. package/src/mocks/duplex.ts +0 -11
  118. package/src/mocks/index.ts +0 -11
  119. package/src/mocks/multiaddr-connection.ts +0 -80
  120. package/src/mocks/muxer.ts +0 -331
  121. package/src/mocks/registrar.ts +0 -86
  122. package/src/mocks/upgrader.ts +0 -65
  123. package/src/pubsub/api.ts +0 -116
  124. package/src/pubsub/connection-handlers.ts +0 -413
  125. package/src/pubsub/emit-self.ts +0 -99
  126. package/src/pubsub/index.ts +0 -34
  127. package/src/pubsub/messages.ts +0 -59
  128. package/src/pubsub/multiple-nodes.ts +0 -440
  129. package/src/pubsub/two-nodes.ts +0 -272
  130. package/src/pubsub/utils.ts +0 -34
  131. package/src/stream-muxer/mega-stress-test.ts +0 -14
  132. package/src/stream-muxer/spawner.ts +0 -55
@@ -1,17 +0,0 @@
1
- import type { MultiaddrConnection, PeerId } from '@libp2p/interface';
2
- import type { Multiaddr } from '@multiformats/multiaddr';
3
- import type { Duplex } from 'it-stream-types';
4
- import type { Uint8ArrayList } from 'uint8arraylist';
5
- export declare function mockMultiaddrConnection(source: Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> & Partial<MultiaddrConnection>, peerId: PeerId): MultiaddrConnection;
6
- export interface MockMultiaddrConnPairOptions {
7
- addrs: Multiaddr[];
8
- remotePeer: PeerId;
9
- }
10
- /**
11
- * Returns both sides of a mocked MultiaddrConnection
12
- */
13
- export declare function mockMultiaddrConnPair(opts: MockMultiaddrConnPairOptions): {
14
- inbound: MultiaddrConnection;
15
- outbound: MultiaddrConnection;
16
- };
17
- //# sourceMappingURL=multiaddr-connection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multiaddr-connection.d.ts","sourceRoot":"","sources":["../../../src/mocks/multiaddr-connection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,wBAAgB,uBAAuB,CAAE,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAexK;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAE,IAAI,EAAE,4BAA4B,GAAG;IAAE,OAAO,EAAE,mBAAmB,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAE,CA6C1I"}
@@ -1,64 +0,0 @@
1
- import { logger } from '@libp2p/logger';
2
- import { multiaddr } from '@multiformats/multiaddr';
3
- import { abortableSource } from 'abortable-iterator';
4
- import { duplexPair } from 'it-pair/duplex';
5
- export function mockMultiaddrConnection(source, peerId) {
6
- const maConn = {
7
- async close() {
8
- },
9
- abort: () => { },
10
- timeline: {
11
- open: Date.now()
12
- },
13
- remoteAddr: multiaddr(`/ip4/127.0.0.1/tcp/4001/p2p/${peerId.toString()}`),
14
- log: logger('mock-maconn'),
15
- ...source
16
- };
17
- return maConn;
18
- }
19
- /**
20
- * Returns both sides of a mocked MultiaddrConnection
21
- */
22
- export function mockMultiaddrConnPair(opts) {
23
- const { addrs, remotePeer } = opts;
24
- const controller = new AbortController();
25
- const [localAddr, remoteAddr] = addrs;
26
- const [inboundStream, outboundStream] = duplexPair();
27
- const outbound = {
28
- ...outboundStream,
29
- remoteAddr: remoteAddr.toString().includes(`/p2p/${remotePeer.toString()}`) ? remoteAddr : remoteAddr.encapsulate(`/p2p/${remotePeer.toString()}`),
30
- timeline: {
31
- open: Date.now()
32
- },
33
- close: async () => {
34
- outbound.timeline.close = Date.now();
35
- controller.abort();
36
- },
37
- abort: (err) => {
38
- outbound.timeline.close = Date.now();
39
- controller.abort(err);
40
- },
41
- log: logger('mock-maconn-outbound')
42
- };
43
- const inbound = {
44
- ...inboundStream,
45
- remoteAddr: localAddr,
46
- timeline: {
47
- open: Date.now()
48
- },
49
- close: async () => {
50
- inbound.timeline.close = Date.now();
51
- controller.abort();
52
- },
53
- abort: (err) => {
54
- outbound.timeline.close = Date.now();
55
- controller.abort(err);
56
- },
57
- log: logger('mock-maconn-inbound')
58
- };
59
- // Make the sources abortable so we can close them easily
60
- inbound.source = abortableSource(inbound.source, controller.signal);
61
- outbound.source = abortableSource(outbound.source, controller.signal);
62
- return { inbound, outbound };
63
- }
64
- //# sourceMappingURL=multiaddr-connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multiaddr-connection.js","sourceRoot":"","sources":["../../../src/mocks/multiaddr-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAM3C,MAAM,UAAU,uBAAuB,CAAE,MAA0F,EAAE,MAAc;IACjJ,MAAM,MAAM,GAAw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C,KAAK,CAAC,GAAG,CAAC,CAAA;QACvB,CAAC;QACD,GAAG,EAAE,MAAM,CAAC,sBAAsB,CAAC;KACpC,CAAA;IAED,MAAM,OAAO,GAAwB;QACnC,GAAG,aAAa;QAChB,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE;YACR,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;SACjB;QACD,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,OAAO,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YACnC,UAAU,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;QACD,KAAK,EAAE,CAAC,GAAU,EAAE,EAAE;YACpB,QAAQ,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YACpC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACvB,CAAC;QACD,GAAG,EAAE,MAAM,CAAC,qBAAqB,CAAC;KACnC,CAAA;IAED,yDAAyD;IACzD,OAAO,CAAC,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;IACnE,QAAQ,CAAC,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;IAErE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAA;AAC9B,CAAC"}
@@ -1,36 +0,0 @@
1
- import type { Direction, StreamMuxerFactory } from '@libp2p/interface';
2
- import type { AbstractStreamInit } from '@libp2p/utils/abstract-stream';
3
- import type { Pushable } from 'it-pushable';
4
- interface DataMessage {
5
- id: string;
6
- type: 'data';
7
- direction: Direction;
8
- chunk: string;
9
- }
10
- interface ResetMessage {
11
- id: string;
12
- type: 'reset';
13
- direction: Direction;
14
- }
15
- interface CloseWriteMessage {
16
- id: string;
17
- type: 'closeWrite';
18
- direction: Direction;
19
- }
20
- interface CloseReadMessage {
21
- id: string;
22
- type: 'closeRead';
23
- direction: Direction;
24
- }
25
- interface CreateMessage {
26
- id: string;
27
- type: 'create';
28
- direction: 'outbound';
29
- }
30
- type StreamMessage = DataMessage | ResetMessage | CloseWriteMessage | CloseReadMessage | CreateMessage;
31
- export interface MockMuxedStreamInit extends AbstractStreamInit {
32
- push: Pushable<StreamMessage>;
33
- }
34
- export declare function mockMuxer(): StreamMuxerFactory;
35
- export {};
36
- //# sourceMappingURL=muxer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"muxer.d.ts","sourceRoot":"","sources":["../../../src/mocks/muxer.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAgB,SAAS,EAAuB,kBAAkB,EAAmB,MAAM,mBAAmB,CAAA;AAE1H,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAM3C,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,SAAS,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,OAAO,CAAA;IACb,SAAS,EAAE,SAAS,CAAA;CACrB;AAED,UAAU,iBAAiB;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,YAAY,CAAA;IAClB,SAAS,EAAE,SAAS,CAAA;CACrB;AAED,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,WAAW,CAAA;IACjB,SAAS,EAAE,SAAS,CAAA;CACrB;AAED,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,QAAQ,CAAA;IACd,SAAS,EAAE,UAAU,CAAA;CACtB;AAED,KAAK,aAAa,GAAG,WAAW,GAAG,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,aAAa,CAAA;AAEtG,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,IAAI,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAA;CAC9B;AAkRD,wBAAgB,SAAS,IAAK,kBAAkB,CAE/C"}
@@ -1,234 +0,0 @@
1
- import { logger } from '@libp2p/logger';
2
- import { AbstractStream } from '@libp2p/utils/abstract-stream';
3
- import { abortableSource } from 'abortable-iterator';
4
- import map from 'it-map';
5
- import * as ndjson from 'it-ndjson';
6
- import { pipe } from 'it-pipe';
7
- import { pushable } from 'it-pushable';
8
- import { Uint8ArrayList } from 'uint8arraylist';
9
- import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
10
- import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
11
- let muxers = 0;
12
- let streams = 0;
13
- class MuxedStream extends AbstractStream {
14
- push;
15
- constructor(init) {
16
- super(init);
17
- this.push = init.push;
18
- }
19
- sendNewStream() {
20
- // If initiator, open a new stream
21
- const createMsg = {
22
- id: this.id,
23
- type: 'create',
24
- direction: 'outbound'
25
- };
26
- this.push.push(createMsg);
27
- }
28
- sendData(data) {
29
- const dataMsg = {
30
- id: this.id,
31
- type: 'data',
32
- chunk: uint8ArrayToString(data.subarray(), 'base64pad'),
33
- direction: this.direction
34
- };
35
- this.push.push(dataMsg);
36
- }
37
- sendReset() {
38
- const resetMsg = {
39
- id: this.id,
40
- type: 'reset',
41
- direction: this.direction
42
- };
43
- this.push.push(resetMsg);
44
- }
45
- sendCloseWrite() {
46
- const closeMsg = {
47
- id: this.id,
48
- type: 'closeWrite',
49
- direction: this.direction
50
- };
51
- this.push.push(closeMsg);
52
- }
53
- sendCloseRead() {
54
- const closeMsg = {
55
- id: this.id,
56
- type: 'closeRead',
57
- direction: this.direction
58
- };
59
- this.push.push(closeMsg);
60
- }
61
- }
62
- class MockMuxer {
63
- source;
64
- input;
65
- streamInput;
66
- name;
67
- protocol = '/mock-muxer/1.0.0';
68
- closeController;
69
- registryInitiatorStreams;
70
- registryRecipientStreams;
71
- options;
72
- log;
73
- constructor(init) {
74
- this.name = `muxer:${muxers++}`;
75
- this.log = logger(`libp2p:mock-muxer:${this.name}`);
76
- this.registryInitiatorStreams = new Map();
77
- this.registryRecipientStreams = new Map();
78
- this.log('create muxer');
79
- this.options = init ?? { direction: 'inbound' };
80
- this.closeController = new AbortController();
81
- // receives data from the muxer at the other end of the stream
82
- this.source = this.input = pushable({
83
- onEnd: () => {
84
- for (const stream of this.registryInitiatorStreams.values()) {
85
- stream.destroy();
86
- }
87
- for (const stream of this.registryRecipientStreams.values()) {
88
- stream.destroy();
89
- }
90
- }
91
- });
92
- // receives messages from all of the muxed streams
93
- this.streamInput = pushable({
94
- objectMode: true
95
- });
96
- }
97
- // receive incoming messages
98
- async sink(source) {
99
- try {
100
- await pipe(abortableSource(source, this.closeController.signal), (source) => map(source, buf => uint8ArrayToString(buf.subarray())), (ndjson.parse), async (source) => {
101
- for await (const message of source) {
102
- this.log.trace('-> %s %s %s', message.type, message.direction, message.id);
103
- this.handleMessage(message);
104
- }
105
- });
106
- this.log('muxer ended');
107
- this.input.end();
108
- }
109
- catch (err) {
110
- this.log.error('muxer errored - %e', err);
111
- this.input.end(err);
112
- }
113
- }
114
- handleMessage(message) {
115
- let muxedStream;
116
- const registry = message.direction === 'outbound' ? this.registryRecipientStreams : this.registryInitiatorStreams;
117
- if (message.type === 'create') {
118
- if (registry.has(message.id)) {
119
- throw new Error(`Already had stream for ${message.id}`);
120
- }
121
- muxedStream = this.createStream(message.id, 'inbound');
122
- registry.set(muxedStream.id, muxedStream);
123
- if (this.options.onIncomingStream != null) {
124
- this.options.onIncomingStream(muxedStream);
125
- }
126
- }
127
- muxedStream = registry.get(message.id);
128
- if (muxedStream == null) {
129
- this.log.error(`No stream found for ${message.id}`);
130
- return;
131
- }
132
- if (message.type === 'data') {
133
- muxedStream.sourcePush(new Uint8ArrayList(uint8ArrayFromString(message.chunk, 'base64pad')));
134
- }
135
- else if (message.type === 'reset') {
136
- this.log('-> reset stream %s %s', muxedStream.direction, muxedStream.id);
137
- muxedStream.reset();
138
- }
139
- else if (message.type === 'closeWrite') {
140
- this.log('-> closing writeable end of stream %s %s', muxedStream.direction, muxedStream.id);
141
- muxedStream.remoteCloseWrite();
142
- }
143
- else if (message.type === 'closeRead') {
144
- this.log('-> closing readable end of stream %s %s', muxedStream.direction, muxedStream.id);
145
- muxedStream.remoteCloseRead();
146
- }
147
- }
148
- get streams() {
149
- return Array.from(this.registryRecipientStreams.values())
150
- .concat(Array.from(this.registryInitiatorStreams.values()));
151
- }
152
- newStream(name) {
153
- if (this.closeController.signal.aborted) {
154
- throw new Error('Muxer already closed');
155
- }
156
- this.log('newStream %s', name);
157
- const storedStream = this.createStream(name, 'outbound');
158
- this.registryInitiatorStreams.set(storedStream.id, storedStream);
159
- return storedStream;
160
- }
161
- createStream(name, direction = 'outbound') {
162
- const id = name ?? `${streams++}`;
163
- this.log('createStream %s %s', direction, id);
164
- const muxedStream = new MuxedStream({
165
- id,
166
- direction,
167
- push: this.streamInput,
168
- onEnd: () => {
169
- this.log('stream ended');
170
- if (direction === 'outbound') {
171
- this.registryInitiatorStreams.delete(muxedStream.id);
172
- }
173
- else {
174
- this.registryRecipientStreams.delete(muxedStream.id);
175
- }
176
- if (this.options.onStreamEnd != null) {
177
- this.options.onStreamEnd(muxedStream);
178
- }
179
- },
180
- log: logger(`libp2p:mock-muxer:stream:${direction}:${id}`)
181
- });
182
- return muxedStream;
183
- }
184
- async close(options) {
185
- if (this.closeController.signal.aborted) {
186
- return;
187
- }
188
- const signal = options?.signal ?? AbortSignal.timeout(10);
189
- try {
190
- // try to gracefully close all streams
191
- await Promise.all(this.streams.map(async (s) => s.close({
192
- signal
193
- })));
194
- this.input.end();
195
- // try to gracefully close the muxer
196
- await this.input.onEmpty({
197
- signal
198
- });
199
- this.closeController.abort();
200
- }
201
- catch (err) {
202
- this.abort(err);
203
- }
204
- }
205
- abort(err) {
206
- if (this.closeController.signal.aborted) {
207
- return;
208
- }
209
- this.log('aborting muxed streams');
210
- this.streams.forEach(s => {
211
- s.abort(err);
212
- });
213
- this.closeController.abort(err);
214
- this.input.end(err);
215
- }
216
- }
217
- class MockMuxerFactory {
218
- protocol = '/mock-muxer/1.0.0';
219
- createStreamMuxer(init) {
220
- const mockMuxer = new MockMuxer(init);
221
- void Promise.resolve().then(async () => {
222
- void pipe(mockMuxer.streamInput, ndjson.stringify, (source) => map(source, str => new Uint8ArrayList(uint8ArrayFromString(str))), async (source) => {
223
- for await (const buf of source) {
224
- mockMuxer.input.push(buf.subarray());
225
- }
226
- });
227
- });
228
- return mockMuxer;
229
- }
230
- }
231
- export function mockMuxer() {
232
- return new MockMuxerFactory();
233
- }
234
- //# sourceMappingURL=muxer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"muxer.js","sourceRoot":"","sources":["../../../src/mocks/muxer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,KAAK,MAAM,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAOtE,IAAI,MAAM,GAAG,CAAC,CAAA;AACd,IAAI,OAAO,GAAG,CAAC,CAAA;AAuCf,MAAM,WAAY,SAAQ,cAAc;IACrB,IAAI,CAAyB;IAE9C,YAAa,IAAy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1,16 +0,0 @@
1
- import type { Connection, PeerId, Topology, IncomingStreamData, StreamHandler, StreamHandlerOptions, StreamHandlerRecord } from '@libp2p/interface';
2
- import type { Registrar } from '@libp2p/interface-internal';
3
- export declare class MockRegistrar implements Registrar {
4
- private readonly topologies;
5
- private readonly handlers;
6
- getProtocols(): string[];
7
- handle(protocol: string, handler: StreamHandler, opts?: StreamHandlerOptions): Promise<void>;
8
- unhandle(protocol: string): Promise<void>;
9
- getHandler(protocol: string): StreamHandlerRecord;
10
- register(protocol: string, topology: Topology): Promise<string>;
11
- unregister(id: string | string[]): void;
12
- getTopologies(protocol: string): Topology[];
13
- }
14
- export declare function mockRegistrar(): Registrar;
15
- export declare function mockIncomingStreamEvent(protocol: string, conn: Connection, remotePeer: PeerId): Promise<IncomingStreamData>;
16
- //# sourceMappingURL=registrar.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registrar.d.ts","sourceRoot":"","sources":["../../../src/mocks/registrar.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACnJ,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE3D,qBAAa,aAAc,YAAW,SAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+D;IAC1F,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyC;IAElE,YAAY,IAAK,MAAM,EAAE;IAInB,MAAM,CAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB7F,QAAQ,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,UAAU,CAAE,QAAQ,EAAE,MAAM,GAAG,mBAAmB;IAU5C,QAAQ,CAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBtE,UAAU,CAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAQxC,aAAa,CAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE;CAG7C;AAED,wBAAgB,aAAa,IAAK,SAAS,CAE1C;AAED,wBAAsB,uBAAuB,CAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAQlI"}
@@ -1,66 +0,0 @@
1
- import { mergeOptions } from '@libp2p/utils/merge-options';
2
- export class MockRegistrar {
3
- topologies = new Map();
4
- handlers = new Map();
5
- getProtocols() {
6
- return Array.from(this.handlers.keys()).sort();
7
- }
8
- async handle(protocol, handler, opts) {
9
- const options = mergeOptions.bind({ ignoreUndefined: true })({
10
- maxInboundStreams: 1,
11
- maxOutboundStreams: 1
12
- }, opts);
13
- if (this.handlers.has(protocol)) {
14
- throw new Error(`Handler already registered for protocol ${protocol}`);
15
- }
16
- this.handlers.set(protocol, {
17
- handler,
18
- options
19
- });
20
- }
21
- async unhandle(protocol) {
22
- this.handlers.delete(protocol);
23
- }
24
- getHandler(protocol) {
25
- const handler = this.handlers.get(protocol);
26
- if (handler == null) {
27
- throw new Error(`No handler registered for protocol ${protocol}`);
28
- }
29
- return handler;
30
- }
31
- async register(protocol, topology) {
32
- const id = `topology-id-${Math.random()}`;
33
- let topologies = this.topologies.get(protocol);
34
- if (topologies == null) {
35
- topologies = [];
36
- }
37
- topologies.push({
38
- id,
39
- topology
40
- });
41
- this.topologies.set(protocol, topologies);
42
- return id;
43
- }
44
- unregister(id) {
45
- if (!Array.isArray(id)) {
46
- id = [id];
47
- }
48
- id.forEach(id => this.topologies.delete(id));
49
- }
50
- getTopologies(protocol) {
51
- return (this.topologies.get(protocol) ?? []).map(t => t.topology);
52
- }
53
- }
54
- export function mockRegistrar() {
55
- return new MockRegistrar();
56
- }
57
- export async function mockIncomingStreamEvent(protocol, conn, remotePeer) {
58
- return {
59
- ...await conn.newStream([protocol]),
60
- // @ts-expect-error incomplete implementation
61
- connection: {
62
- remotePeer
63
- }
64
- };
65
- }
66
- //# sourceMappingURL=registrar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registrar.js","sourceRoot":"","sources":["../../../src/mocks/registrar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAI1D,MAAM,OAAO,aAAa;IACP,UAAU,GAAG,IAAI,GAAG,EAAqD,CAAA;IACzE,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAA;IAElE,YAAY;QACV,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAChD,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,QAAgB,EAAE,OAAsB,EAAE,IAA2B;QACjF,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3D,iBAAiB,EAAE,CAAC;YACpB,kBAAkB,EAAE,CAAC;SACtB,EAAE,IAAI,CAAC,CAAA;QAER,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,2CAA2C,QAAQ,EAAE,CAAC,CAAA;QACxE,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC1B,OAAO;YACP,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ,CAAE,QAAgB;QAC9B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAChC,CAAC;IAED,UAAU,CAAE,QAAgB;QAC1B,MAAM,OA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AM,CAAC,KAAK,UAAU,uBAAuB,CAAE,QAAgB,EAAE,IAAgB,EAAE,UAAkB;IACnG,OAAO;QACL,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;QACnC,6CAA6C;QAC7C,UAAU,EAAE;YACV,UAAU;SACX;KACF,CAAA;AACH,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { Libp2pEvents, Upgrader } from '@libp2p/interface';
2
- import type { Registrar } from '@libp2p/interface-internal';
3
- import type { TypedEventTarget } from 'main-event';
4
- export interface MockUpgraderInit {
5
- registrar?: Registrar;
6
- events?: TypedEventTarget<Libp2pEvents>;
7
- }
8
- export declare function mockUpgrader(init?: MockUpgraderInit): Upgrader;
9
- //# sourceMappingURL=upgrader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upgrader.d.ts","sourceRoot":"","sources":["../../../src/mocks/upgrader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAmC,QAAQ,EAA6E,MAAM,mBAAmB,CAAA;AAC3K,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAA;CACxC;AAoDD,wBAAgB,YAAY,CAAE,IAAI,GAAE,gBAAqB,GAAG,QAAQ,CAEnE"}
@@ -1,46 +0,0 @@
1
- import { anySignal } from 'any-signal';
2
- import { setMaxListeners } from 'main-event';
3
- import { mockConnection } from './connection.js';
4
- class MockUpgrader {
5
- registrar;
6
- events;
7
- constructor(init) {
8
- this.registrar = init.registrar;
9
- this.events = init.events;
10
- }
11
- async upgradeOutbound(multiaddrConnection, opts) {
12
- const connection = mockConnection(multiaddrConnection, {
13
- direction: 'outbound',
14
- registrar: this.registrar,
15
- ...opts
16
- });
17
- this.events?.safeDispatchEvent('connection:open', { detail: connection });
18
- return connection;
19
- }
20
- async upgradeInbound(multiaddrConnection, opts) {
21
- const connection = mockConnection(multiaddrConnection, {
22
- direction: 'inbound',
23
- registrar: this.registrar,
24
- ...opts
25
- });
26
- this.events?.safeDispatchEvent('connection:open', { detail: connection });
27
- }
28
- createInboundAbortSignal(signal) {
29
- const output = anySignal([
30
- AbortSignal.timeout(10_000),
31
- signal
32
- ]);
33
- setMaxListeners(Infinity, output);
34
- return output;
35
- }
36
- getConnectionEncrypters() {
37
- return new Map();
38
- }
39
- getStreamMuxers() {
40
- return new Map();
41
- }
42
- }
43
- export function mockUpgrader(init = {}) {
44
- return new MockUpgrader(init);
45
- }
46
- //# sourceMappingURL=upgrader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upgrader.js","sourceRoot":"","sources":["../../../src/mocks/upgrader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAUhD,MAAM,YAAY;IACC,SAAS,CAAY;IACrB,MAAM,CAAiC;IAExD,YAAa,IAAsB;QACjC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;QAC/B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,eAAe,CAAE,mBAAwC,EAAE,IAAqB;QACpF,MAAM,UAAU,GAAG,cAAc,CAAC,mBAAmB,EAAE;YACrD,SAAS,EAAE,UAAU;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,GAAG,IAAI;SACR,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;QAEzE,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,cAAc,CAAE,mBAAwC,EAAE,IAAqB;QACnF,MAAM,UAAU,GAAG,cAAc,CAAC,mBAAmB,EAAE;YACrD,SAAS,EAAE,SAAS;YACpB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,GAAG,IAAI;SACR,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED,wBAAwB,CAAE,MAAoB;QAC5C,MAAM,MAAM,GAAG,SAAS,CAAC;YACvB,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC;YAC3B,MAAM;SACP,CAAC,CAAA;QACF,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAEjC,OAAO,MAAM,CAAA;IACf,CAAC;IAED,uBAAuB;QACrB,OAAO,IAAI,GAAG,EAAE,CAAA;IAClB,CAAC;IAED,eAAe;QACb,OAAO,IAAI,GAAG,EAAE,CAAA;IAClB,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAE,OAAyB,EAAE;IACvD,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC"}
@@ -1,6 +0,0 @@
1
- import type { PubSubArgs } from './index.js';
2
- import type { TestSetup } from '../index.js';
3
- import type { PubSub } from '@libp2p/interface';
4
- declare const _default: (common: TestSetup<PubSub, PubSubArgs>) => void;
5
- export default _default;
6
- //# sourceMappingURL=api.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/pubsub/api.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,YAAY,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;yBAK/B,QAAQ,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,KAAG,IAAI;AAA5D,wBAmGC"}
@@ -1,88 +0,0 @@
1
- import { isPubSub, isStartable, start, stop } from '@libp2p/interface';
2
- import { expect } from 'aegir/chai';
3
- import delay from 'delay';
4
- import pDefer from 'p-defer';
5
- import pWaitFor from 'p-wait-for';
6
- import sinon from 'sinon';
7
- import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
8
- import { mockNetwork } from '../mocks/index.js';
9
- import { createComponents } from './utils.js';
10
- const topic = 'foo';
11
- const data = uint8ArrayFromString('bar');
12
- export default (common) => {
13
- describe('pubsub api', () => {
14
- let pubsub;
15
- let components;
16
- // Create pubsub router
17
- beforeEach(async () => {
18
- mockNetwork.reset();
19
- components = await createComponents();
20
- pubsub = components.pubsub = await common.setup({
21
- components,
22
- init: {
23
- emitSelf: true
24
- }
25
- });
26
- });
27
- afterEach(async () => {
28
- sinon.restore();
29
- await stop(...Object.values(components));
30
- await common.teardown();
31
- mockNetwork.reset();
32
- });
33
- it('is a PubSub implementation', () => {
34
- expect(isPubSub(pubsub)).to.be.true();
35
- });
36
- it('can start correctly', async () => {
37
- if (!isStartable(pubsub)) {
38
- return;
39
- }
40
- sinon.spy(components.registrar, 'register');
41
- await start(...Object.values(components));
42
- expect(components.registrar.register).to.have.property('callCount', 1);
43
- });
44
- it('can stop correctly', async () => {
45
- if (!isStartable(pubsub)) {
46
- return;
47
- }
48
- sinon.spy(components.registrar, 'unregister');
49
- await start(...Object.values(components));
50
- await stop(...Object.values(components));
51
- expect(components.registrar.unregister).to.have.property('callCount', 1);
52
- });
53
- it('can subscribe and unsubscribe correctly', async () => {
54
- const handler = () => {
55
- throw new Error('a message should not be received');
56
- };
57
- await start(...Object.values(components));
58
- pubsub.subscribe(topic);
59
- pubsub.addEventListener('message', handler);
60
- await pWaitFor(() => {
61
- const topics = pubsub.getTopics();
62
- return topics.length === 1 && topics[0] === topic;
63
- });
64
- pubsub.removeEventListener('message', handler);
65
- pubsub.unsubscribe(topic);
66
- await pWaitFor(() => pubsub.getTopics().length === 0);
67
- // Publish to guarantee the handler is not called
68
- await pubsub.publish(topic, data);
69
- // handlers are called async
70
- await delay(100);
71
- await stop(...Object.values(components));
72
- });
73
- it('can subscribe and publish correctly', async () => {
74
- const defer = pDefer();
75
- await start(...Object.values(components));
76
- pubsub.subscribe(topic);
77
- pubsub.addEventListener('message', (evt) => {
78
- expect(evt).to.have.nested.property('detail.topic', topic);
79
- expect(evt).to.have.deep.nested.property('detail.data', data);
80
- defer.resolve();
81
- });
82
- await pubsub.publish(topic, data);
83
- await defer.promise;
84
- await stop(...Object.values(components));
85
- });
86
- });
87
- };
88
- //# sourceMappingURL=api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/pubsub/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAK7C,MAAM,KAAK,GAAG,KAAK,CAAA;AACnB,MAAM,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAA;AAExC,eAAe,CAAC,MAAqC,EAAQ,EAAE;IAC7D,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,IAAI,MAAc,CAAA;QAClB,IAAI,UAA4B,CAAA;QAEhC,uBAAuB;QACv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