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

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 (316) 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 +6 -6
  9. package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
  10. package/dist/src/connection/ConnectionManager.d.ts +5 -8
  11. package/dist/src/connection/ConnectionManager.js +77 -107
  12. package/dist/src/connection/ConnectionManager.js.map +1 -1
  13. package/dist/src/connection/ConnectivityChecker.d.ts +7 -6
  14. package/dist/src/connection/ConnectivityChecker.js +23 -20
  15. package/dist/src/connection/ConnectivityChecker.js.map +1 -1
  16. package/dist/src/connection/ConnectorFacade.d.ts +15 -12
  17. package/dist/src/connection/ConnectorFacade.js +61 -26
  18. package/dist/src/connection/ConnectorFacade.js.map +1 -1
  19. package/dist/src/connection/Handshaker.d.ts +2 -2
  20. package/dist/src/connection/Handshaker.js +28 -28
  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 +3 -4
  25. package/dist/src/connection/ManagedConnection.js +30 -30
  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 +22 -22
  34. package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -0
  35. package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.d.ts +2 -2
  36. package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js +11 -11
  37. package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js.map +1 -1
  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} +36 -36
  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} +20 -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} +23 -27
  67. package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -0
  68. package/dist/src/connection/{WebSocket/WebSocketConnectorRpcLocal.d.ts → websocket/WebsocketConnector.d.ts} +23 -15
  69. package/dist/src/connection/{WebSocket/WebSocketConnectorRpcLocal.js → websocket/WebsocketConnector.js} +107 -101
  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} +5 -10
  76. package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js.map → websocket/WebsocketConnectorRpcRemote.js.map} +1 -1
  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 +119 -150
  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} +17 -21
  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 +8 -8
  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 +5 -5
  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 +47 -90
  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 +15 -43
  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 +25 -24
  142. package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
  143. package/dist/src/dht/store/StoreRpcRemote.js +3 -7
  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/protoClasses.js +3 -3
  154. package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +56 -39
  155. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +49 -36
  156. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
  157. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +64 -84
  158. package/dist/src/proto/packages/dht/protos/DhtRpc.js +64 -66
  159. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
  160. package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +26 -21
  161. package/dist/src/rpc-protocol/DhtCallContext.d.ts +0 -1
  162. package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
  163. package/dist/src/transport/ITransport.d.ts +5 -6
  164. package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
  165. package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
  166. package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -1
  167. package/dist/src/transport/RoutingRpcCommunicator.js +0 -1
  168. package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
  169. package/dist/src/types/ServiceID.d.ts +1 -0
  170. package/dist/src/types/ServiceID.js +3 -0
  171. package/dist/src/types/ServiceID.js.map +1 -0
  172. package/karma.config.js +4 -4
  173. package/package.json +10 -8
  174. package/protos/DhtRpc.proto +32 -35
  175. package/src/connection/ConnectionLockHandler.ts +19 -17
  176. package/src/connection/ConnectionLockRpcLocal.ts +74 -0
  177. package/src/connection/ConnectionLockRpcRemote.ts +7 -6
  178. package/src/connection/ConnectionManager.ts +59 -95
  179. package/src/connection/ConnectivityChecker.ts +30 -26
  180. package/src/connection/ConnectorFacade.ts +74 -34
  181. package/src/connection/Handshaker.ts +9 -9
  182. package/src/connection/IConnection.ts +5 -6
  183. package/src/connection/ManagedConnection.ts +21 -22
  184. package/src/connection/{ManagedWebRtcConnection.ts → ManagedWebrtcConnection.ts} +9 -9
  185. package/src/connection/{Simulator → simulator}/Simulator.ts +4 -4
  186. package/src/connection/{Simulator → simulator}/SimulatorConnection.ts +23 -24
  187. package/src/connection/{Simulator → simulator}/SimulatorConnector.ts +13 -13
  188. package/src/connection/{Simulator → simulator}/SimulatorTransport.ts +2 -2
  189. package/src/connection/{WebRTC/BrowserWebRtcConnection.ts → webrtc/BrowserWebrtcConnection.ts} +12 -13
  190. package/src/connection/{WebRTC/IWebRtcConnection.ts → webrtc/IWebrtcConnection.ts} +2 -2
  191. package/src/connection/{WebRTC/NodeWebRtcConnection.ts → webrtc/NodeWebrtcConnection.ts} +32 -33
  192. package/src/connection/webrtc/WebrtcConnector.ts +225 -0
  193. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +132 -0
  194. package/src/connection/{WebRTC/WebRtcConnectorRpcRemote.ts → webrtc/WebrtcConnectorRpcRemote.ts} +6 -7
  195. package/src/connection/{WebRTC → webrtc}/iceServerAsString.ts +1 -1
  196. package/src/connection/websocket/AutoCertifierClientFacade.ts +91 -0
  197. package/src/connection/{WebSocket/ClientWebSocket.ts → websocket/ClientWebsocket.ts} +19 -17
  198. package/src/connection/{WebSocket/ServerWebSocket.ts → websocket/ServerWebsocket.ts} +21 -27
  199. package/src/connection/{WebSocket/WebSocketConnectorRpcLocal.ts → websocket/WebsocketConnector.ts} +109 -100
  200. package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +41 -0
  201. package/src/connection/{WebSocket/WebSocketConnectorRpcRemote.ts → websocket/WebsocketConnectorRpcRemote.ts} +6 -12
  202. package/src/connection/{WebSocket/WebSocketServer.ts → websocket/WebsocketServer.ts} +40 -22
  203. package/src/dht/DhtNode.ts +144 -179
  204. package/src/dht/DhtNodeRpcLocal.ts +68 -0
  205. package/src/dht/{RemoteDhtNode.ts → DhtNodeRpcRemote.ts} +12 -13
  206. package/src/dht/ExternalApiRpcLocal.ts +46 -0
  207. package/src/dht/ExternalApiRpcRemote.ts +4 -4
  208. package/src/dht/contact/Remote.ts +32 -4
  209. package/src/dht/contact/SortedContactList.ts +4 -4
  210. package/src/dht/discovery/DiscoverySession.ts +23 -20
  211. package/src/dht/discovery/PeerDiscovery.ts +14 -17
  212. package/src/dht/find/FindRpcLocal.ts +35 -0
  213. package/src/dht/find/{RecursiveFindSession.ts → FindSession.ts} +25 -25
  214. package/src/dht/find/FindSessionRpcLocal.ts +25 -0
  215. package/src/dht/find/{RemoteRecursiveFindSession.ts → FindSessionRpcRemote.ts} +9 -5
  216. package/src/dht/find/{RecursiveFinder.ts → Finder.ts} +77 -71
  217. package/src/dht/routing/FindRpcRemote.ts +40 -0
  218. package/src/dht/routing/Router.ts +69 -105
  219. package/src/dht/routing/RouterRpcLocal.ts +81 -0
  220. package/src/dht/routing/RouterRpcRemote.ts +15 -45
  221. package/src/dht/routing/RoutingSession.ts +56 -61
  222. package/src/dht/routing/getPreviousPeer.ts +6 -0
  223. package/src/dht/store/StoreRpcLocal.ts +44 -37
  224. package/src/dht/store/StoreRpcRemote.ts +4 -8
  225. package/src/exports.ts +11 -5
  226. package/src/helpers/Connectivity.ts +19 -0
  227. package/src/helpers/errors.ts +3 -3
  228. package/src/helpers/protoClasses.ts +6 -6
  229. package/src/proto/packages/dht/protos/DhtRpc.client.ts +75 -59
  230. package/src/proto/packages/dht/protos/DhtRpc.server.ts +26 -21
  231. package/src/proto/packages/dht/protos/DhtRpc.ts +87 -114
  232. package/src/rpc-protocol/DhtCallContext.ts +0 -1
  233. package/src/transport/ITransport.ts +5 -8
  234. package/src/transport/ListeningRpcCommunicator.ts +2 -1
  235. package/src/transport/RoutingRpcCommunicator.ts +3 -4
  236. package/src/types/ServiceID.ts +1 -0
  237. package/test/benchmark/{RecursiveFind.test.ts → Find.test.ts} +6 -6
  238. package/test/benchmark/KademliaCorrectness.test.ts +2 -2
  239. package/test/benchmark/kademlia-simulation/SimulationNode.ts +3 -3
  240. package/test/end-to-end/Layer0-Layer1.test.ts +13 -5
  241. package/test/end-to-end/Layer0.test.ts +35 -17
  242. package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +24 -6
  243. package/test/end-to-end/{Layer0WebRTC-Layer1.test.ts → Layer0Webrtc-Layer1.test.ts} +1 -1
  244. package/test/end-to-end/{Layer0WebRTC.test.ts → Layer0Webrtc.test.ts} +14 -10
  245. package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +8 -4
  246. package/test/end-to-end/{Layer1-Scale-WebRTC.test.ts → Layer1-Scale-Webrtc.test.ts} +2 -2
  247. package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +52 -0
  248. package/test/end-to-end/{WebSocketConnectionRequest.test.ts → WebsocketConnectionRequest.test.ts} +16 -8
  249. package/test/end-to-end/memory-leak.test.ts +85 -0
  250. package/test/integration/ConnectionLocking.test.ts +4 -4
  251. package/test/integration/ConnectionManager.test.ts +37 -28
  252. package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
  253. package/test/integration/DhtNodeExternalAPI.test.ts +10 -10
  254. package/test/integration/{RemoteDhtNode.test.ts → DhtNodeRpcRemote.test.ts} +10 -10
  255. package/test/integration/DhtRpc.test.ts +5 -5
  256. package/test/integration/{RecursiveFind.test.ts → Find.test.ts} +3 -3
  257. package/test/integration/Layer1-scale.test.ts +1 -1
  258. package/test/integration/MigrateData.test.ts +6 -5
  259. package/test/integration/Mock-Layer1-Layer0.test.ts +1 -1
  260. package/test/integration/MultipleEntryPointJoining.test.ts +6 -6
  261. package/test/integration/RouteMessage.test.ts +26 -26
  262. package/test/integration/RpcErrors.test.ts +10 -10
  263. package/test/integration/ScaleDownDht.test.ts +3 -3
  264. package/test/integration/SimultaneousConnections.test.ts +10 -7
  265. package/test/integration/Store.test.ts +1 -1
  266. package/test/integration/StoreAndDelete.test.ts +1 -1
  267. package/test/integration/StoreOnDhtWithTwoNodes.test.ts +12 -12
  268. package/test/integration/{WebRtcConnectionManagement.test.ts → WebrtcConnectionManagement.test.ts} +4 -4
  269. package/test/integration/{WebRtcConnectorRpc.test.ts → WebrtcConnectorRpc.test.ts} +7 -8
  270. package/test/integration/{WebSocket.test.ts → Websocket.test.ts} +14 -13
  271. package/test/integration/{WebSocketConnectionManagement.test.ts → WebsocketConnectionManagement.test.ts} +4 -4
  272. package/test/integration/{WebSocketConnectorRpc.test.ts → WebsocketConnectorRpc.test.ts} +15 -15
  273. package/test/unit/AutoCertifierClientFacade.test.ts +58 -0
  274. package/test/unit/ConnectivityHelpers.test.ts +69 -0
  275. package/test/unit/{RecursiveFinder.test.ts → Finder.test.ts} +19 -17
  276. package/test/unit/Router.test.ts +26 -26
  277. package/test/unit/UUID.test.ts +1 -1
  278. package/test/unit/{WebSocketConnectorRpcLocal.test.ts → WebsocketConnector.test.ts} +8 -8
  279. package/test/unit/{WebSocketServer.test.ts → WebsocketServer.test.ts} +20 -14
  280. package/test/unit/webrtcReplaceInternalIpWithExternalIp.test.ts +1 -1
  281. package/test/utils/FakeRpcCommunicator.ts +23 -0
  282. package/test/utils/mock/Transport.ts +1 -1
  283. package/test/utils/utils.ts +14 -24
  284. package/tsconfig.browser.json +1 -1
  285. package/tsconfig.jest.json +3 -2
  286. package/tsconfig.node.json +3 -2
  287. package/dist/src/connection/ManagedWebRtcConnection.d.ts +0 -7
  288. package/dist/src/connection/ManagedWebRtcConnection.js +0 -20
  289. package/dist/src/connection/ManagedWebRtcConnection.js.map +0 -1
  290. package/dist/src/connection/Simulator/SimulatorConnection.js.map +0 -1
  291. package/dist/src/connection/Simulator/SimulatorTransport.js.map +0 -1
  292. package/dist/src/connection/WebRTC/IWebRtcConnection.js.map +0 -1
  293. package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +0 -1
  294. package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.d.ts +0 -51
  295. package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js +0 -249
  296. package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js.map +0 -1
  297. package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js.map +0 -1
  298. package/dist/src/connection/WebSocket/ClientWebSocket.js.map +0 -1
  299. package/dist/src/connection/WebSocket/ServerWebSocket.js.map +0 -1
  300. package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js.map +0 -1
  301. package/dist/src/connection/WebSocket/WebSocketServer.js.map +0 -1
  302. package/dist/src/dht/RemoteDhtNode.js.map +0 -1
  303. package/dist/src/dht/find/RecursiveFindSession.js.map +0 -1
  304. package/dist/src/dht/find/RecursiveFinder.js.map +0 -1
  305. package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +0 -1
  306. package/dist/src/dht/registerExternalApiRpcMethods.d.ts +0 -2
  307. package/dist/src/dht/registerExternalApiRpcMethods.js +0 -32
  308. package/dist/src/dht/registerExternalApiRpcMethods.js.map +0 -1
  309. package/src/connection/WebRTC/WebRtcConnectorRpcLocal.ts +0 -335
  310. package/src/dht/registerExternalApiRpcMethods.ts +0 -44
  311. package/test/utils/mock/RecursiveFinder.ts +0 -19
  312. /package/dist/src/connection/{Simulator → simulator}/Simulator.d.ts +0 -0
  313. /package/dist/src/connection/{Simulator → simulator}/pings.d.ts +0 -0
  314. /package/dist/src/connection/{Simulator → simulator}/pings.js +0 -0
  315. /package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js +0 -0
  316. /package/src/connection/{Simulator → simulator}/pings.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import { DhtNode } from '../../src/dht/DhtNode'
2
- import { LatencyType, Simulator } from '../../src/connection/Simulator/Simulator'
2
+ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
3
3
  import { createMockConnectionDhtNode } from '../utils/utils'
4
4
  import { Any } from '../../src/proto/google/protobuf/any'
5
5
  import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
@@ -15,7 +15,7 @@ describe('DhtNodeExternalApi', () => {
15
15
  simulator = new Simulator(LatencyType.NONE)
16
16
  dhtNode1 = await createMockConnectionDhtNode('node1', simulator)
17
17
  remote = await createMockConnectionDhtNode('remote', simulator)
18
- await dhtNode1.joinDht([dhtNode1.getPeerDescriptor()])
18
+ await dhtNode1.joinDht([dhtNode1.getLocalPeerDescriptor()])
19
19
  })
20
20
 
21
21
  afterEach(async () => {
@@ -27,26 +27,26 @@ describe('DhtNodeExternalApi', () => {
27
27
  })
28
28
 
29
29
  it('findData happy path', async () => {
30
- const data = Any.pack(dhtNode1.getPeerDescriptor(), PeerDescriptor)
30
+ const data = Any.pack(dhtNode1.getLocalPeerDescriptor(), PeerDescriptor)
31
31
  const key = PeerID.fromString('key').value
32
32
  await dhtNode1.storeDataToDht(key, data)
33
33
 
34
- const foundData = await remote.findDataViaPeer(key, dhtNode1.getPeerDescriptor())
35
- expect(Any.unpack(foundData[0].data!, PeerDescriptor)).toEqual(dhtNode1.getPeerDescriptor())
34
+ const foundData = await remote.findDataViaPeer(key, dhtNode1.getLocalPeerDescriptor())
35
+ expect(Any.unpack(foundData[0].data!, PeerDescriptor)).toEqual(dhtNode1.getLocalPeerDescriptor())
36
36
  })
37
37
 
38
38
  it('findData returns empty array if no data found', async () => {
39
- const foundData = await remote.findDataViaPeer(PeerID.fromString('key').value, dhtNode1.getPeerDescriptor())
39
+ const foundData = await remote.findDataViaPeer(PeerID.fromString('key').value, dhtNode1.getLocalPeerDescriptor())
40
40
  expect(foundData).toEqual([])
41
41
  })
42
42
 
43
43
  it('external store data happy path', async () => {
44
- const data = Any.pack(dhtNode1.getPeerDescriptor(), PeerDescriptor)
44
+ const data = Any.pack(dhtNode1.getLocalPeerDescriptor(), PeerDescriptor)
45
45
  const key = PeerID.fromString('key').value
46
46
 
47
- await remote.storeDataViaPeer(key, data, dhtNode1.getPeerDescriptor())
48
- const foundData = await remote.findDataViaPeer(key, dhtNode1.getPeerDescriptor())
49
- expect(Any.unpack(foundData[0].data!, PeerDescriptor)).toEqual(dhtNode1.getPeerDescriptor())
47
+ await remote.storeDataViaPeer(key, data, dhtNode1.getLocalPeerDescriptor())
48
+ const foundData = await remote.findDataViaPeer(key, dhtNode1.getLocalPeerDescriptor())
49
+ expect(Any.unpack(foundData[0].data!, PeerDescriptor)).toEqual(dhtNode1.getLocalPeerDescriptor())
50
50
  })
51
51
 
52
52
  })
@@ -1,4 +1,4 @@
1
- import { RemoteDhtNode } from '../../src/dht/RemoteDhtNode'
1
+ import { DhtNodeRpcRemote } from '../../src/dht/DhtNodeRpcRemote'
2
2
  import { RpcCommunicator, toProtoRpcClient } from '@streamr/proto-rpc'
3
3
  import { getMockPeers, MockDhtRpc } from '../utils/utils'
4
4
  import {
@@ -10,12 +10,12 @@ import {
10
10
  PingResponse
11
11
  } from '../../src/proto/packages/dht/protos/DhtRpc'
12
12
  import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
13
- import { DhtRpcServiceClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
13
+ import { DhtNodeRpcClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
14
14
  import { generateId } from '../utils/utils'
15
15
 
16
- describe('RemoteDhtNode', () => {
16
+ describe('DhtNodeRpcRemote', () => {
17
17
 
18
- let remoteDhtNode: RemoteDhtNode
18
+ let rpcRemote: DhtNodeRpcRemote
19
19
  let clientRpcCommunicator: RpcCommunicator
20
20
  let serverRpcCommunicator: RpcCommunicator
21
21
  const serviceId = 'test'
@@ -39,8 +39,8 @@ describe('RemoteDhtNode', () => {
39
39
  serverRpcCommunicator.on('outgoingMessage', (message: RpcMessage) => {
40
40
  clientRpcCommunicator.handleIncomingMessage(message)
41
41
  })
42
- const client = toProtoRpcClient(new DhtRpcServiceClient(clientRpcCommunicator.getRpcClientTransport()))
43
- remoteDhtNode = new RemoteDhtNode(clientPeerDescriptor, serverPeerDescriptor, client, serviceId)
42
+ const client = toProtoRpcClient(new DhtNodeRpcClient(clientRpcCommunicator.getRpcClientTransport()))
43
+ rpcRemote = new DhtNodeRpcRemote(clientPeerDescriptor, serverPeerDescriptor, client, serviceId)
44
44
  })
45
45
 
46
46
  afterEach(() => {
@@ -49,24 +49,24 @@ describe('RemoteDhtNode', () => {
49
49
  })
50
50
 
51
51
  it('Ping happy path', async () => {
52
- const active = await remoteDhtNode.ping()
52
+ const active = await rpcRemote.ping()
53
53
  expect(active).toEqual(true)
54
54
  })
55
55
 
56
56
  it('getClosestPeers happy path', async () => {
57
- const neighbors = await remoteDhtNode.getClosestPeers(clientPeerDescriptor.kademliaId)
57
+ const neighbors = await rpcRemote.getClosestPeers(clientPeerDescriptor.kademliaId)
58
58
  expect(neighbors.length).toEqual(getMockPeers().length)
59
59
  })
60
60
 
61
61
  it('ping error path', async () => {
62
62
  serverRpcCommunicator.registerRpcMethod(PingRequest, PingResponse, 'ping', MockDhtRpc.throwPingError)
63
- const active = await remoteDhtNode.ping()
63
+ const active = await rpcRemote.ping()
64
64
  expect(active).toEqual(false)
65
65
  })
66
66
 
67
67
  it('getClosestPeers error path', async () => {
68
68
  serverRpcCommunicator.registerRpcMethod(ClosestPeersRequest, ClosestPeersResponse, 'getClosestPeers', MockDhtRpc.throwGetClosestPeersError)
69
- await expect(remoteDhtNode.getClosestPeers(clientPeerDescriptor.kademliaId))
69
+ await expect(rpcRemote.getClosestPeers(clientPeerDescriptor.kademliaId))
70
70
  .rejects.toThrow('Closest peers error')
71
71
  })
72
72
 
@@ -1,6 +1,6 @@
1
1
  import { getMockPeers, MockDhtRpc } from '../utils/utils'
2
2
  import { ProtoRpcClient, RpcCommunicator, RpcError, toProtoRpcClient } from '@streamr/proto-rpc'
3
- import { DhtRpcServiceClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
3
+ import { DhtNodeRpcClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
4
4
  import { generateId } from '../utils/utils'
5
5
  import { ClosestPeersRequest, ClosestPeersResponse, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
6
6
  import { wait } from '@streamr/utils'
@@ -9,8 +9,8 @@ import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
9
9
  describe('DhtRpc', () => {
10
10
  let rpcCommunicator1: RpcCommunicator
11
11
  let rpcCommunicator2: RpcCommunicator
12
- let client1: ProtoRpcClient<DhtRpcServiceClient>
13
- let client2: ProtoRpcClient<DhtRpcServiceClient>
12
+ let client1: ProtoRpcClient<DhtNodeRpcClient>
13
+ let client2: ProtoRpcClient<DhtNodeRpcClient>
14
14
 
15
15
  const peerDescriptor1: PeerDescriptor = {
16
16
  kademliaId: generateId('peer1'),
@@ -39,8 +39,8 @@ describe('DhtRpc', () => {
39
39
 
40
40
  rpcCommunicator2.on('outgoingMessage', outgoingListener2)
41
41
 
42
- client1 = toProtoRpcClient(new DhtRpcServiceClient(rpcCommunicator1.getRpcClientTransport()))
43
- client2 = toProtoRpcClient(new DhtRpcServiceClient(rpcCommunicator1.getRpcClientTransport()))
42
+ client1 = toProtoRpcClient(new DhtNodeRpcClient(rpcCommunicator1.getRpcClientTransport()))
43
+ client2 = toProtoRpcClient(new DhtNodeRpcClient(rpcCommunicator1.getRpcClientTransport()))
44
44
  })
45
45
 
46
46
  afterEach(async () => {
@@ -1,11 +1,11 @@
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, waitConnectionManagersReadyForTesting } from '../utils/utils'
5
5
  import { PeerID } from '../../src/helpers/PeerID'
6
6
  import { peerIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
7
7
 
8
- describe('Recursive find correctness', () => {
8
+ describe('Find correctness', () => {
9
9
 
10
10
  let entryPoint: DhtNode
11
11
  let nodes: DhtNode[]
@@ -42,7 +42,7 @@ describe('Recursive find correctness', () => {
42
42
 
43
43
  it('Entrypoint can find a node from the network (exact match)', async () => {
44
44
  const kademliaIdToFind = nodes[45].getNodeId().value
45
- const results = await entryPoint.startRecursiveFind(kademliaIdToFind)
45
+ const results = await entryPoint.startFind(kademliaIdToFind)
46
46
  expect(results.closestNodes.length).toBeGreaterThanOrEqual(5)
47
47
  expect(PeerID.fromValue(kademliaIdToFind).equals(peerIdFromPeerDescriptor(results.closestNodes[0])))
48
48
  }, 30000)
@@ -1,4 +1,4 @@
1
- import { Simulator } from '../../src/connection/Simulator/Simulator'
1
+ import { Simulator } from '../../src/connection/simulator/Simulator'
2
2
  import { PeerID } from '../../src/helpers/PeerID'
3
3
  import { DhtNode } from '../../src/dht/DhtNode'
4
4
  import { createMockConnectionDhtNode, createMockConnectionLayer1Node } from '../utils/utils'
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-console */
2
- import { LatencyType, Simulator } from '../../src/connection/Simulator/Simulator'
2
+ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
3
3
  import { DhtNode } from '../../src/dht/DhtNode'
4
4
  import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
5
5
  import { createMockConnectionDhtNode, waitNodesReadyForTesting } from '../utils/utils'
@@ -83,7 +83,7 @@ describe('Migrating data from node to node in DHT', () => {
83
83
  const sortedList = new SortedContactList<Contact>(dataKey, 10000)
84
84
 
85
85
  nodes.forEach((node) => {
86
- sortedList.addContact(new Contact(node.getPeerDescriptor())
86
+ sortedList.addContact(new Contact(node.getLocalPeerDescriptor())
87
87
  )
88
88
  })
89
89
 
@@ -114,13 +114,14 @@ describe('Migrating data from node to node in DHT', () => {
114
114
  hasDataMarker = '<-'
115
115
  }
116
116
 
117
- logger.info(keyFromPeerDescriptor(contact.getPeerDescriptor()) + ' ' + keyFromPeerDescriptor(node.getPeerDescriptor()) + hasDataMarker)
117
+ // eslint-disable-next-line max-len
118
+ logger.info(keyFromPeerDescriptor(contact.getPeerDescriptor()) + ' ' + keyFromPeerDescriptor(node.getLocalPeerDescriptor()) + hasDataMarker)
118
119
  })
119
120
 
120
121
  logger.info(NUM_NODES + ' nodes joining layer0 DHT')
121
122
  await Promise.all(
122
123
  nodes.map((node) => {
123
- if (keyFromPeerDescriptor(node.getPeerDescriptor()) != '0') {
124
+ if (keyFromPeerDescriptor(node.getLocalPeerDescriptor()) != '0') {
124
125
  node.joinDht([entrypointDescriptor])
125
126
  }
126
127
  })
@@ -142,7 +143,7 @@ describe('Migrating data from node to node in DHT', () => {
142
143
  hasDataMarker = '<-'
143
144
  }
144
145
 
145
- logger.info(keyFromPeerDescriptor(node.getPeerDescriptor()) + hasDataMarker)
146
+ logger.info(keyFromPeerDescriptor(node.getLocalPeerDescriptor()) + hasDataMarker)
146
147
  })
147
148
 
148
149
  const closestNode = nodesById.get(PeerID.fromValue(closest[0].getPeerDescriptor().kademliaId).toKey())!
@@ -1,5 +1,5 @@
1
1
  import { Logger } from '@streamr/utils'
2
- import { Simulator } from '../../src/connection/Simulator/Simulator'
2
+ import { Simulator } from '../../src/connection/simulator/Simulator'
3
3
  import { DhtNode } from '../../src/dht/DhtNode'
4
4
  import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
5
5
  import { createMockConnectionDhtNode, createMockConnectionLayer1Node } from '../utils/utils'
@@ -1,4 +1,4 @@
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 { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
4
4
  import { createMockConnectionDhtNode } from '../utils/utils'
@@ -21,9 +21,9 @@ describe('multiple entry point joining', () => {
21
21
  node3 = await createMockConnectionDhtNode('node3', simulator)
22
22
 
23
23
  entryPoints = [
24
- node1.getPeerDescriptor(),
25
- node2.getPeerDescriptor(),
26
- node3.getPeerDescriptor()
24
+ node1.getLocalPeerDescriptor(),
25
+ node2.getLocalPeerDescriptor(),
26
+ node3.getLocalPeerDescriptor()
27
27
  ]
28
28
  })
29
29
 
@@ -76,8 +76,8 @@ describe('multiple entry point joining', () => {
76
76
  node2 = await createMockConnectionDhtNode('node2', simulator)
77
77
 
78
78
  entryPoints = [
79
- entryPoint1.getPeerDescriptor(),
80
- entryPoint2.getPeerDescriptor(),
79
+ entryPoint1.getLocalPeerDescriptor(),
80
+ entryPoint2.getLocalPeerDescriptor(),
81
81
  ]
82
82
 
83
83
  await entryPoint1.joinDht(entryPoints)
@@ -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,4 +1,4 @@
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'
@@ -49,12 +49,12 @@ 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()) + ', '
57
+ logger.error(keyFromPeerDescriptor(node.getLocalPeerDescriptor()) + ', '
58
58
  + keyFromPeerDescriptor(stoppingPeerDescriptor) + ' cleaning up failed')
59
59
  }
60
60
  return !areEqualPeerDescriptors(peer, stoppingPeerDescriptor)
@@ -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,4 +1,4 @@
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, waitConnectionManagersReadyForTesting } from '../utils/utils'
@@ -1,4 +1,4 @@
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, waitConnectionManagersReadyForTesting } from '../utils/utils'
@@ -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
  })