@libp2p/interface-compliance-tests 2.0.2 → 3.0.1

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 (192) hide show
  1. package/README.md +23 -11
  2. package/dist/src/{utils/is-valid-tick.d.ts → is-valid-tick.d.ts} +0 -0
  3. package/dist/src/is-valid-tick.d.ts.map +1 -0
  4. package/dist/src/{utils/is-valid-tick.js → is-valid-tick.js} +0 -0
  5. package/dist/src/is-valid-tick.js.map +1 -0
  6. package/dist/src/{utils/peers.d.ts → peers.d.ts} +0 -0
  7. package/dist/src/peers.d.ts.map +1 -0
  8. package/dist/src/{utils/peers.js → peers.js} +0 -0
  9. package/dist/src/peers.js.map +1 -0
  10. package/package.json +11 -89
  11. package/src/{utils/is-valid-tick.ts → is-valid-tick.ts} +0 -0
  12. package/src/{utils/peers.ts → peers.ts} +0 -0
  13. package/dist/src/connection/connection.d.ts +0 -5
  14. package/dist/src/connection/connection.d.ts.map +0 -1
  15. package/dist/src/connection/connection.js +0 -146
  16. package/dist/src/connection/connection.js.map +0 -1
  17. package/dist/src/connection/index.d.ts +0 -5
  18. package/dist/src/connection/index.d.ts.map +0 -1
  19. package/dist/src/connection/index.js +0 -5
  20. package/dist/src/connection/index.js.map +0 -1
  21. package/dist/src/connection-encrypter/index.d.ts +0 -5
  22. package/dist/src/connection-encrypter/index.d.ts.map +0 -1
  23. package/dist/src/connection-encrypter/index.js +0 -77
  24. package/dist/src/connection-encrypter/index.js.map +0 -1
  25. package/dist/src/connection-encrypter/utils/index.d.ts +0 -3
  26. package/dist/src/connection-encrypter/utils/index.d.ts.map +0 -1
  27. package/dist/src/connection-encrypter/utils/index.js +0 -18
  28. package/dist/src/connection-encrypter/utils/index.js.map +0 -1
  29. package/dist/src/mocks/connection-encrypter.d.ts +0 -3
  30. package/dist/src/mocks/connection-encrypter.d.ts.map +0 -1
  31. package/dist/src/mocks/connection-encrypter.js +0 -93
  32. package/dist/src/mocks/connection-encrypter.js.map +0 -1
  33. package/dist/src/mocks/connection-gater.d.ts +0 -12
  34. package/dist/src/mocks/connection-gater.d.ts.map +0 -1
  35. package/dist/src/mocks/connection-gater.js +0 -14
  36. package/dist/src/mocks/connection-gater.js.map +0 -1
  37. package/dist/src/mocks/connection-manager.d.ts +0 -28
  38. package/dist/src/mocks/connection-manager.d.ts.map +0 -1
  39. package/dist/src/mocks/connection-manager.js +0 -107
  40. package/dist/src/mocks/connection-manager.js.map +0 -1
  41. package/dist/src/mocks/connection.d.ts +0 -18
  42. package/dist/src/mocks/connection.d.ts.map +0 -1
  43. package/dist/src/mocks/connection.js +0 -138
  44. package/dist/src/mocks/connection.js.map +0 -1
  45. package/dist/src/mocks/duplex.d.ts +0 -3
  46. package/dist/src/mocks/duplex.d.ts.map +0 -1
  47. package/dist/src/mocks/duplex.js +0 -7
  48. package/dist/src/mocks/duplex.js.map +0 -1
  49. package/dist/src/mocks/index.d.ts +0 -10
  50. package/dist/src/mocks/index.d.ts.map +0 -1
  51. package/dist/src/mocks/index.js +0 -9
  52. package/dist/src/mocks/index.js.map +0 -1
  53. package/dist/src/mocks/multiaddr-connection.d.ts +0 -17
  54. package/dist/src/mocks/multiaddr-connection.d.ts.map +0 -1
  55. package/dist/src/mocks/multiaddr-connection.js +0 -51
  56. package/dist/src/mocks/multiaddr-connection.js.map +0 -1
  57. package/dist/src/mocks/muxer.d.ts +0 -9
  58. package/dist/src/mocks/muxer.d.ts.map +0 -1
  59. package/dist/src/mocks/muxer.js +0 -302
  60. package/dist/src/mocks/muxer.js.map +0 -1
  61. package/dist/src/mocks/registrar.d.ts +0 -18
  62. package/dist/src/mocks/registrar.d.ts.map +0 -1
  63. package/dist/src/mocks/registrar.js +0 -73
  64. package/dist/src/mocks/registrar.js.map +0 -1
  65. package/dist/src/mocks/upgrader.d.ts +0 -15
  66. package/dist/src/mocks/upgrader.d.ts.map +0 -1
  67. package/dist/src/mocks/upgrader.js +0 -33
  68. package/dist/src/mocks/upgrader.js.map +0 -1
  69. package/dist/src/peer-discovery/index.d.ts +0 -6
  70. package/dist/src/peer-discovery/index.d.ts.map +0 -1
  71. package/dist/src/peer-discovery/index.js +0 -64
  72. package/dist/src/peer-discovery/index.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 -87
  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 -86
  84. package/dist/src/pubsub/emit-self.js.map +0 -1
  85. package/dist/src/pubsub/index.d.ts +0 -10
  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 -46
  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 -185
  100. package/dist/src/pubsub/two-nodes.js.map +0 -1
  101. package/dist/src/pubsub/utils.d.ts +0 -6
  102. package/dist/src/pubsub/utils.d.ts.map +0 -1
  103. package/dist/src/pubsub/utils.js +0 -22
  104. package/dist/src/pubsub/utils.js.map +0 -1
  105. package/dist/src/record/index.d.ts +0 -5
  106. package/dist/src/record/index.d.ts.map +0 -1
  107. package/dist/src/record/index.js +0 -25
  108. package/dist/src/record/index.js.map +0 -1
  109. package/dist/src/stream-muxer/base-test.d.ts +0 -5
  110. package/dist/src/stream-muxer/base-test.d.ts.map +0 -1
  111. package/dist/src/stream-muxer/base-test.js +0 -147
  112. package/dist/src/stream-muxer/base-test.js.map +0 -1
  113. package/dist/src/stream-muxer/close-test.d.ts +0 -5
  114. package/dist/src/stream-muxer/close-test.d.ts.map +0 -1
  115. package/dist/src/stream-muxer/close-test.js +0 -180
  116. package/dist/src/stream-muxer/close-test.js.map +0 -1
  117. package/dist/src/stream-muxer/index.d.ts +0 -5
  118. package/dist/src/stream-muxer/index.d.ts.map +0 -1
  119. package/dist/src/stream-muxer/index.js +0 -13
  120. package/dist/src/stream-muxer/index.js.map +0 -1
  121. package/dist/src/stream-muxer/mega-stress-test.d.ts +0 -5
  122. package/dist/src/stream-muxer/mega-stress-test.d.ts.map +0 -1
  123. package/dist/src/stream-muxer/mega-stress-test.js +0 -12
  124. package/dist/src/stream-muxer/mega-stress-test.js.map +0 -1
  125. package/dist/src/stream-muxer/spawner.d.ts +0 -4
  126. package/dist/src/stream-muxer/spawner.d.ts.map +0 -1
  127. package/dist/src/stream-muxer/spawner.js +0 -32
  128. package/dist/src/stream-muxer/spawner.js.map +0 -1
  129. package/dist/src/stream-muxer/stress-test.d.ts +0 -5
  130. package/dist/src/stream-muxer/stress-test.d.ts.map +0 -1
  131. package/dist/src/stream-muxer/stress-test.js +0 -26
  132. package/dist/src/stream-muxer/stress-test.js.map +0 -1
  133. package/dist/src/topology/topology.d.ts +0 -5
  134. package/dist/src/topology/topology.d.ts.map +0 -1
  135. package/dist/src/topology/topology.js +0 -20
  136. package/dist/src/topology/topology.js.map +0 -1
  137. package/dist/src/transport/dial-test.d.ts +0 -5
  138. package/dist/src/transport/dial-test.d.ts.map +0 -1
  139. package/dist/src/transport/dial-test.js +0 -97
  140. package/dist/src/transport/dial-test.js.map +0 -1
  141. package/dist/src/transport/filter-test.d.ts +0 -5
  142. package/dist/src/transport/filter-test.d.ts.map +0 -1
  143. package/dist/src/transport/filter-test.js +0 -18
  144. package/dist/src/transport/filter-test.js.map +0 -1
  145. package/dist/src/transport/index.d.ts +0 -15
  146. package/dist/src/transport/index.d.ts.map +0 -1
  147. package/dist/src/transport/index.js +0 -11
  148. package/dist/src/transport/index.js.map +0 -1
  149. package/dist/src/transport/listen-test.d.ts +0 -5
  150. package/dist/src/transport/listen-test.d.ts.map +0 -1
  151. package/dist/src/transport/listen-test.js +0 -152
  152. package/dist/src/transport/listen-test.js.map +0 -1
  153. package/dist/src/utils/is-valid-tick.d.ts.map +0 -1
  154. package/dist/src/utils/is-valid-tick.js.map +0 -1
  155. package/dist/src/utils/peers.d.ts.map +0 -1
  156. package/dist/src/utils/peers.js.map +0 -1
  157. package/src/connection/README.md +0 -256
  158. package/src/connection/connection.ts +0 -176
  159. package/src/connection/index.ts +0 -7
  160. package/src/connection-encrypter/index.ts +0 -104
  161. package/src/connection-encrypter/utils/index.ts +0 -23
  162. package/src/mocks/connection-encrypter.ts +0 -110
  163. package/src/mocks/connection-gater.ts +0 -14
  164. package/src/mocks/connection-manager.ts +0 -141
  165. package/src/mocks/connection.ts +0 -205
  166. package/src/mocks/duplex.ts +0 -8
  167. package/src/mocks/index.ts +0 -10
  168. package/src/mocks/multiaddr-connection.ts +0 -66
  169. package/src/mocks/muxer.ts +0 -424
  170. package/src/mocks/registrar.ts +0 -96
  171. package/src/mocks/upgrader.ts +0 -46
  172. package/src/peer-discovery/index.ts +0 -89
  173. package/src/pubsub/api.ts +0 -115
  174. package/src/pubsub/connection-handlers.ts +0 -413
  175. package/src/pubsub/emit-self.ts +0 -105
  176. package/src/pubsub/index.ts +0 -25
  177. package/src/pubsub/messages.ts +0 -58
  178. package/src/pubsub/multiple-nodes.ts +0 -429
  179. package/src/pubsub/two-nodes.ts +0 -235
  180. package/src/pubsub/utils.ts +0 -28
  181. package/src/record/index.ts +0 -32
  182. package/src/stream-muxer/base-test.ts +0 -190
  183. package/src/stream-muxer/close-test.ts +0 -227
  184. package/src/stream-muxer/index.ts +0 -15
  185. package/src/stream-muxer/mega-stress-test.ts +0 -15
  186. package/src/stream-muxer/spawner.ts +0 -50
  187. package/src/stream-muxer/stress-test.ts +0 -29
  188. package/src/topology/topology.ts +0 -25
  189. package/src/transport/dial-test.ts +0 -123
  190. package/src/transport/filter-test.ts +0 -25
  191. package/src/transport/index.ts +0 -25
  192. package/src/transport/listen-test.ts +0 -191
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-encrypter.js","sourceRoot":"","sources":["../../../src/mocks/connection-encrypter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAInD,kDAAkD;AAClD,MAAM,SAAS,GAAG,GAAsC,EAAE;IACxD,OAAO,CAAC,MAA0B,EAAE,EAAE,CAAC,CAAC,KAAK,SAAU,CAAC;QACtD,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE;YAChC,MAAM,KAAK,CAAA;SACZ;IACH,CAAC,CAAC,EAAE,CAAA;AACN,CAAC,CAAA;AAED,MAAM,UAAU,uBAAuB;IACrC,MAAM,SAAS,GAAwB;QACrC,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;YACvD,gCAAgC;YAChC,MAAM,KAAK,GAAG,SAAS,C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C;KACF,CAAA;IAED,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -1,12 +0,0 @@
1
- export declare function mockConnectionGater(): {
2
- denyDialPeer: () => Promise<boolean>;
3
- denyDialMultiaddr: () => Promise<boolean>;
4
- denyInboundConnection: () => Promise<boolean>;
5
- denyOutboundConnection: () => Promise<boolean>;
6
- denyInboundEncryptedConnection: () => Promise<boolean>;
7
- denyOutboundEncryptedConnection: () => Promise<boolean>;
8
- denyInboundUpgradedConnection: () => Promise<boolean>;
9
- denyOutboundUpgradedConnection: () => Promise<boolean>;
10
- filterMultiaddrForPeer: () => Promise<boolean>;
11
- };
12
- //# sourceMappingURL=connection-gater.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-gater.d.ts","sourceRoot":"","sources":["../../../src/mocks/connection-gater.ts"],"names":[],"mappings":"AACA,wBAAgB,mBAAmB;;;;;;;;;;EAYlC"}
@@ -1,14 +0,0 @@
1
- export function mockConnectionGater() {
2
- return {
3
- denyDialPeer: async () => await Promise.resolve(false),
4
- denyDialMultiaddr: async () => await Promise.resolve(false),
5
- denyInboundConnection: async () => await Promise.resolve(false),
6
- denyOutboundConnection: async () => await Promise.resolve(false),
7
- denyInboundEncryptedConnection: async () => await Promise.resolve(false),
8
- denyOutboundEncryptedConnection: async () => await Promise.resolve(false),
9
- denyInboundUpgradedConnection: async () => await Promise.resolve(false),
10
- denyOutboundUpgradedConnection: async () => await Promise.resolve(false),
11
- filterMultiaddrForPeer: async () => await Promise.resolve(true)
12
- };
13
- }
14
- //# sourceMappingURL=connection-gater.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-gater.js","sourceRoot":"","sources":["../../../src/mocks/connection-gater.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACtD,iBAAiB,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAC3D,qBAAqB,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAC/D,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAChE,8BAA8B,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACxE,+BAA+B,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,6BAA6B,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACvE,8BAA8B,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACxE,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;KAChE,CAAA;AACH,CAAC"}
@@ -1,28 +0,0 @@
1
- import { EventEmitter } from '@libp2p/interfaces/events';
2
- import type { Startable } from '@libp2p/interfaces/startable';
3
- import type { Connection } from '@libp2p/interfaces/connection';
4
- import type { PeerId } from '@libp2p/interfaces/peer-id';
5
- import type { ConnectionManager, ConnectionManagerEvents } from '@libp2p/interfaces/connection-manager';
6
- import type { Components, Initializable } from '@libp2p/interfaces/src/components';
7
- declare class MockNetwork {
8
- private components;
9
- addNode(components: Components): void;
10
- getNode(peerId: PeerId): Components;
11
- reset(): void;
12
- }
13
- export declare const mockNetwork: MockNetwork;
14
- declare class MockConnectionManager extends EventEmitter<ConnectionManagerEvents> implements ConnectionManager, Initializable, Startable {
15
- private connections;
16
- private components?;
17
- private started;
18
- init(components: Components): void;
19
- isStarted(): boolean;
20
- start(): Promise<void>;
21
- stop(): Promise<void>;
22
- getConnections(peerId?: PeerId): Connection[];
23
- openConnection(peerId: PeerId): Promise<Connection>;
24
- closeConnections(peerId: PeerId): Promise<void>;
25
- }
26
- export declare function mockConnectionManager(): MockConnectionManager;
27
- export {};
28
- //# sourceMappingURL=connection-manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../src/mocks/connection-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAA;AACvG,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAIlF,cAAM,WAAW;IACf,OAAO,CAAC,UAAU,CAAmB;IAErC,OAAO,CAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAItC,OAAO,CAAE,MAAM,EAAE,MAAM,GAAG,UAAU;IAUpC,KAAK;CAGN;AAED,eAAO,MAAM,WAAW,aAAoB,CAAA;AAE5C,cAAM,qBAAsB,SAAQ,YAAY,CAAC,uBAAuB,CAAE,YAAW,iBAAiB,EAAE,aAAa,EAAE,SAAS;IAC9H,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,UAAU,CAAC,CAAY;IAC/B,OAAO,CAAC,OAAO,CAAQ;IAEvB,IAAI,CAAE,UAAU,EAAE,UAAU;IAI5B,SAAS;IAIH,KAAK;IAIL,IAAI;IAQV,cAAc,CAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,EAAE;IASxC,cAAc,CAAE,MAAM,EAAE,MAAM;IA0C9B,gBAAgB,CAAE,MAAM,EAAE,MAAM;CA2BvC;AAED,wBAAgB,qBAAqB,0BAEpC"}
@@ -1,107 +0,0 @@
1
- import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events';
2
- import { connectionPair } from './connection.js';
3
- import errCode from 'err-code';
4
- class MockNetwork {
5
- constructor() {
6
- this.components = [];
7
- }
8
- addNode(components) {
9
- this.components.push(components);
10
- }
11
- getNode(peerId) {
12
- for (const components of this.components) {
13
- if (peerId.equals(components.getPeerId())) {
14
- return components;
15
- }
16
- }
17
- throw errCode(new Error('Peer not found'), 'ERR_PEER_NOT_FOUND');
18
- }
19
- reset() {
20
- this.components = [];
21
- }
22
- }
23
- export const mockNetwork = new MockNetwork();
24
- class MockConnectionManager extends EventEmitter {
25
- constructor() {
26
- super(...arguments);
27
- this.connections = [];
28
- this.started = false;
29
- }
30
- init(components) {
31
- this.components = components;
32
- }
33
- isStarted() {
34
- return this.started;
35
- }
36
- async start() {
37
- this.started = true;
38
- }
39
- async stop() {
40
- for (const connection of this.connections) {
41
- await this.closeConnections(connection.remotePeer);
42
- }
43
- this.started = false;
44
- }
45
- getConnections(peerId) {
46
- if (peerId != null) {
47
- return this.connections
48
- .filter(c => c.remotePeer.toString() === peerId.toString());
49
- }
50
- return this.connections;
51
- }
52
- async openConnection(peerId) {
53
- if (this.components == null) {
54
- throw errCode(new Error('Not initialized'), 'ERR_NOT_INITIALIZED');
55
- }
56
- const existingConnections = this.getConnections(peerId);
57
- if (existingConnections.length > 0) {
58
- return existingConnections[0];
59
- }
60
- const componentsB = mockNetwork.getNode(peerId);
61
- const [aToB, bToA] = connectionPair(this.components, componentsB);
62
- // track connections
63
- this.connections.push(aToB);
64
- componentsB.getConnectionManager().connections.push(bToA);
65
- this.components.getConnectionManager().dispatchEvent(new CustomEvent('peer:connect', {
66
- detail: aToB
67
- }));
68
- for (const protocol of this.components.getRegistrar().getProtocols()) {
69
- for (const topology of this.components.getRegistrar().getTopologies(protocol)) {
70
- topology.onConnect(componentsB.getPeerId(), aToB);
71
- }
72
- }
73
- componentsB.getConnectionManager().dispatchEvent(new CustomEvent('peer:connect', {
74
- detail: bToA
75
- }));
76
- for (const protocol of componentsB.getRegistrar().getProtocols()) {
77
- for (const topology of componentsB.getRegistrar().getTopologies(protocol)) {
78
- topology.onConnect(this.components.getPeerId(), bToA);
79
- }
80
- }
81
- return aToB;
82
- }
83
- async closeConnections(peerId) {
84
- if (this.components == null) {
85
- throw errCode(new Error('Not initialized'), 'ERR_NOT_INITIALIZED');
86
- }
87
- const connections = this.getConnections(peerId);
88
- if (connections.length === 0) {
89
- return;
90
- }
91
- const componentsB = mockNetwork.getNode(peerId);
92
- for (const protocol of this.components.getRegistrar().getProtocols()) {
93
- this.components.getRegistrar().getTopologies(protocol).forEach(topology => {
94
- topology.onDisconnect(componentsB.getPeerId());
95
- });
96
- }
97
- for (const conn of connections) {
98
- await conn.close();
99
- }
100
- this.connections = this.connections.filter(c => !c.remotePeer.equals(peerId));
101
- await componentsB.getConnectionManager().closeConnections(peerId);
102
- }
103
- }
104
- export function mockConnectionManager() {
105
- return new MockConnectionManager();
106
- }
107
- //# sourceMappingURL=connection-manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-manager.js","sourceRoot":"","sources":["../../../src/mocks/connection-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAMrE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,OAAO,MAAM,UAAU,CAAA;AAE9B,MAAM,WAAW;IAAjB;QACU,eAAU,GAAiB,EAAE,CAAA;IAmBvC,CAAC;IAjBC,OAAO,CAAE,UAAsB;QAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,CAAE,MAAc;QACrB,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,UAAU,EAAE;YACxC,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,EA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C"}
@@ -1,18 +0,0 @@
1
- import type { MultiaddrConnection } from '@libp2p/interfaces/transport';
2
- import type { Connection, Stream } from '@libp2p/interfaces/connection';
3
- import type { Duplex } from 'it-stream-types';
4
- import type { PeerId } from '@libp2p/interfaces/peer-id';
5
- import type { Registrar } from '@libp2p/interfaces/registrar';
6
- import { Components } from '@libp2p/interfaces/components';
7
- export interface MockConnectionOptions {
8
- direction?: 'inbound' | 'outbound';
9
- registrar?: Registrar;
10
- }
11
- export declare function mockConnection(maConn: MultiaddrConnection, opts?: MockConnectionOptions): Connection;
12
- export declare function mockStream(stream: Duplex<Uint8Array>): Stream;
13
- export interface Peer {
14
- peerId: PeerId;
15
- registrar: Registrar;
16
- }
17
- export declare function connectionPair(a: Components, b: Components): [Connection, Connection];
18
- //# sourceMappingURL=connection.d.ts.map
@@ -1 +0,0 @@
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,EAA4C,MAAM,+BAA+B,CAAA;AACjH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAO7D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAK1D,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IAClC,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AA4FD,wBAAgB,cAAc,CAAE,MAAM,EAAE,mBAAmB,EAAE,IAAI,GAAE,qBAA0B,GAAG,UAAU,CAmDzG;AAED,wBAAgB,UAAU,CAAE,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAa9D;AAED,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,CAAA;CACrB;AAED,wBAAgB,cAAc,CAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,CAAE,UAAU,EAAE,UAAU,CAAE,CAexF"}
@@ -1,138 +0,0 @@
1
- import { peerIdFromString } from '@libp2p/peer-id';
2
- import { pipe } from 'it-pipe';
3
- import { duplexPair } from 'it-pair/duplex';
4
- import { mockMuxer } from './muxer.js';
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 * as STATUS from '@libp2p/interfaces/connection/status';
10
- import { Components } from '@libp2p/interfaces/components';
11
- const log = logger('libp2p:mock-connection');
12
- class MockConnection {
13
- constructor(init) {
14
- const { remoteAddr, remotePeer, direction, maConn, muxer } = init;
15
- this.id = `mock-connection-${Math.random()}`;
16
- this.remoteAddr = remoteAddr;
17
- this.remotePeer = remotePeer;
18
- this.direction = direction;
19
- this.stat = {
20
- status: STATUS.OPEN,
21
- direction,
22
- timeline: maConn.timeline,
23
- multiplexer: 'test-multiplexer',
24
- encryption: 'yes-yes-very-secure'
25
- };
26
- this.registry = new Map();
27
- this.streams = [];
28
- this.tags = [];
29
- this.muxer = muxer;
30
- this.maConn = maConn;
31
- }
32
- async newStream(protocols, options) {
33
- if (!Array.isArray(protocols)) {
34
- protocols = [protocols];
35
- }
36
- if (protocols.length === 0) {
37
- throw new Error('protocols must have a length');
38
- }
39
- const id = `${Math.random()}`;
40
- const stream = this.muxer.newStream(id);
41
- const mss = new Dialer(stream);
42
- const result = await mss.select(protocols, options);
43
- const streamData = {
44
- protocol: result.protocol,
45
- stream: {
46
- ...stream,
47
- ...result.stream
48
- }
49
- };
50
- this.addStream(stream, { protocol: result.protocol, metadata: {} });
51
- return streamData;
52
- }
53
- addStream(stream, metadata) {
54
- this.registry.set(stream.id, {
55
- protocol: metadata.protocol ?? '',
56
- metadata: metadata.metadata ?? {}
57
- });
58
- this.streams.push(stream);
59
- }
60
- removeStream(id) {
61
- this.registry.delete(id);
62
- this.streams = this.streams.filter(stream => stream.id !== id);
63
- }
64
- async close() {
65
- this.stat.status = STATUS.CLOSING;
66
- await this.maConn.close();
67
- this.stat.status = STATUS.CLOSED;
68
- }
69
- }
70
- export function mockConnection(maConn, opts = {}) {
71
- const remoteAddr = maConn.remoteAddr;
72
- const remotePeerIdStr = remoteAddr.getPeerId() ?? '12D3KooWCrhmFM1BCPGBkNzbPfDk4cjYmtAYSpZwUBC69Qg2kZyq';
73
- if (remotePeerIdStr == null) {
74
- throw new Error('Remote multiaddr must contain a peer id');
75
- }
76
- const remotePeer = peerIdFromString(remotePeerIdStr);
77
- const direction = opts.direction ?? 'inbound';
78
- const registrar = opts.registrar ?? mockRegistrar();
79
- const muxerFactory = mockMuxer();
80
- const muxer = muxerFactory.createStreamMuxer(new Components(), {
81
- onIncomingStream: (muxedStream) => {
82
- const mss = new Listener(muxedStream);
83
- try {
84
- mss.handle(registrar.getProtocols())
85
- .then(({ stream, protocol }) => {
86
- log('%s: incoming stream opened on %s', direction, protocol);
87
- muxedStream = { ...muxedStream, ...stream };
88
- connection.addStream(muxedStream, { protocol, metadata: {} });
89
- const handler = registrar.getHandler(protocol);
90
- handler({ connection, stream: muxedStream, protocol });
91
- }).catch(err => {
92
- log.error(err);
93
- });
94
- }
95
- catch (err) {
96
- log.error(err);
97
- }
98
- },
99
- onStreamEnd: (muxedStream) => {
100
- connection.removeStream(muxedStream.id);
101
- }
102
- });
103
- void pipe(maConn, muxer, maConn);
104
- const connection = new MockConnection({
105
- remoteAddr,
106
- remotePeer,
107
- direction,
108
- maConn,
109
- muxer
110
- });
111
- return connection;
112
- }
113
- export function mockStream(stream) {
114
- return {
115
- ...stream,
116
- close: () => { },
117
- closeRead: () => { },
118
- closeWrite: () => { },
119
- abort: () => { },
120
- reset: () => { },
121
- timeline: {
122
- open: Date.now()
123
- },
124
- id: `stream-${Date.now()}`
125
- };
126
- }
127
- export function connectionPair(a, b) {
128
- const [peerBtoPeerA, peerAtoPeerB] = duplexPair();
129
- return [
130
- mockConnection(mockMultiaddrConnection(peerAtoPeerB, b.getPeerId()), {
131
- registrar: a.getRegistrar()
132
- }),
133
- mockConnection(mockMultiaddrConnection(peerBtoPeerA, a.getPeerId()), {
134
- registrar: b.getRegistrar()
135
- })
136
- ];
137
- }
138
- //# sourceMappingURL=connection.js.map
@@ -1 +0,0 @@
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;AAI3C,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,KAAK,MAAM,MAAM,sCAAsC,CAAA;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAG1D,MAAM,GAAG,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAA;AAe5C,MAAM,cAAc;IAalB,YAAa,IAAwB;QACnC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;QAEjE,IAAI,CAAC,EAAE,GAAG,mBAAmB,IAAI,CAAC,MAAM,EAAE,EAAE,CAAA;QAC5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C,CAAC;KACF,CAAC,CAAA;IAEF,KAAK,IAAI,CACP,MAAM,EAAE,KAAK,EAAE,MAAM,CACtB,CAAA;IAED,MAAM,UAAU,GAAG,IAAI,cAAc,CAAC;QACpC,UAAU;QACV,UAAU;QACV,SAAS;QACT,MAAM;QACN,KAAK;KACN,CAAC,CAAA;IAEF,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,MAAM,UAAU,UAAU,CAAE,MAA0B;IACpD,OAAO;QACL,GAAG,MAAM;QACT,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;QACf,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC;QACnB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;QACpB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;QACf,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;QACf,QAAQ,EAAE;YACR,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;SACjB;QACD,EAAE,EAAE,UAAU,IAAI,CAAC,GAAG,EAAE,EAAE;KAC3B,CAAA;AACH,CAAC;AAOD,MAAM,UAAU,cAAc,CAAE,CAAa,EAAE,CAAa;IAC1D,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,UAAU,EAAc,CAAA;IAE7D,OAAO;QACL,cAAc,CACZ,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,EAAE;YACpD,SAAS,EAAE,CAAC,CAAC,YAAY,EAAE;SAC5B,CACF;QACD,cAAc,CACZ,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,EAAE;YACpD,SAAS,EAAE,CAAC,CAAC,YAAY,EAAE;SAC5B,CACF;KACF,CAAA;AACH,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Duplex } from 'it-stream-types';
2
- export declare function mockDuplex(): Duplex<Uint8Array>;
3
- //# sourceMappingURL=duplex.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"duplex.d.ts","sourceRoot":"","sources":["../../../src/mocks/duplex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C,wBAAgB,UAAU,IAAK,MAAM,CAAC,UAAU,CAAC,CAKhD"}
@@ -1,7 +0,0 @@
1
- export function mockDuplex() {
2
- return {
3
- source: [],
4
- sink: async () => { }
5
- };
6
- }
7
- //# sourceMappingURL=duplex.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"duplex.js","sourceRoot":"","sources":["../../../src/mocks/duplex.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;KACrB,CAAA;AACH,CAAC"}
@@ -1,10 +0,0 @@
1
- export { mockConnectionGater } from './connection-gater.js';
2
- export { mockConnectionManager, mockNetwork } from './connection-manager.js';
3
- export { mockConnection, mockStream, connectionPair } from './connection.js';
4
- export { mockMultiaddrConnection, mockMultiaddrConnPair } from './multiaddr-connection.js';
5
- export { mockMuxer } from './muxer.js';
6
- export { mockRegistrar } from './registrar.js';
7
- export { mockUpgrader } from './upgrader.js';
8
- export { mockDuplex } from './duplex.js';
9
- export type { MockUpgraderInit } from './upgrader.js';
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mocks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC5E,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA"}
@@ -1,9 +0,0 @@
1
- export { mockConnectionGater } from './connection-gater.js';
2
- export { mockConnectionManager, mockNetwork } from './connection-manager.js';
3
- export { mockConnection, mockStream, connectionPair } from './connection.js';
4
- export { mockMultiaddrConnection, mockMultiaddrConnPair } from './multiaddr-connection.js';
5
- export { mockMuxer } from './muxer.js';
6
- export { mockRegistrar } from './registrar.js';
7
- export { mockUpgrader } from './upgrader.js';
8
- export { mockDuplex } from './duplex.js';
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mocks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC5E,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA"}
@@ -1,17 +0,0 @@
1
- import { Multiaddr } from '@multiformats/multiaddr';
2
- import type { MultiaddrConnection } from '@libp2p/interfaces/transport';
3
- import type { Duplex } from 'it-stream-types';
4
- import type { PeerId } from '@libp2p/interfaces/peer-id';
5
- export declare function mockMultiaddrConnection(source: Duplex<Uint8Array> & 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":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGnD,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;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,CAmC1I"}
@@ -1,51 +0,0 @@
1
- import { Multiaddr } from '@multiformats/multiaddr';
2
- import { duplexPair } from 'it-pair/duplex';
3
- import { abortableSource } from 'abortable-iterator';
4
- export function mockMultiaddrConnection(source, peerId) {
5
- const maConn = {
6
- async close() {
7
- },
8
- timeline: {
9
- open: Date.now()
10
- },
11
- remoteAddr: new Multiaddr(`/ip4/127.0.0.1/tcp/4001/p2p/${peerId.toString()}`),
12
- ...source
13
- };
14
- return maConn;
15
- }
16
- /**
17
- * Returns both sides of a mocked MultiaddrConnection
18
- */
19
- export function mockMultiaddrConnPair(opts) {
20
- const { addrs, remotePeer } = opts;
21
- const controller = new AbortController();
22
- const [localAddr, remoteAddr] = addrs;
23
- const [inboundStream, outboundStream] = duplexPair();
24
- const outbound = {
25
- ...outboundStream,
26
- remoteAddr: remoteAddr.encapsulate(`/p2p/${remotePeer.toString()}`),
27
- timeline: {
28
- open: Date.now()
29
- },
30
- close: async () => {
31
- outbound.timeline.close = Date.now();
32
- controller.abort();
33
- }
34
- };
35
- const inbound = {
36
- ...inboundStream,
37
- remoteAddr: localAddr,
38
- timeline: {
39
- open: Date.now()
40
- },
41
- close: async () => {
42
- inbound.timeline.close = Date.now();
43
- controller.abort();
44
- }
45
- };
46
- // Make the sources abortable so we can close them easily
47
- inbound.source = abortableSource(inbound.source, controller.signal);
48
- outbound.source = abortableSource(outbound.source, controller.signal);
49
- return { inbound, outbound };
50
- }
51
- //# 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,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAKpD,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,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AO,EAAE,QAAQ,EAAE,CAAA;AAC9B,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interfaces/stream-muxer';
2
- import type { Components } from '@libp2p/interfaces/components';
3
- declare class MockMuxerFactory implements StreamMuxerFactory {
4
- protocol: string;
5
- createStreamMuxer(c: Components, init?: StreamMuxerInit): StreamMuxer;
6
- }
7
- export declare function mockMuxer(): MockMuxerFactory;
8
- export {};
9
- //# sourceMappingURL=muxer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"muxer.d.ts","sourceRoot":"","sources":["../../../src/mocks/muxer.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAIvG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAiY/D,cAAM,gBAAiB,YAAW,kBAAkB;IAC3C,QAAQ,EAAE,MAAM,CAAsB;IAE7C,iBAAiB,CAAE,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,WAAW;CAkBvE;AAED,wBAAgB,SAAS,IAAK,gBAAgB,CAE7C"}