@streamr/dht 100.0.0-pretestnet.2 → 100.0.0-pretestnet.4

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 (325) hide show
  1. package/dist/src/connection/ConnectionLockHandler.d.ts +7 -8
  2. package/dist/src/connection/ConnectionLockHandler.js +16 -14
  3. package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
  4. package/dist/src/connection/ConnectionLockRpcLocal.d.ts +20 -0
  5. package/dist/src/connection/ConnectionLockRpcLocal.js +47 -0
  6. package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -0
  7. package/dist/src/connection/ConnectionLockRpcRemote.d.ts +4 -3
  8. package/dist/src/connection/ConnectionLockRpcRemote.js +9 -9
  9. package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
  10. package/dist/src/connection/ConnectionManager.d.ts +9 -16
  11. package/dist/src/connection/ConnectionManager.js +101 -132
  12. package/dist/src/connection/ConnectionManager.js.map +1 -1
  13. package/dist/src/connection/ConnectivityChecker.d.ts +7 -10
  14. package/dist/src/connection/ConnectivityChecker.js +30 -32
  15. package/dist/src/connection/ConnectivityChecker.js.map +1 -1
  16. package/dist/src/connection/ConnectorFacade.d.ts +19 -13
  17. package/dist/src/connection/ConnectorFacade.js +74 -29
  18. package/dist/src/connection/ConnectorFacade.js.map +1 -1
  19. package/dist/src/connection/Handshaker.d.ts +8 -8
  20. package/dist/src/connection/Handshaker.js +30 -33
  21. package/dist/src/connection/Handshaker.js.map +1 -1
  22. package/dist/src/connection/IConnection.d.ts +5 -6
  23. package/dist/src/connection/IConnection.js.map +1 -1
  24. package/dist/src/connection/ManagedConnection.d.ts +9 -13
  25. package/dist/src/connection/ManagedConnection.js +63 -99
  26. package/dist/src/connection/ManagedConnection.js.map +1 -1
  27. package/dist/src/connection/ManagedWebrtcConnection.d.ts +7 -0
  28. package/dist/src/connection/ManagedWebrtcConnection.js +20 -0
  29. package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -0
  30. package/dist/src/connection/{Simulator → simulator}/Simulator.js +3 -3
  31. package/dist/src/connection/{Simulator → simulator}/Simulator.js.map +1 -1
  32. package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.d.ts +3 -4
  33. package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.js +25 -24
  34. package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -0
  35. package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.d.ts +3 -3
  36. package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js +17 -18
  37. package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -0
  38. package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.d.ts +1 -1
  39. package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.js +2 -2
  40. package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -0
  41. package/dist/src/connection/{Simulator → simulator}/pings.js.map +1 -1
  42. package/dist/src/connection/{WebRTC/IWebRtcConnection.d.ts → webrtc/IWebrtcConnection.d.ts} +2 -2
  43. package/dist/src/connection/{WebRTC/IWebRtcConnection.js → webrtc/IWebrtcConnection.js} +1 -1
  44. package/dist/src/connection/webrtc/IWebrtcConnection.js.map +1 -0
  45. package/dist/src/connection/{WebRTC/NodeWebRtcConnection.d.ts → webrtc/NodeWebrtcConnection.d.ts} +6 -7
  46. package/dist/src/connection/{WebRTC/NodeWebRtcConnection.js → webrtc/NodeWebrtcConnection.js} +41 -42
  47. package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -0
  48. package/dist/src/connection/webrtc/WebrtcConnector.d.ts +38 -0
  49. package/dist/src/connection/webrtc/WebrtcConnector.js +178 -0
  50. package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -0
  51. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +26 -0
  52. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +99 -0
  53. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -0
  54. package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.d.ts → webrtc/WebrtcConnectorRpcRemote.d.ts} +4 -4
  55. package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.js → webrtc/WebrtcConnectorRpcRemote.js} +6 -8
  56. package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -0
  57. package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.d.ts +1 -1
  58. package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js.map +1 -1
  59. package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +26 -0
  60. package/dist/src/connection/websocket/AutoCertifierClientFacade.js +37 -0
  61. package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -0
  62. package/dist/src/connection/{WebSocket/ClientWebSocket.d.ts → websocket/ClientWebsocket.d.ts} +5 -4
  63. package/dist/src/connection/{WebSocket/ClientWebSocket.js → websocket/ClientWebsocket.js} +23 -16
  64. package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -0
  65. package/dist/src/connection/{WebSocket/ServerWebSocket.d.ts → websocket/ServerWebsocket.d.ts} +2 -2
  66. package/dist/src/connection/{WebSocket/ServerWebSocket.js → websocket/ServerWebsocket.js} +25 -27
  67. package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -0
  68. package/dist/src/connection/websocket/WebsocketConnector.d.ts +53 -0
  69. package/dist/src/connection/websocket/WebsocketConnector.js +242 -0
  70. package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -0
  71. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +17 -0
  72. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +26 -0
  73. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -0
  74. package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.d.ts → websocket/WebsocketConnectorRpcRemote.d.ts} +3 -3
  75. package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js → websocket/WebsocketConnectorRpcRemote.js} +6 -11
  76. package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -0
  77. package/dist/src/connection/{WebSocket/WebSocketServer.d.ts → websocket/WebsocketServer.d.ts} +6 -3
  78. package/dist/src/connection/{WebSocket/WebSocketServer.js → websocket/WebsocketServer.js} +39 -19
  79. package/dist/src/connection/websocket/WebsocketServer.js.map +1 -0
  80. package/dist/src/dht/DhtNode.d.ts +11 -19
  81. package/dist/src/dht/DhtNode.js +135 -163
  82. package/dist/src/dht/DhtNode.js.map +1 -1
  83. package/dist/src/dht/DhtNodeRpcLocal.d.ts +22 -0
  84. package/dist/src/dht/DhtNodeRpcLocal.js +42 -0
  85. package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -0
  86. package/dist/src/dht/{RemoteDhtNode.d.ts → DhtNodeRpcRemote.d.ts} +5 -3
  87. package/dist/src/dht/{RemoteDhtNode.js → DhtNodeRpcRemote.js} +20 -24
  88. package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -0
  89. package/dist/src/dht/ExternalApiRpcLocal.d.ts +16 -0
  90. package/dist/src/dht/ExternalApiRpcLocal.js +30 -0
  91. package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -0
  92. package/dist/src/dht/ExternalApiRpcRemote.d.ts +1 -1
  93. package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
  94. package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
  95. package/dist/src/dht/contact/Remote.d.ts +4 -1
  96. package/dist/src/dht/contact/Remote.js +28 -2
  97. package/dist/src/dht/contact/Remote.js.map +1 -1
  98. package/dist/src/dht/contact/SortedContactList.d.ts +2 -2
  99. package/dist/src/dht/contact/SortedContactList.js +3 -3
  100. package/dist/src/dht/contact/SortedContactList.js.map +1 -1
  101. package/dist/src/dht/discovery/DiscoverySession.d.ts +9 -7
  102. package/dist/src/dht/discovery/DiscoverySession.js +9 -9
  103. package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
  104. package/dist/src/dht/discovery/PeerDiscovery.d.ts +7 -10
  105. package/dist/src/dht/discovery/PeerDiscovery.js +6 -6
  106. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
  107. package/dist/src/dht/find/FindRpcLocal.d.ts +14 -0
  108. package/dist/src/dht/find/FindRpcLocal.js +25 -0
  109. package/dist/src/dht/find/FindRpcLocal.js.map +1 -0
  110. package/dist/src/dht/find/{RecursiveFindSession.d.ts → FindSession.d.ts} +12 -13
  111. package/dist/src/dht/find/{RecursiveFindSession.js → FindSession.js} +17 -15
  112. package/dist/src/dht/find/FindSession.js.map +1 -0
  113. package/dist/src/dht/find/FindSessionRpcLocal.d.ts +12 -0
  114. package/dist/src/dht/find/FindSessionRpcLocal.js +17 -0
  115. package/dist/src/dht/find/FindSessionRpcLocal.js.map +1 -0
  116. package/dist/src/dht/find/{RemoteRecursiveFindSession.d.ts → FindSessionRpcRemote.d.ts} +2 -2
  117. package/dist/src/dht/find/{RemoteRecursiveFindSession.js → FindSessionRpcRemote.js} +5 -5
  118. package/dist/src/dht/find/FindSessionRpcRemote.js.map +1 -0
  119. package/dist/src/dht/find/{RecursiveFinder.d.ts → Finder.d.ts} +16 -19
  120. package/dist/src/dht/find/{RecursiveFinder.js → Finder.js} +50 -46
  121. package/dist/src/dht/find/Finder.js.map +1 -0
  122. package/dist/src/dht/routing/FindRpcRemote.d.ts +6 -0
  123. package/dist/src/dht/routing/FindRpcRemote.js +41 -0
  124. package/dist/src/dht/routing/FindRpcRemote.js.map +1 -0
  125. package/dist/src/dht/routing/Router.d.ts +10 -17
  126. package/dist/src/dht/routing/Router.js +50 -93
  127. package/dist/src/dht/routing/Router.js.map +1 -1
  128. package/dist/src/dht/routing/RouterRpcLocal.d.ts +22 -0
  129. package/dist/src/dht/routing/RouterRpcLocal.js +66 -0
  130. package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -0
  131. package/dist/src/dht/routing/RouterRpcRemote.d.ts +0 -1
  132. package/dist/src/dht/routing/RouterRpcRemote.js +17 -45
  133. package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
  134. package/dist/src/dht/routing/RoutingSession.d.ts +17 -8
  135. package/dist/src/dht/routing/RoutingSession.js +124 -131
  136. package/dist/src/dht/routing/RoutingSession.js.map +1 -1
  137. package/dist/src/dht/routing/getPreviousPeer.d.ts +2 -0
  138. package/dist/src/dht/routing/getPreviousPeer.js +9 -0
  139. package/dist/src/dht/routing/getPreviousPeer.js.map +1 -0
  140. package/dist/src/dht/store/StoreRpcLocal.d.ts +11 -8
  141. package/dist/src/dht/store/StoreRpcLocal.js +26 -25
  142. package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
  143. package/dist/src/dht/store/StoreRpcRemote.js +6 -10
  144. package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
  145. package/dist/src/exports.d.ts +11 -5
  146. package/dist/src/exports.js +17 -4
  147. package/dist/src/exports.js.map +1 -1
  148. package/dist/src/helpers/Connectivity.d.ts +4 -0
  149. package/dist/src/helpers/Connectivity.js +24 -0
  150. package/dist/src/helpers/Connectivity.js.map +1 -0
  151. package/dist/src/helpers/errors.d.ts +3 -3
  152. package/dist/src/helpers/errors.js +7 -7
  153. package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +1 -0
  154. package/dist/src/helpers/peerIdFromPeerDescriptor.js +7 -1
  155. package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
  156. package/dist/src/helpers/protoClasses.js +3 -3
  157. package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +56 -39
  158. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +49 -36
  159. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
  160. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +85 -96
  161. package/dist/src/proto/packages/dht/protos/DhtRpc.js +82 -71
  162. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
  163. package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +26 -21
  164. package/dist/src/rpc-protocol/DhtCallContext.d.ts +0 -1
  165. package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
  166. package/dist/src/transport/ITransport.d.ts +5 -6
  167. package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
  168. package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
  169. package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -1
  170. package/dist/src/transport/RoutingRpcCommunicator.js +0 -1
  171. package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
  172. package/dist/src/types/ServiceID.d.ts +1 -0
  173. package/dist/src/types/ServiceID.js +3 -0
  174. package/dist/src/types/ServiceID.js.map +1 -0
  175. package/karma.config.js +4 -4
  176. package/package.json +10 -8
  177. package/protos/DhtRpc.proto +41 -40
  178. package/src/connection/ConnectionLockHandler.ts +19 -17
  179. package/src/connection/ConnectionLockRpcLocal.ts +74 -0
  180. package/src/connection/ConnectionLockRpcRemote.ts +11 -11
  181. package/src/connection/ConnectionManager.ts +88 -130
  182. package/src/connection/ConnectivityChecker.ts +36 -34
  183. package/src/connection/ConnectorFacade.ts +91 -40
  184. package/src/connection/Handshaker.ts +20 -23
  185. package/src/connection/IConnection.ts +5 -6
  186. package/src/connection/ManagedConnection.ts +76 -101
  187. package/src/connection/{ManagedWebRtcConnection.ts → ManagedWebrtcConnection.ts} +12 -10
  188. package/src/connection/{Simulator → simulator}/Simulator.ts +4 -4
  189. package/src/connection/{Simulator → simulator}/SimulatorConnection.ts +27 -27
  190. package/src/connection/{Simulator → simulator}/SimulatorConnector.ts +22 -23
  191. package/src/connection/{Simulator → simulator}/SimulatorTransport.ts +2 -2
  192. package/src/connection/{WebRTC/BrowserWebRtcConnection.ts → webrtc/BrowserWebrtcConnection.ts} +13 -14
  193. package/src/connection/{WebRTC/IWebRtcConnection.ts → webrtc/IWebrtcConnection.ts} +2 -2
  194. package/src/connection/{WebRTC/NodeWebRtcConnection.ts → webrtc/NodeWebrtcConnection.ts} +38 -40
  195. package/src/connection/webrtc/WebrtcConnector.ts +226 -0
  196. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +132 -0
  197. package/src/connection/{WebRTC/WebRtcConnectorRpcRemote.ts → webrtc/WebrtcConnectorRpcRemote.ts} +6 -7
  198. package/src/connection/{WebRTC → webrtc}/iceServerAsString.ts +1 -1
  199. package/src/connection/websocket/AutoCertifierClientFacade.ts +91 -0
  200. package/src/connection/{WebSocket/ClientWebSocket.ts → websocket/ClientWebsocket.ts} +22 -17
  201. package/src/connection/{WebSocket/ServerWebSocket.ts → websocket/ServerWebsocket.ts} +23 -27
  202. package/src/connection/websocket/WebsocketConnector.ts +328 -0
  203. package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +41 -0
  204. package/src/connection/{WebSocket/WebSocketConnectorRpcRemote.ts → websocket/WebsocketConnectorRpcRemote.ts} +8 -14
  205. package/src/connection/{WebSocket/WebSocketServer.ts → websocket/WebsocketServer.ts} +40 -22
  206. package/src/dht/DhtNode.ts +166 -193
  207. package/src/dht/DhtNodeRpcLocal.ts +68 -0
  208. package/src/dht/{RemoteDhtNode.ts → DhtNodeRpcRemote.ts} +17 -18
  209. package/src/dht/ExternalApiRpcLocal.ts +46 -0
  210. package/src/dht/ExternalApiRpcRemote.ts +4 -4
  211. package/src/dht/contact/Remote.ts +32 -4
  212. package/src/dht/contact/SortedContactList.ts +4 -4
  213. package/src/dht/discovery/DiscoverySession.ts +25 -22
  214. package/src/dht/discovery/PeerDiscovery.ts +16 -19
  215. package/src/dht/find/FindRpcLocal.ts +35 -0
  216. package/src/dht/find/{RecursiveFindSession.ts → FindSession.ts} +25 -25
  217. package/src/dht/find/FindSessionRpcLocal.ts +25 -0
  218. package/src/dht/find/{RemoteRecursiveFindSession.ts → FindSessionRpcRemote.ts} +9 -5
  219. package/src/dht/find/{RecursiveFinder.ts → Finder.ts} +77 -71
  220. package/src/dht/routing/FindRpcRemote.ts +40 -0
  221. package/src/dht/routing/Router.ts +78 -109
  222. package/src/dht/routing/RouterRpcLocal.ts +81 -0
  223. package/src/dht/routing/RouterRpcRemote.ts +18 -49
  224. package/src/dht/routing/RoutingSession.ts +58 -63
  225. package/src/dht/routing/getPreviousPeer.ts +6 -0
  226. package/src/dht/store/StoreRpcLocal.ts +46 -39
  227. package/src/dht/store/StoreRpcRemote.ts +8 -12
  228. package/src/exports.ts +11 -5
  229. package/src/helpers/Connectivity.ts +19 -0
  230. package/src/helpers/errors.ts +3 -3
  231. package/src/helpers/peerIdFromPeerDescriptor.ts +6 -0
  232. package/src/helpers/protoClasses.ts +6 -6
  233. package/src/proto/packages/dht/protos/DhtRpc.client.ts +75 -59
  234. package/src/proto/packages/dht/protos/DhtRpc.server.ts +26 -21
  235. package/src/proto/packages/dht/protos/DhtRpc.ts +112 -131
  236. package/src/rpc-protocol/DhtCallContext.ts +0 -1
  237. package/src/transport/ITransport.ts +5 -8
  238. package/src/transport/ListeningRpcCommunicator.ts +2 -1
  239. package/src/transport/RoutingRpcCommunicator.ts +3 -4
  240. package/src/types/ServiceID.ts +1 -0
  241. package/test/benchmark/{RecursiveFind.test.ts → Find.test.ts} +7 -7
  242. package/test/benchmark/KademliaCorrectness.test.ts +3 -3
  243. package/test/benchmark/kademlia-simulation/SimulationNode.ts +3 -3
  244. package/test/end-to-end/Layer0-Layer1.test.ts +13 -5
  245. package/test/end-to-end/Layer0.test.ts +35 -17
  246. package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +28 -9
  247. package/test/end-to-end/{Layer0WebRTC-Layer1.test.ts → Layer0Webrtc-Layer1.test.ts} +1 -1
  248. package/test/end-to-end/{Layer0WebRTC.test.ts → Layer0Webrtc.test.ts} +14 -10
  249. package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +8 -4
  250. package/test/end-to-end/{Layer1-Scale-WebRTC.test.ts → Layer1-Scale-Webrtc.test.ts} +2 -2
  251. package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +52 -0
  252. package/test/end-to-end/{WebSocketConnectionRequest.test.ts → WebsocketConnectionRequest.test.ts} +16 -8
  253. package/test/end-to-end/memory-leak.test.ts +85 -0
  254. package/test/integration/ConnectionLocking.test.ts +10 -7
  255. package/test/integration/ConnectionManager.test.ts +107 -30
  256. package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
  257. package/test/integration/DhtNodeExternalAPI.test.ts +10 -10
  258. package/test/integration/{RemoteDhtNode.test.ts → DhtNodeRpcRemote.test.ts} +10 -10
  259. package/test/integration/DhtRpc.test.ts +5 -5
  260. package/test/integration/{RecursiveFind.test.ts → Find.test.ts} +6 -9
  261. package/test/integration/Layer1-scale.test.ts +1 -1
  262. package/test/integration/MigrateData.test.ts +8 -7
  263. package/test/integration/Mock-Layer1-Layer0.test.ts +1 -1
  264. package/test/integration/MultipleEntryPointJoining.test.ts +8 -8
  265. package/test/integration/RouteMessage.test.ts +26 -26
  266. package/test/integration/RpcErrors.test.ts +10 -10
  267. package/test/integration/ScaleDownDht.test.ts +6 -6
  268. package/test/integration/SimultaneousConnections.test.ts +10 -7
  269. package/test/integration/Store.test.ts +4 -7
  270. package/test/integration/StoreAndDelete.test.ts +4 -7
  271. package/test/integration/StoreOnDhtWithTwoNodes.test.ts +12 -12
  272. package/test/integration/{WebRtcConnectionManagement.test.ts → WebrtcConnectionManagement.test.ts} +5 -5
  273. package/test/integration/{WebRtcConnectorRpc.test.ts → WebrtcConnectorRpc.test.ts} +7 -8
  274. package/test/integration/{WebSocket.test.ts → Websocket.test.ts} +14 -13
  275. package/test/integration/{WebSocketConnectionManagement.test.ts → WebsocketConnectionManagement.test.ts} +4 -4
  276. package/test/integration/{WebSocketConnectorRpc.test.ts → WebsocketConnectorRpc.test.ts} +15 -15
  277. package/test/unit/AutoCertifierClientFacade.test.ts +58 -0
  278. package/test/unit/ConnectivityHelpers.test.ts +69 -0
  279. package/test/unit/{RecursiveFinder.test.ts → Finder.test.ts} +19 -17
  280. package/test/unit/Router.test.ts +26 -26
  281. package/test/unit/UUID.test.ts +1 -1
  282. package/test/unit/{WebSocketConnectorRpcLocal.test.ts → WebsocketConnector.test.ts} +8 -8
  283. package/test/unit/{WebSocketServer.test.ts → WebsocketServer.test.ts} +20 -14
  284. package/test/unit/webrtcReplaceInternalIpWithExternalIp.test.ts +1 -1
  285. package/test/utils/FakeRpcCommunicator.ts +23 -0
  286. package/test/utils/mock/Transport.ts +1 -1
  287. package/test/utils/utils.ts +22 -26
  288. package/tsconfig.browser.json +1 -1
  289. package/tsconfig.jest.json +3 -2
  290. package/tsconfig.node.json +3 -2
  291. package/dist/src/connection/ManagedWebRtcConnection.d.ts +0 -7
  292. package/dist/src/connection/ManagedWebRtcConnection.js +0 -20
  293. package/dist/src/connection/ManagedWebRtcConnection.js.map +0 -1
  294. package/dist/src/connection/Simulator/SimulatorConnection.js.map +0 -1
  295. package/dist/src/connection/Simulator/SimulatorConnector.js.map +0 -1
  296. package/dist/src/connection/Simulator/SimulatorTransport.js.map +0 -1
  297. package/dist/src/connection/WebRTC/IWebRtcConnection.js.map +0 -1
  298. package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +0 -1
  299. package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.d.ts +0 -51
  300. package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js +0 -249
  301. package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js.map +0 -1
  302. package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js.map +0 -1
  303. package/dist/src/connection/WebSocket/ClientWebSocket.js.map +0 -1
  304. package/dist/src/connection/WebSocket/ServerWebSocket.js.map +0 -1
  305. package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.d.ts +0 -45
  306. package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js +0 -234
  307. package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js.map +0 -1
  308. package/dist/src/connection/WebSocket/WebSocketConnectorRpcRemote.js.map +0 -1
  309. package/dist/src/connection/WebSocket/WebSocketServer.js.map +0 -1
  310. package/dist/src/dht/RemoteDhtNode.js.map +0 -1
  311. package/dist/src/dht/find/RecursiveFindSession.js.map +0 -1
  312. package/dist/src/dht/find/RecursiveFinder.js.map +0 -1
  313. package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +0 -1
  314. package/dist/src/dht/registerExternalApiRpcMethods.d.ts +0 -2
  315. package/dist/src/dht/registerExternalApiRpcMethods.js +0 -32
  316. package/dist/src/dht/registerExternalApiRpcMethods.js.map +0 -1
  317. package/src/connection/WebRTC/WebRtcConnectorRpcLocal.ts +0 -335
  318. package/src/connection/WebSocket/WebSocketConnectorRpcLocal.ts +0 -295
  319. package/src/dht/registerExternalApiRpcMethods.ts +0 -44
  320. package/test/utils/mock/RecursiveFinder.ts +0 -19
  321. /package/dist/src/connection/{Simulator → simulator}/Simulator.d.ts +0 -0
  322. /package/dist/src/connection/{Simulator → simulator}/pings.d.ts +0 -0
  323. /package/dist/src/connection/{Simulator → simulator}/pings.js +0 -0
  324. /package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js +0 -0
  325. /package/src/connection/{Simulator → simulator}/pings.ts +0 -0
@@ -4,7 +4,7 @@ import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
4
4
  import { Logger, runAndWaitForEvents3, waitForCondition } from '@streamr/utils'
5
5
  import { createMockConnectionDhtNode, createWrappedClosestPeersRequest } from '../utils/utils'
6
6
  import { PeerID } from '../../src/helpers/PeerID'
7
- import { Simulator } from '../../src/connection/Simulator/Simulator'
7
+ import { Simulator } from '../../src/connection/simulator/Simulator'
8
8
  import { v4 } from 'uuid'
9
9
  import { Any } from '../../src/proto/google/protobuf/any'
10
10
  import { RoutingMode } from '../../src/dht/routing/RoutingSession'
@@ -65,7 +65,7 @@ describe('Route Message With Mock Connections', () => {
65
65
  }, 10000)
66
66
 
67
67
  it('Happy path', async () => {
68
- const rpcWrapper = createWrappedClosestPeersRequest(sourceNode.getPeerDescriptor())
68
+ const rpcWrapper = createWrappedClosestPeersRequest(sourceNode.getLocalPeerDescriptor())
69
69
  const message: Message = {
70
70
  serviceId: 'unknown',
71
71
  messageId: v4(),
@@ -74,16 +74,16 @@ describe('Route Message With Mock Connections', () => {
74
74
  oneofKind: 'rpcMessage',
75
75
  rpcMessage: rpcWrapper
76
76
  },
77
- sourceDescriptor: sourceNode.getPeerDescriptor(),
78
- targetDescriptor: destinationNode.getPeerDescriptor()
77
+ sourceDescriptor: sourceNode.getLocalPeerDescriptor(),
78
+ targetDescriptor: destinationNode.getLocalPeerDescriptor()
79
79
  }
80
80
 
81
81
  await runAndWaitForEvents3<DhtNodeEvents>([() => {
82
82
  sourceNode.router!.doRouteMessage({
83
83
  message,
84
- destinationPeer: destinationNode.getPeerDescriptor(),
84
+ destinationPeer: destinationNode.getLocalPeerDescriptor(),
85
85
  requestId: v4(),
86
- sourcePeer: sourceNode.getPeerDescriptor(),
86
+ sourcePeer: sourceNode.getLocalPeerDescriptor(),
87
87
  reachableThrough: [],
88
88
  routingPath: []
89
89
 
@@ -97,7 +97,7 @@ describe('Route Message With Mock Connections', () => {
97
97
  destinationNode.on('message', () => {
98
98
  receivedMessages += 1
99
99
  })
100
- const rpcWrapper = createWrappedClosestPeersRequest(sourceNode.getPeerDescriptor())
100
+ const rpcWrapper = createWrappedClosestPeersRequest(sourceNode.getLocalPeerDescriptor())
101
101
 
102
102
  for (let i = 0; i < numOfMessages; i++) {
103
103
  const message: Message = {
@@ -108,14 +108,14 @@ describe('Route Message With Mock Connections', () => {
108
108
  oneofKind: 'rpcMessage',
109
109
  rpcMessage: rpcWrapper
110
110
  },
111
- sourceDescriptor: sourceNode.getPeerDescriptor(),
112
- targetDescriptor: destinationNode.getPeerDescriptor()
111
+ sourceDescriptor: sourceNode.getLocalPeerDescriptor(),
112
+ targetDescriptor: destinationNode.getLocalPeerDescriptor()
113
113
  }
114
114
  sourceNode.router!.doRouteMessage({
115
115
  message,
116
- destinationPeer: destinationNode.getPeerDescriptor(),
116
+ destinationPeer: destinationNode.getLocalPeerDescriptor(),
117
117
  requestId: v4(),
118
- sourcePeer: sourceNode.getPeerDescriptor(),
118
+ sourcePeer: sourceNode.getLocalPeerDescriptor(),
119
119
  reachableThrough: [],
120
120
  routingPath: []
121
121
  })
@@ -145,7 +145,7 @@ describe('Route Message With Mock Connections', () => {
145
145
  } catch (e) {
146
146
  console.error(e)
147
147
  }
148
- if (parseInt(node.getNodeId().toString()) > routerNodes.length || parseInt(node.getNodeId().toString()) < 1) {
148
+ if (parseInt(node.getNodeId().toString()) > routerNodes.length || parseInt(node.getNodeId().toString()) === 0) {
149
149
  console.error(node.getNodeId().toString())
150
150
  }
151
151
  })
@@ -155,7 +155,7 @@ describe('Route Message With Mock Connections', () => {
155
155
  routerNodes.map(async (node) =>
156
156
  Promise.all(routerNodes.map(async (receiver) => {
157
157
  if (!node.getNodeId().equals(receiver.getNodeId())) {
158
- const rpcWrapper = createWrappedClosestPeersRequest(sourceNode.getPeerDescriptor())
158
+ const rpcWrapper = createWrappedClosestPeersRequest(sourceNode.getLocalPeerDescriptor())
159
159
  const message: Message = {
160
160
  serviceId: 'nonexisting_service',
161
161
  messageId: v4(),
@@ -164,13 +164,13 @@ describe('Route Message With Mock Connections', () => {
164
164
  oneofKind: 'rpcMessage',
165
165
  rpcMessage: rpcWrapper
166
166
  },
167
- sourceDescriptor: node.getPeerDescriptor(),
168
- targetDescriptor: destinationNode.getPeerDescriptor()
167
+ sourceDescriptor: node.getLocalPeerDescriptor(),
168
+ targetDescriptor: destinationNode.getLocalPeerDescriptor()
169
169
  }
170
170
  node.router!.doRouteMessage({
171
171
  message,
172
- destinationPeer: receiver.getPeerDescriptor(),
173
- sourcePeer: node.getPeerDescriptor(),
172
+ destinationPeer: receiver.getLocalPeerDescriptor(),
173
+ sourcePeer: node.getLocalPeerDescriptor(),
174
174
  requestId: v4(),
175
175
  reachableThrough: [],
176
176
  routingPath: []
@@ -190,7 +190,7 @@ describe('Route Message With Mock Connections', () => {
190
190
  }, 90000)
191
191
 
192
192
  it('Destination receives forwarded message', async () => {
193
- const closestPeersRequest = createWrappedClosestPeersRequest(sourceNode.getPeerDescriptor())
193
+ const closestPeersRequest = createWrappedClosestPeersRequest(sourceNode.getLocalPeerDescriptor())
194
194
  const closestPeersRequestMessage: Message = {
195
195
  serviceId: 'unknown',
196
196
  messageId: v4(),
@@ -199,15 +199,15 @@ describe('Route Message With Mock Connections', () => {
199
199
  oneofKind: 'rpcMessage',
200
200
  rpcMessage: closestPeersRequest
201
201
  },
202
- sourceDescriptor: sourceNode.getPeerDescriptor()!,
203
- targetDescriptor: destinationNode.getPeerDescriptor()!
202
+ sourceDescriptor: sourceNode.getLocalPeerDescriptor()!,
203
+ targetDescriptor: destinationNode.getLocalPeerDescriptor()!
204
204
  }
205
205
 
206
206
  const routeMessageWrapper: RouteMessageWrapper = {
207
207
  message: closestPeersRequestMessage,
208
- destinationPeer: destinationNode.getPeerDescriptor(),
208
+ destinationPeer: destinationNode.getLocalPeerDescriptor(),
209
209
  requestId: v4(),
210
- sourcePeer: sourceNode.getPeerDescriptor(),
210
+ sourcePeer: sourceNode.getLocalPeerDescriptor(),
211
211
  reachableThrough: [entryPointDescriptor],
212
212
  routingPath: []
213
213
  }
@@ -229,15 +229,15 @@ describe('Route Message With Mock Connections', () => {
229
229
  oneofKind: 'rpcMessage',
230
230
  rpcMessage
231
231
  },
232
- sourceDescriptor: sourceNode.getPeerDescriptor()!,
233
- targetDescriptor: entryPoint.getPeerDescriptor()!
232
+ sourceDescriptor: sourceNode.getLocalPeerDescriptor()!,
233
+ targetDescriptor: entryPoint.getLocalPeerDescriptor()!
234
234
  }
235
235
 
236
236
  const forwardedMessage: RouteMessageWrapper = {
237
237
  message: requestMessage,
238
238
  requestId: v4(),
239
- sourcePeer: sourceNode.getPeerDescriptor(),
240
- destinationPeer: entryPoint.getPeerDescriptor()!,
239
+ sourcePeer: sourceNode.getLocalPeerDescriptor(),
240
+ destinationPeer: entryPoint.getLocalPeerDescriptor()!,
241
241
  reachableThrough: [],
242
242
  routingPath: []
243
243
  }
@@ -1,22 +1,22 @@
1
1
  import { ConnectionManager } from '../../src/connection/ConnectionManager'
2
- import { LatencyType, Simulator } from '../../src/connection/Simulator/Simulator'
2
+ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
3
3
  import { PeerID } from '../../src/helpers/PeerID'
4
4
  import { ITransport } from '../../src/transport/ITransport'
5
5
  import { v4 } from 'uuid'
6
- import { SimulatorTransport } from '../../src/connection/Simulator/SimulatorTransport'
6
+ import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
7
7
  import { DhtRpcOptions } from '../../src/rpc-protocol/DhtRpcOptions'
8
8
  import { ListeningRpcCommunicator } from '../../src/transport/ListeningRpcCommunicator'
9
9
  import { ProtoRpcClient, toProtoRpcClient } from '@streamr/proto-rpc'
10
- import { DhtRpcServiceClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
10
+ import { DhtNodeRpcClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
11
11
  import { NodeType, PeerDescriptor, PingRequest, PingResponse } from '../../src/proto/packages/dht/protos/DhtRpc'
12
12
  import { DefaultConnectorFacade } from '../../src/connection/ConnectorFacade'
13
13
  import { MetricsContext } from '@streamr/utils'
14
14
 
15
- const createConnectionManager = (ownPeerDescriptor: PeerDescriptor, transport: ITransport) => {
15
+ const createConnectionManager = (localPeerDescriptor: PeerDescriptor, transport: ITransport) => {
16
16
  return new ConnectionManager({
17
17
  createConnectorFacade: () => new DefaultConnectorFacade({
18
18
  transport,
19
- createOwnPeerDescriptor: () => ownPeerDescriptor
19
+ createLocalPeerDescriptor: () => localPeerDescriptor
20
20
  }),
21
21
  metricsContext: new MetricsContext()
22
22
  })
@@ -30,8 +30,8 @@ describe('RPC errors', () => {
30
30
  let rpcCommunicator1: ListeningRpcCommunicator
31
31
  let rpcCommunicator2: ListeningRpcCommunicator
32
32
 
33
- let client1: ProtoRpcClient<DhtRpcServiceClient>
34
- //let client2: ProtoRpcClient<DhtRpcServiceClient>
33
+ let client1: ProtoRpcClient<DhtNodeRpcClient>
34
+ //let client2: ProtoRpcClient<DhtNodeRpcClient>
35
35
 
36
36
  let simulator: Simulator
37
37
 
@@ -57,13 +57,13 @@ describe('RPC errors', () => {
57
57
  await connectorTransport1.start()
58
58
  manager1 = createConnectionManager(peerDescriptor1, connectorTransport1)
59
59
  rpcCommunicator1 = new ListeningRpcCommunicator(serviceId, manager1)
60
- client1 = toProtoRpcClient(new DhtRpcServiceClient(rpcCommunicator1.getRpcClientTransport()))
60
+ client1 = toProtoRpcClient(new DhtNodeRpcClient(rpcCommunicator1.getRpcClientTransport()))
61
61
 
62
62
  connectorTransport2 = new SimulatorTransport(peerDescriptor2, simulator)
63
63
  await connectorTransport2.start()
64
64
  manager2 = createConnectionManager(peerDescriptor2, connectorTransport2)
65
65
  rpcCommunicator2 = new ListeningRpcCommunicator(serviceId, manager2)
66
- //client2 = toProtoRpcClient(new DhtRpcServiceClient(rpcCommunicator2.getRpcClientTransport()))
66
+ //client2 = toProtoRpcClient(new DhtNodeRpcClient(rpcCommunicator2.getRpcClientTransport()))
67
67
 
68
68
  await manager1.start()
69
69
  await manager2.start()
@@ -133,7 +133,7 @@ describe('RPC errors', () => {
133
133
 
134
134
  }, 60000)
135
135
 
136
- it('Disconnects WebRtcConnection while being connected', async () => {
136
+ it('Disconnects WebrtcConnection while being connected', async () => {
137
137
 
138
138
  const rpcMessage: RpcMessage = {
139
139
  header: {},
@@ -1,8 +1,8 @@
1
- import { LatencyType, Simulator } from '../../src/connection/Simulator/Simulator'
1
+ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
2
2
  import { DhtNode } from '../../src/dht/DhtNode'
3
3
  import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
4
4
  import { createMockConnectionDhtNode } from '../utils/utils'
5
- import { areEqualPeerDescriptors, keyFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
5
+ import { areEqualPeerDescriptors, getNodeIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
6
6
  import { Logger } from '@streamr/utils'
7
7
 
8
8
  const logger = new Logger(module)
@@ -11,7 +11,7 @@ describe('Scaling down a Dht network', () => {
11
11
  let entryPoint: DhtNode
12
12
  let nodes: DhtNode[]
13
13
  let entrypointDescriptor: PeerDescriptor
14
- const simulator = new Simulator(LatencyType.RANDOM)
14
+ const simulator = new Simulator(LatencyType.REAL)
15
15
  const NUM_NODES = 80
16
16
  const MAX_CONNECTIONS = 15
17
17
  const K = 2
@@ -49,13 +49,13 @@ describe('Scaling down a Dht network', () => {
49
49
  const index = Math.floor(Math.random() * randomIndices.length)
50
50
  const nodeIndex = randomIndices[index]
51
51
  randomIndices.splice(index, 1)
52
- const stoppingPeerDescriptor = nodes[nodeIndex].getPeerDescriptor()
52
+ const stoppingPeerDescriptor = nodes[nodeIndex].getLocalPeerDescriptor()
53
53
  await nodes[nodeIndex].stop()
54
54
  const nodeIsCleaned = nodes.every((node) =>
55
55
  node.getAllConnectionPeerDescriptors().every((peer) => {
56
56
  if (areEqualPeerDescriptors(peer, stoppingPeerDescriptor)) {
57
- logger.error(keyFromPeerDescriptor(node.getPeerDescriptor()) + ', '
58
- + keyFromPeerDescriptor(stoppingPeerDescriptor) + ' cleaning up failed')
57
+ logger.error(getNodeIdFromPeerDescriptor(node.getLocalPeerDescriptor()) + ', '
58
+ + getNodeIdFromPeerDescriptor(stoppingPeerDescriptor) + ' cleaning up failed')
59
59
  }
60
60
  return !areEqualPeerDescriptors(peer, stoppingPeerDescriptor)
61
61
  })
@@ -1,16 +1,16 @@
1
1
  import { MetricsContext, waitForCondition } from '@streamr/utils'
2
2
  import { ConnectionManager } from '../../src/connection/ConnectionManager'
3
3
  import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../../src/connection/ConnectorFacade'
4
- import { Simulator } from '../../src/connection/Simulator/Simulator'
5
- import { SimulatorTransport } from '../../src/connection/Simulator/SimulatorTransport'
4
+ import { Simulator } from '../../src/connection/simulator/Simulator'
5
+ import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
6
6
  import { PeerID } from '../../src/helpers/PeerID'
7
7
  import { Message, MessageType, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
8
8
  import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
9
9
 
10
- const createConnectionManager = (ownPeerDescriptor: PeerDescriptor, opts: Omit<DefaultConnectorFacadeConfig, 'createOwnPeerDescriptor'>) => {
10
+ const createConnectionManager = (localPeerDescriptor: PeerDescriptor, opts: Omit<DefaultConnectorFacadeConfig, 'createLocalPeerDescriptor'>) => {
11
11
  return new ConnectionManager({
12
12
  createConnectorFacade: () => new DefaultConnectorFacade({
13
- createOwnPeerDescriptor: () => ownPeerDescriptor,
13
+ createLocalPeerDescriptor: () => localPeerDescriptor,
14
14
  ...opts
15
15
  }),
16
16
  metricsContext: new MetricsContext()
@@ -118,12 +118,14 @@ describe('SimultaneousConnections', () => {
118
118
  connectionManager1 = createConnectionManager(wsPeer1, {
119
119
  transport: simulatorTransport1,
120
120
  websocketPortRange,
121
- entryPoints: [wsPeer1]
121
+ entryPoints: [wsPeer1],
122
+ websocketServerEnableTls: false
122
123
  })
123
124
  connectionManager2 = createConnectionManager(wsPeer2, {
124
125
  transport: simulatorTransport2,
125
126
  websocketPortRange,
126
- entryPoints: [wsPeer1]
127
+ entryPoints: [wsPeer1],
128
+ websocketServerEnableTls: false
127
129
  })
128
130
  await connectionManager1.start()
129
131
  await connectionManager2.start()
@@ -193,7 +195,8 @@ describe('SimultaneousConnections', () => {
193
195
  connectionManager1 = createConnectionManager(wsPeer1, {
194
196
  transport: simulatorTransport1,
195
197
  websocketPortRange: { min: 43432, max: 43432 },
196
- entryPoints: [wsPeer1]
198
+ entryPoints: [wsPeer1],
199
+ websocketServerEnableTls: false
197
200
  })
198
201
  connectionManager2 = createConnectionManager(wsPeer2, {
199
202
  transport: simulatorTransport2
@@ -1,6 +1,6 @@
1
- import { LatencyType, Simulator } from '../../src/connection/Simulator/Simulator'
1
+ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
2
2
  import { DhtNode } from '../../src/dht/DhtNode'
3
- import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
3
+ import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
4
4
  import { createMockConnectionDhtNode, waitConnectionManagersReadyForTesting } from '../utils/utils'
5
5
  import { PeerID } from '../../src/helpers/PeerID'
6
6
  import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
@@ -10,7 +10,7 @@ describe('Storing data in DHT', () => {
10
10
  let entryPoint: DhtNode
11
11
  let nodes: DhtNode[]
12
12
  let entrypointDescriptor: PeerDescriptor
13
- const simulator = new Simulator(LatencyType.RANDOM)
13
+ const simulator = new Simulator(LatencyType.REAL)
14
14
  const NUM_NODES = 100
15
15
  const MAX_CONNECTIONS = 20
16
16
  const K = 4
@@ -27,10 +27,7 @@ describe('Storing data in DHT', () => {
27
27
  undefined, K, MAX_CONNECTIONS)
28
28
  nodes.push(entryPoint)
29
29
  nodeIndicesById[entryPoint.getNodeId().toKey()] = 0
30
- entrypointDescriptor = {
31
- kademliaId: entryPoint.getNodeId().value,
32
- type: NodeType.NODEJS
33
- }
30
+ entrypointDescriptor = entryPoint.getLocalPeerDescriptor()
34
31
  nodes.push(entryPoint)
35
32
  for (let i = 1; i < NUM_NODES; i++) {
36
33
  const nodeId = `${i}`
@@ -1,6 +1,6 @@
1
- import { LatencyType, Simulator } from '../../src/connection/Simulator/Simulator'
1
+ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
2
2
  import { DhtNode } from '../../src/dht/DhtNode'
3
- import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
3
+ import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
4
4
  import { createMockConnectionDhtNode, waitConnectionManagersReadyForTesting } from '../utils/utils'
5
5
  import { PeerID } from '../../src/helpers/PeerID'
6
6
  import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
@@ -10,7 +10,7 @@ describe('Storing data in DHT', () => {
10
10
  let entryPoint: DhtNode
11
11
  let nodes: DhtNode[]
12
12
  let entrypointDescriptor: PeerDescriptor
13
- const simulator = new Simulator(LatencyType.RANDOM)
13
+ const simulator = new Simulator(LatencyType.REAL)
14
14
  const NUM_NODES = 5
15
15
  const MAX_CONNECTIONS = 5
16
16
  const K = 4
@@ -27,10 +27,7 @@ describe('Storing data in DHT', () => {
27
27
  undefined, K, MAX_CONNECTIONS)
28
28
  nodes.push(entryPoint)
29
29
  nodeIndicesById[entryPoint.getNodeId().toKey()] = 0
30
- entrypointDescriptor = {
31
- kademliaId: entryPoint.getNodeId().value,
32
- type: NodeType.NODEJS
33
- }
30
+ entrypointDescriptor = entryPoint.getLocalPeerDescriptor()
34
31
  nodes.push(entryPoint)
35
32
  for (let i = 1; i < NUM_NODES; i++) {
36
33
  const nodeId = `${i}`
@@ -1,6 +1,6 @@
1
1
  import { createMockConnectionDhtNode } from '../utils/utils'
2
2
  import { DhtNode } from '../../src/dht/DhtNode'
3
- import { Simulator } from '../../src/connection/Simulator/Simulator'
3
+ import { Simulator } from '../../src/connection/simulator/Simulator'
4
4
  import { PeerID } from '../../src/helpers/PeerID'
5
5
  import { Any } from '../../src/proto/google/protobuf/any'
6
6
  import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
@@ -30,8 +30,8 @@ describe('Storing data in DHT with two peers', () => {
30
30
  await entryPoint.start()
31
31
  await otherNode.start()
32
32
 
33
- await entryPoint.joinDht([entryPoint.getPeerDescriptor()])
34
- await otherNode.joinDht([entryPoint.getPeerDescriptor()])
33
+ await entryPoint.joinDht([entryPoint.getLocalPeerDescriptor()])
34
+ await otherNode.joinDht([entryPoint.getLocalPeerDescriptor()])
35
35
  })
36
36
 
37
37
  afterEach(async () => {
@@ -42,30 +42,30 @@ describe('Storing data in DHT with two peers', () => {
42
42
 
43
43
  it('Node can store on two peer DHT', async () => {
44
44
  const dataKey1 = PeerID.fromString('node0-stored-data')
45
- const data1 = Any.pack(otherNode.getPeerDescriptor(), PeerDescriptor)
45
+ const data1 = Any.pack(otherNode.getLocalPeerDescriptor(), PeerDescriptor)
46
46
  const dataKey2 = PeerID.fromString('other-node-stored-data')
47
- const data2 = Any.pack(entryPoint.getPeerDescriptor(), PeerDescriptor)
47
+ const data2 = Any.pack(entryPoint.getLocalPeerDescriptor(), PeerDescriptor)
48
48
 
49
49
  const successfulStorers1 = await otherNode.storeDataToDht(dataKey1.value, data1)
50
50
  const successfulStorers2 = await entryPoint.storeDataToDht(dataKey2.value, data2)
51
- expect(successfulStorers1[0].kademliaId).toStrictEqual(entryPoint.getPeerDescriptor().kademliaId)
52
- expect(successfulStorers2[0].kademliaId).toStrictEqual(otherNode.getPeerDescriptor().kademliaId)
51
+ expect(successfulStorers1[0].kademliaId).toStrictEqual(entryPoint.getLocalPeerDescriptor().kademliaId)
52
+ expect(successfulStorers2[0].kademliaId).toStrictEqual(otherNode.getLocalPeerDescriptor().kademliaId)
53
53
 
54
54
  const foundData1 = await otherNode.getDataFromDht(dataKey1.value)
55
55
  const foundData2 = await entryPoint.getDataFromDht(dataKey2.value)
56
- expect(areEqualPeerDescriptors(otherNode.getPeerDescriptor(), Any.unpack(foundData1[0]!.data!, PeerDescriptor))).toBeTrue()
57
- expect(areEqualPeerDescriptors(entryPoint.getPeerDescriptor(), Any.unpack(foundData2[0]!.data!, PeerDescriptor))).toBeTrue()
56
+ expect(areEqualPeerDescriptors(otherNode.getLocalPeerDescriptor(), Any.unpack(foundData1[0]!.data!, PeerDescriptor))).toBeTrue()
57
+ expect(areEqualPeerDescriptors(entryPoint.getLocalPeerDescriptor(), Any.unpack(foundData2[0]!.data!, PeerDescriptor))).toBeTrue()
58
58
  })
59
59
 
60
60
  it('Can store on one peer DHT', async () => {
61
61
  await otherNode.stop()
62
62
  await waitForCondition(() => entryPoint.getBucketSize() === 0)
63
63
  const dataKey = PeerID.fromString('data-to-store')
64
- const data = Any.pack(entryPoint.getPeerDescriptor(), PeerDescriptor)
64
+ const data = Any.pack(entryPoint.getLocalPeerDescriptor(), PeerDescriptor)
65
65
  const successfulStorers = await entryPoint.storeDataToDht(dataKey.value, data)
66
- expect(successfulStorers[0].kademliaId).toStrictEqual(entryPoint.getPeerDescriptor().kademliaId)
66
+ expect(successfulStorers[0].kademliaId).toStrictEqual(entryPoint.getLocalPeerDescriptor().kademliaId)
67
67
 
68
68
  const foundData = await entryPoint.getDataFromDht(dataKey.value)
69
- expect(areEqualPeerDescriptors(entryPoint.getPeerDescriptor(), Any.unpack(foundData[0]!.data!, PeerDescriptor))).toBeTrue()
69
+ expect(areEqualPeerDescriptors(entryPoint.getLocalPeerDescriptor(), Any.unpack(foundData[0]!.data!, PeerDescriptor))).toBeTrue()
70
70
  }, 60000)
71
71
  })
@@ -1,20 +1,20 @@
1
1
  import { ConnectionManager } from '../../src/connection/ConnectionManager'
2
- import { LatencyType, Simulator } from '../../src/connection/Simulator/Simulator'
2
+ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
3
3
  import { Message, MessageType, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
4
4
  import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
5
5
  import { PeerID } from '../../src/helpers/PeerID'
6
6
  import { ConnectionType } from '../../src/connection/IConnection'
7
7
  import { ITransport } from '../../src/transport/ITransport'
8
8
  import * as Err from '../../src/helpers/errors'
9
- import { SimulatorTransport } from '../../src/connection/Simulator/SimulatorTransport'
9
+ import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
10
10
  import { DefaultConnectorFacade } from '../../src/connection/ConnectorFacade'
11
11
  import { MetricsContext } from '@streamr/utils'
12
12
 
13
- const createConnectionManager = (ownPeerDescriptor: PeerDescriptor, transport: ITransport) => {
13
+ const createConnectionManager = (localPeerDescriptor: PeerDescriptor, transport: ITransport) => {
14
14
  return new ConnectionManager({
15
15
  createConnectorFacade: () => new DefaultConnectorFacade({
16
16
  transport,
17
- createOwnPeerDescriptor: () => ownPeerDescriptor
17
+ createLocalPeerDescriptor: () => localPeerDescriptor
18
18
  }),
19
19
  metricsContext: new MetricsContext()
20
20
  })
@@ -200,7 +200,7 @@ describe('WebRTC Connection Management', () => {
200
200
 
201
201
  msg.targetDescriptor = peerDescriptor2
202
202
  manager1.send(msg).catch((e) => {
203
- expect(e.code).toEqual('CONNECTION_FAILED')
203
+ expect(e.code).toEqual('SEND_FAILED')
204
204
  })
205
205
 
206
206
  // @ts-expect-error private field
@@ -1,23 +1,23 @@
1
1
  import { ProtoRpcClient, RpcCommunicator, toProtoRpcClient } from '@streamr/proto-rpc'
2
- import { WebRtcConnectorRpcClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
2
+ import { WebrtcConnectorRpcClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
3
3
  import {
4
4
  IceCandidate,
5
5
  NodeType,
6
6
  PeerDescriptor,
7
7
  RtcAnswer,
8
8
  RtcOffer,
9
- WebRtcConnectionRequest
9
+ WebrtcConnectionRequest
10
10
  } from '../../src/proto/packages/dht/protos/DhtRpc'
11
11
  import { Empty } from '../../src/proto/google/protobuf/empty'
12
12
  import { generateId } from '../utils/utils'
13
- import { IWebRtcConnectorRpc } from '../../src/proto/packages/dht/protos/DhtRpc.server'
13
+ import { IWebrtcConnectorRpc } from '../../src/proto/packages/dht/protos/DhtRpc.server'
14
14
  import { waitForCondition } from '@streamr/utils'
15
15
  import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
16
16
 
17
17
  describe('WebRTC rpc messages', () => {
18
18
  let rpcCommunicator1: RpcCommunicator
19
19
  let rpcCommunicator2: RpcCommunicator
20
- let client: ProtoRpcClient<WebRtcConnectorRpcClient>
20
+ let client: ProtoRpcClient<WebrtcConnectorRpcClient>
21
21
 
22
22
  let requestConnectionCounter: number
23
23
  let rtcOfferCounter: number
@@ -36,7 +36,7 @@ describe('WebRTC rpc messages', () => {
36
36
  iceCandidateCounter = 0
37
37
 
38
38
  rpcCommunicator1 = new RpcCommunicator()
39
- const serverFunctions: IWebRtcConnectorRpc = {
39
+ const serverFunctions: IWebrtcConnectorRpc = {
40
40
 
41
41
  requestConnection: async (): Promise<Empty> => {
42
42
  requestConnectionCounter += 1
@@ -67,7 +67,7 @@ describe('WebRTC rpc messages', () => {
67
67
  rpcCommunicator2.registerRpcNotification(RtcOffer, 'rtcOffer', serverFunctions.rtcOffer)
68
68
  rpcCommunicator2.registerRpcNotification(RtcAnswer, 'rtcAnswer', serverFunctions.rtcAnswer)
69
69
  rpcCommunicator2.registerRpcNotification(IceCandidate, 'iceCandidate', serverFunctions.iceCandidate)
70
- rpcCommunicator2.registerRpcNotification(WebRtcConnectionRequest, 'requestConnection', serverFunctions.requestConnection)
70
+ rpcCommunicator2.registerRpcNotification(WebrtcConnectionRequest, 'requestConnection', serverFunctions.requestConnection)
71
71
 
72
72
  rpcCommunicator1.on('outgoingMessage', (message: RpcMessage) => {
73
73
  rpcCommunicator2.handleIncomingMessage(message)
@@ -77,7 +77,7 @@ describe('WebRTC rpc messages', () => {
77
77
  rpcCommunicator1.handleIncomingMessage(message)
78
78
  })
79
79
 
80
- client = toProtoRpcClient(new WebRtcConnectorRpcClient(rpcCommunicator1.getRpcClientTransport()))
80
+ client = toProtoRpcClient(new WebrtcConnectorRpcClient(rpcCommunicator1.getRpcClientTransport()))
81
81
  })
82
82
 
83
83
  afterEach(async () => {
@@ -87,7 +87,6 @@ describe('WebRTC rpc messages', () => {
87
87
 
88
88
  it('send connectionRequest', async () => {
89
89
  client.requestConnection({
90
- connectionId: 'connectionRequest'
91
90
  },
92
91
  { targetDescriptor, notification: true }
93
92
  )
@@ -1,26 +1,27 @@
1
1
  /* eslint-disable no-console */
2
2
 
3
- import { WebSocketServer } from '../../src/connection/WebSocket/WebSocketServer'
3
+ import { WebsocketServer } from '../../src/connection/websocket/WebsocketServer'
4
4
  import { IConnection } from '../../src/connection/IConnection'
5
- import { ClientWebSocket } from '../../src/connection/WebSocket/ClientWebSocket'
5
+ import { ClientWebsocket } from '../../src/connection/websocket/ClientWebsocket'
6
6
  import { Logger } from '@streamr/utils'
7
7
 
8
8
  const logger = new Logger(module)
9
9
 
10
- describe('WebSocket', () => {
10
+ describe('Websocket', () => {
11
11
 
12
- const webSocketServer = new WebSocketServer({
13
- portRange: { min: 9999, max: 9999 }
12
+ const websocketServer = new WebsocketServer({
13
+ portRange: { min: 9977, max: 9977 },
14
+ enableTls: false
14
15
  })
15
- const clientWebSocket = new ClientWebSocket()
16
+ const clientWebsocket = new ClientWebsocket()
16
17
 
17
18
  beforeAll(async () => {
18
- await webSocketServer.start()
19
+ await websocketServer.start()
19
20
  })
20
21
 
21
22
  it('Happy path', (done) => {
22
23
 
23
- webSocketServer.on('connected', (serverConnection: IConnection) => {
24
+ websocketServer.on('connected', (serverConnection: IConnection) => {
24
25
  const time = Date.now()
25
26
  logger.info('server side sendind msg at ' + time)
26
27
  serverConnection.send(Uint8Array.from([1, 2, 3, 4]))
@@ -40,11 +41,11 @@ describe('WebSocket', () => {
40
41
  })
41
42
  })
42
43
 
43
- clientWebSocket.on('connected', () => {
44
+ clientWebsocket.on('connected', () => {
44
45
  const time = Date.now()
45
46
  logger.info('client side setting listeners at ' + time)
46
47
 
47
- clientWebSocket.on('data', (bytes: Uint8Array) => {
48
+ clientWebsocket.on('data', (bytes: Uint8Array) => {
48
49
  const time = Date.now()
49
50
  logger.info('client side receiving message at ' + time)
50
51
 
@@ -53,14 +54,14 @@ describe('WebSocket', () => {
53
54
 
54
55
  const time2 = Date.now()
55
56
  logger.info('client side sendind msg at ' + time2)
56
- clientWebSocket.send(Uint8Array.from([1, 2, 3, 4]))
57
+ clientWebsocket.send(Uint8Array.from([1, 2, 3, 4]))
57
58
  })
58
59
  })
59
60
 
60
- clientWebSocket.connect('ws://127.0.0.1:9999')
61
+ clientWebsocket.connect('ws://127.0.0.1:9977')
61
62
  })
62
63
 
63
64
  afterAll(async () => {
64
- await webSocketServer.stop()
65
+ await websocketServer.stop()
65
66
  })
66
67
  })
@@ -4,24 +4,24 @@ import { MetricsContext, waitForCondition } from '@streamr/utils'
4
4
  import { ConnectionManager } from '../../src/connection/ConnectionManager'
5
5
  import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../../src/connection/ConnectorFacade'
6
6
  import { ConnectionType } from '../../src/connection/IConnection'
7
- import { Simulator } from '../../src/connection/Simulator/Simulator'
7
+ import { Simulator } from '../../src/connection/simulator/Simulator'
8
8
  import { SimulatorTransport } from '../../src/exports'
9
9
  import { PeerID } from '../../src/helpers/PeerID'
10
10
  import * as Err from '../../src/helpers/errors'
11
11
  import { Message, MessageType, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
12
12
  import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
13
13
 
14
- const createConfig = (ownPeerDescriptor: PeerDescriptor, opts: Omit<DefaultConnectorFacadeConfig, 'createOwnPeerDescriptor'>) => {
14
+ const createConfig = (localPeerDescriptor: PeerDescriptor, opts: Omit<DefaultConnectorFacadeConfig, 'createLocalPeerDescriptor'>) => {
15
15
  return {
16
16
  createConnectorFacade: () => new DefaultConnectorFacade({
17
- createOwnPeerDescriptor: () => ownPeerDescriptor,
17
+ createLocalPeerDescriptor: () => localPeerDescriptor,
18
18
  ...opts
19
19
  }),
20
20
  metricsContext: new MetricsContext()
21
21
  }
22
22
  }
23
23
 
24
- describe('WebSocket Connection Management', () => {
24
+ describe('Websocket Connection Management', () => {
25
25
 
26
26
  const serviceId = 'test'
27
27
  let wsServerManager: ConnectionManager