@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.
- package/dist/src/connection/ConnectionLockHandler.d.ts +7 -8
- package/dist/src/connection/ConnectionLockHandler.js +16 -14
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +20 -0
- package/dist/src/connection/ConnectionLockRpcLocal.js +47 -0
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -0
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +4 -3
- package/dist/src/connection/ConnectionLockRpcRemote.js +9 -9
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +9 -16
- package/dist/src/connection/ConnectionManager.js +101 -132
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.d.ts +7 -10
- package/dist/src/connection/ConnectivityChecker.js +30 -32
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +19 -13
- package/dist/src/connection/ConnectorFacade.js +74 -29
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +8 -8
- package/dist/src/connection/Handshaker.js +30 -33
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/IConnection.d.ts +5 -6
- package/dist/src/connection/IConnection.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +9 -13
- package/dist/src/connection/ManagedConnection.js +63 -99
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebrtcConnection.d.ts +7 -0
- package/dist/src/connection/ManagedWebrtcConnection.js +20 -0
- package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/Simulator.js +3 -3
- package/dist/src/connection/{Simulator → simulator}/Simulator.js.map +1 -1
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.d.ts +3 -4
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.js +25 -24
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.d.ts +3 -3
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js +17 -18
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.d.ts +1 -1
- package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.js +2 -2
- package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/pings.js.map +1 -1
- package/dist/src/connection/{WebRTC/IWebRtcConnection.d.ts → webrtc/IWebrtcConnection.d.ts} +2 -2
- package/dist/src/connection/{WebRTC/IWebRtcConnection.js → webrtc/IWebrtcConnection.js} +1 -1
- package/dist/src/connection/webrtc/IWebrtcConnection.js.map +1 -0
- package/dist/src/connection/{WebRTC/NodeWebRtcConnection.d.ts → webrtc/NodeWebrtcConnection.d.ts} +6 -7
- package/dist/src/connection/{WebRTC/NodeWebRtcConnection.js → webrtc/NodeWebrtcConnection.js} +41 -42
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -0
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +38 -0
- package/dist/src/connection/webrtc/WebrtcConnector.js +178 -0
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +26 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +99 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.d.ts → webrtc/WebrtcConnectorRpcRemote.d.ts} +4 -4
- package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.js → webrtc/WebrtcConnectorRpcRemote.js} +6 -8
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.d.ts +1 -1
- package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +26 -0
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +37 -0
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -0
- package/dist/src/connection/{WebSocket/ClientWebSocket.d.ts → websocket/ClientWebsocket.d.ts} +5 -4
- package/dist/src/connection/{WebSocket/ClientWebSocket.js → websocket/ClientWebsocket.js} +23 -16
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -0
- package/dist/src/connection/{WebSocket/ServerWebSocket.d.ts → websocket/ServerWebsocket.d.ts} +2 -2
- package/dist/src/connection/{WebSocket/ServerWebSocket.js → websocket/ServerWebsocket.js} +25 -27
- package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +53 -0
- package/dist/src/connection/websocket/WebsocketConnector.js +242 -0
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +17 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +26 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.d.ts → websocket/WebsocketConnectorRpcRemote.d.ts} +3 -3
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js → websocket/WebsocketConnectorRpcRemote.js} +6 -11
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/{WebSocket/WebSocketServer.d.ts → websocket/WebsocketServer.d.ts} +6 -3
- package/dist/src/connection/{WebSocket/WebSocketServer.js → websocket/WebsocketServer.js} +39 -19
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +11 -19
- package/dist/src/dht/DhtNode.js +135 -163
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +22 -0
- package/dist/src/dht/DhtNodeRpcLocal.js +42 -0
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -0
- package/dist/src/dht/{RemoteDhtNode.d.ts → DhtNodeRpcRemote.d.ts} +5 -3
- package/dist/src/dht/{RemoteDhtNode.js → DhtNodeRpcRemote.js} +20 -24
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -0
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +16 -0
- package/dist/src/dht/ExternalApiRpcLocal.js +30 -0
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -0
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/contact/Remote.d.ts +4 -1
- package/dist/src/dht/contact/Remote.js +28 -2
- package/dist/src/dht/contact/Remote.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +2 -2
- package/dist/src/dht/contact/SortedContactList.js +3 -3
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +9 -7
- package/dist/src/dht/discovery/DiscoverySession.js +9 -9
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +7 -10
- package/dist/src/dht/discovery/PeerDiscovery.js +6 -6
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/find/FindRpcLocal.d.ts +14 -0
- package/dist/src/dht/find/FindRpcLocal.js +25 -0
- package/dist/src/dht/find/FindRpcLocal.js.map +1 -0
- package/dist/src/dht/find/{RecursiveFindSession.d.ts → FindSession.d.ts} +12 -13
- package/dist/src/dht/find/{RecursiveFindSession.js → FindSession.js} +17 -15
- package/dist/src/dht/find/FindSession.js.map +1 -0
- package/dist/src/dht/find/FindSessionRpcLocal.d.ts +12 -0
- package/dist/src/dht/find/FindSessionRpcLocal.js +17 -0
- package/dist/src/dht/find/FindSessionRpcLocal.js.map +1 -0
- package/dist/src/dht/find/{RemoteRecursiveFindSession.d.ts → FindSessionRpcRemote.d.ts} +2 -2
- package/dist/src/dht/find/{RemoteRecursiveFindSession.js → FindSessionRpcRemote.js} +5 -5
- package/dist/src/dht/find/FindSessionRpcRemote.js.map +1 -0
- package/dist/src/dht/find/{RecursiveFinder.d.ts → Finder.d.ts} +16 -19
- package/dist/src/dht/find/{RecursiveFinder.js → Finder.js} +50 -46
- package/dist/src/dht/find/Finder.js.map +1 -0
- package/dist/src/dht/routing/FindRpcRemote.d.ts +6 -0
- package/dist/src/dht/routing/FindRpcRemote.js +41 -0
- package/dist/src/dht/routing/FindRpcRemote.js.map +1 -0
- package/dist/src/dht/routing/Router.d.ts +10 -17
- package/dist/src/dht/routing/Router.js +50 -93
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +22 -0
- package/dist/src/dht/routing/RouterRpcLocal.js +66 -0
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -0
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +0 -1
- package/dist/src/dht/routing/RouterRpcRemote.js +17 -45
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +17 -8
- package/dist/src/dht/routing/RoutingSession.js +124 -131
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/getPreviousPeer.d.ts +2 -0
- package/dist/src/dht/routing/getPreviousPeer.js +9 -0
- package/dist/src/dht/routing/getPreviousPeer.js.map +1 -0
- package/dist/src/dht/store/StoreRpcLocal.d.ts +11 -8
- package/dist/src/dht/store/StoreRpcLocal.js +26 -25
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.js +6 -10
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +11 -5
- package/dist/src/exports.js +17 -4
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/Connectivity.d.ts +4 -0
- package/dist/src/helpers/Connectivity.js +24 -0
- package/dist/src/helpers/Connectivity.js.map +1 -0
- package/dist/src/helpers/errors.d.ts +3 -3
- package/dist/src/helpers/errors.js +7 -7
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +7 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +3 -3
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +56 -39
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +49 -36
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +85 -96
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +82 -71
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +26 -21
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +0 -1
- package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
- package/dist/src/transport/ITransport.d.ts +5 -6
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/RoutingRpcCommunicator.js +0 -1
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/dist/src/types/ServiceID.d.ts +1 -0
- package/dist/src/types/ServiceID.js +3 -0
- package/dist/src/types/ServiceID.js.map +1 -0
- package/karma.config.js +4 -4
- package/package.json +10 -8
- package/protos/DhtRpc.proto +41 -40
- package/src/connection/ConnectionLockHandler.ts +19 -17
- package/src/connection/ConnectionLockRpcLocal.ts +74 -0
- package/src/connection/ConnectionLockRpcRemote.ts +11 -11
- package/src/connection/ConnectionManager.ts +88 -130
- package/src/connection/ConnectivityChecker.ts +36 -34
- package/src/connection/ConnectorFacade.ts +91 -40
- package/src/connection/Handshaker.ts +20 -23
- package/src/connection/IConnection.ts +5 -6
- package/src/connection/ManagedConnection.ts +76 -101
- package/src/connection/{ManagedWebRtcConnection.ts → ManagedWebrtcConnection.ts} +12 -10
- package/src/connection/{Simulator → simulator}/Simulator.ts +4 -4
- package/src/connection/{Simulator → simulator}/SimulatorConnection.ts +27 -27
- package/src/connection/{Simulator → simulator}/SimulatorConnector.ts +22 -23
- package/src/connection/{Simulator → simulator}/SimulatorTransport.ts +2 -2
- package/src/connection/{WebRTC/BrowserWebRtcConnection.ts → webrtc/BrowserWebrtcConnection.ts} +13 -14
- package/src/connection/{WebRTC/IWebRtcConnection.ts → webrtc/IWebrtcConnection.ts} +2 -2
- package/src/connection/{WebRTC/NodeWebRtcConnection.ts → webrtc/NodeWebrtcConnection.ts} +38 -40
- package/src/connection/webrtc/WebrtcConnector.ts +226 -0
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +132 -0
- package/src/connection/{WebRTC/WebRtcConnectorRpcRemote.ts → webrtc/WebrtcConnectorRpcRemote.ts} +6 -7
- package/src/connection/{WebRTC → webrtc}/iceServerAsString.ts +1 -1
- package/src/connection/websocket/AutoCertifierClientFacade.ts +91 -0
- package/src/connection/{WebSocket/ClientWebSocket.ts → websocket/ClientWebsocket.ts} +22 -17
- package/src/connection/{WebSocket/ServerWebSocket.ts → websocket/ServerWebsocket.ts} +23 -27
- package/src/connection/websocket/WebsocketConnector.ts +328 -0
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +41 -0
- package/src/connection/{WebSocket/WebSocketConnectorRpcRemote.ts → websocket/WebsocketConnectorRpcRemote.ts} +8 -14
- package/src/connection/{WebSocket/WebSocketServer.ts → websocket/WebsocketServer.ts} +40 -22
- package/src/dht/DhtNode.ts +166 -193
- package/src/dht/DhtNodeRpcLocal.ts +68 -0
- package/src/dht/{RemoteDhtNode.ts → DhtNodeRpcRemote.ts} +17 -18
- package/src/dht/ExternalApiRpcLocal.ts +46 -0
- package/src/dht/ExternalApiRpcRemote.ts +4 -4
- package/src/dht/contact/Remote.ts +32 -4
- package/src/dht/contact/SortedContactList.ts +4 -4
- package/src/dht/discovery/DiscoverySession.ts +25 -22
- package/src/dht/discovery/PeerDiscovery.ts +16 -19
- package/src/dht/find/FindRpcLocal.ts +35 -0
- package/src/dht/find/{RecursiveFindSession.ts → FindSession.ts} +25 -25
- package/src/dht/find/FindSessionRpcLocal.ts +25 -0
- package/src/dht/find/{RemoteRecursiveFindSession.ts → FindSessionRpcRemote.ts} +9 -5
- package/src/dht/find/{RecursiveFinder.ts → Finder.ts} +77 -71
- package/src/dht/routing/FindRpcRemote.ts +40 -0
- package/src/dht/routing/Router.ts +78 -109
- package/src/dht/routing/RouterRpcLocal.ts +81 -0
- package/src/dht/routing/RouterRpcRemote.ts +18 -49
- package/src/dht/routing/RoutingSession.ts +58 -63
- package/src/dht/routing/getPreviousPeer.ts +6 -0
- package/src/dht/store/StoreRpcLocal.ts +46 -39
- package/src/dht/store/StoreRpcRemote.ts +8 -12
- package/src/exports.ts +11 -5
- package/src/helpers/Connectivity.ts +19 -0
- package/src/helpers/errors.ts +3 -3
- package/src/helpers/peerIdFromPeerDescriptor.ts +6 -0
- package/src/helpers/protoClasses.ts +6 -6
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +75 -59
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +26 -21
- package/src/proto/packages/dht/protos/DhtRpc.ts +112 -131
- package/src/rpc-protocol/DhtCallContext.ts +0 -1
- package/src/transport/ITransport.ts +5 -8
- package/src/transport/ListeningRpcCommunicator.ts +2 -1
- package/src/transport/RoutingRpcCommunicator.ts +3 -4
- package/src/types/ServiceID.ts +1 -0
- package/test/benchmark/{RecursiveFind.test.ts → Find.test.ts} +7 -7
- package/test/benchmark/KademliaCorrectness.test.ts +3 -3
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +3 -3
- package/test/end-to-end/Layer0-Layer1.test.ts +13 -5
- package/test/end-to-end/Layer0.test.ts +35 -17
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +28 -9
- package/test/end-to-end/{Layer0WebRTC-Layer1.test.ts → Layer0Webrtc-Layer1.test.ts} +1 -1
- package/test/end-to-end/{Layer0WebRTC.test.ts → Layer0Webrtc.test.ts} +14 -10
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +8 -4
- package/test/end-to-end/{Layer1-Scale-WebRTC.test.ts → Layer1-Scale-Webrtc.test.ts} +2 -2
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +52 -0
- package/test/end-to-end/{WebSocketConnectionRequest.test.ts → WebsocketConnectionRequest.test.ts} +16 -8
- package/test/end-to-end/memory-leak.test.ts +85 -0
- package/test/integration/ConnectionLocking.test.ts +10 -7
- package/test/integration/ConnectionManager.test.ts +107 -30
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNodeExternalAPI.test.ts +10 -10
- package/test/integration/{RemoteDhtNode.test.ts → DhtNodeRpcRemote.test.ts} +10 -10
- package/test/integration/DhtRpc.test.ts +5 -5
- package/test/integration/{RecursiveFind.test.ts → Find.test.ts} +6 -9
- package/test/integration/Layer1-scale.test.ts +1 -1
- package/test/integration/MigrateData.test.ts +8 -7
- package/test/integration/Mock-Layer1-Layer0.test.ts +1 -1
- package/test/integration/MultipleEntryPointJoining.test.ts +8 -8
- package/test/integration/RouteMessage.test.ts +26 -26
- package/test/integration/RpcErrors.test.ts +10 -10
- package/test/integration/ScaleDownDht.test.ts +6 -6
- package/test/integration/SimultaneousConnections.test.ts +10 -7
- package/test/integration/Store.test.ts +4 -7
- package/test/integration/StoreAndDelete.test.ts +4 -7
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +12 -12
- package/test/integration/{WebRtcConnectionManagement.test.ts → WebrtcConnectionManagement.test.ts} +5 -5
- package/test/integration/{WebRtcConnectorRpc.test.ts → WebrtcConnectorRpc.test.ts} +7 -8
- package/test/integration/{WebSocket.test.ts → Websocket.test.ts} +14 -13
- package/test/integration/{WebSocketConnectionManagement.test.ts → WebsocketConnectionManagement.test.ts} +4 -4
- package/test/integration/{WebSocketConnectorRpc.test.ts → WebsocketConnectorRpc.test.ts} +15 -15
- package/test/unit/AutoCertifierClientFacade.test.ts +58 -0
- package/test/unit/ConnectivityHelpers.test.ts +69 -0
- package/test/unit/{RecursiveFinder.test.ts → Finder.test.ts} +19 -17
- package/test/unit/Router.test.ts +26 -26
- package/test/unit/UUID.test.ts +1 -1
- package/test/unit/{WebSocketConnectorRpcLocal.test.ts → WebsocketConnector.test.ts} +8 -8
- package/test/unit/{WebSocketServer.test.ts → WebsocketServer.test.ts} +20 -14
- package/test/unit/webrtcReplaceInternalIpWithExternalIp.test.ts +1 -1
- package/test/utils/FakeRpcCommunicator.ts +23 -0
- package/test/utils/mock/Transport.ts +1 -1
- package/test/utils/utils.ts +22 -26
- package/tsconfig.browser.json +1 -1
- package/tsconfig.jest.json +3 -2
- package/tsconfig.node.json +3 -2
- package/dist/src/connection/ManagedWebRtcConnection.d.ts +0 -7
- package/dist/src/connection/ManagedWebRtcConnection.js +0 -20
- package/dist/src/connection/ManagedWebRtcConnection.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorConnection.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorConnector.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js.map +0 -1
- package/dist/src/connection/WebRTC/IWebRtcConnection.js.map +0 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.d.ts +0 -51
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js +0 -249
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js.map +0 -1
- package/dist/src/connection/WebSocket/ClientWebSocket.js.map +0 -1
- package/dist/src/connection/WebSocket/ServerWebSocket.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.d.ts +0 -45
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js +0 -234
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcRemote.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketServer.js.map +0 -1
- package/dist/src/dht/RemoteDhtNode.js.map +0 -1
- package/dist/src/dht/find/RecursiveFindSession.js.map +0 -1
- package/dist/src/dht/find/RecursiveFinder.js.map +0 -1
- package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +0 -1
- package/dist/src/dht/registerExternalApiRpcMethods.d.ts +0 -2
- package/dist/src/dht/registerExternalApiRpcMethods.js +0 -32
- package/dist/src/dht/registerExternalApiRpcMethods.js.map +0 -1
- package/src/connection/WebRTC/WebRtcConnectorRpcLocal.ts +0 -335
- package/src/connection/WebSocket/WebSocketConnectorRpcLocal.ts +0 -295
- package/src/dht/registerExternalApiRpcMethods.ts +0 -44
- package/test/utils/mock/RecursiveFinder.ts +0 -19
- /package/dist/src/connection/{Simulator → simulator}/Simulator.d.ts +0 -0
- /package/dist/src/connection/{Simulator → simulator}/pings.d.ts +0 -0
- /package/dist/src/connection/{Simulator → simulator}/pings.js +0 -0
- /package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js +0 -0
- /package/src/connection/{Simulator → simulator}/pings.ts +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
2
2
|
import { ConnectivityResponse, Message, MessageType, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
3
3
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
4
|
-
import { Simulator } from '../../src/connection/
|
|
4
|
+
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
5
5
|
import { createPeerDescriptor } from '../../src/dht/DhtNode'
|
|
6
6
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
7
|
-
import { Logger, MetricsContext } from '@streamr/utils'
|
|
7
|
+
import { Logger, MetricsContext, waitForEvent3 } from '@streamr/utils'
|
|
8
8
|
import { SimulatorTransport } from '../../src/exports'
|
|
9
9
|
import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../../src/connection/ConnectorFacade'
|
|
10
|
+
import { MarkOptional } from 'ts-essentials'
|
|
11
|
+
import { createRandomKademliaId } from '../../src/helpers/kademliaId'
|
|
12
|
+
import { TransportEvents } from '../../src/transport/ITransport'
|
|
10
13
|
|
|
11
14
|
const logger = new Logger(module)
|
|
12
15
|
|
|
@@ -37,12 +40,13 @@ describe('ConnectionManager', () => {
|
|
|
37
40
|
const mockConnectorTransport1 = new SimulatorTransport(mockPeerDescriptor1, simulator)
|
|
38
41
|
const mockConnectorTransport2 = new SimulatorTransport(mockPeerDescriptor2, simulator)
|
|
39
42
|
|
|
40
|
-
let
|
|
43
|
+
let createLocalPeerDescriptor: jest.Mock<PeerDescriptor, [ConnectivityResponse]>
|
|
41
44
|
|
|
42
|
-
const createConnectionManager = (opts:
|
|
45
|
+
const createConnectionManager = (opts: MarkOptional<DefaultConnectorFacadeConfig, 'createLocalPeerDescriptor'>) => {
|
|
43
46
|
return new ConnectionManager({
|
|
44
47
|
createConnectorFacade: () => new DefaultConnectorFacade({
|
|
45
|
-
|
|
48
|
+
createLocalPeerDescriptor,
|
|
49
|
+
websocketServerEnableTls: false,
|
|
46
50
|
...opts
|
|
47
51
|
}),
|
|
48
52
|
metricsContext: new MetricsContext()
|
|
@@ -50,7 +54,7 @@ describe('ConnectionManager', () => {
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
beforeEach(() => {
|
|
53
|
-
|
|
57
|
+
createLocalPeerDescriptor = jest.fn().mockImplementation((response) => createPeerDescriptor(response))
|
|
54
58
|
})
|
|
55
59
|
|
|
56
60
|
beforeAll(async () => {
|
|
@@ -59,7 +63,7 @@ describe('ConnectionManager', () => {
|
|
|
59
63
|
await mockConnectorTransport2.start()
|
|
60
64
|
})
|
|
61
65
|
|
|
62
|
-
afterAll(async ()=> {
|
|
66
|
+
afterAll(async () => {
|
|
63
67
|
await mockTransport.stop()
|
|
64
68
|
await mockConnectorTransport1.stop()
|
|
65
69
|
await mockConnectorTransport2.stop()
|
|
@@ -70,12 +74,11 @@ describe('ConnectionManager', () => {
|
|
|
70
74
|
const connectionManager = createConnectionManager({
|
|
71
75
|
transport: mockTransport,
|
|
72
76
|
websocketHost: '127.0.0.1',
|
|
73
|
-
websocketPortRange: { min: 9991, max: 9991 }
|
|
77
|
+
websocketPortRange: { min: 9991, max: 9991 }
|
|
74
78
|
})
|
|
75
79
|
|
|
76
80
|
await connectionManager.start()
|
|
77
|
-
expect(
|
|
78
|
-
expect(createOwnPeerDescriptor.mock.calls[0][0].openInternet).toEqual(true)
|
|
81
|
+
expect(createLocalPeerDescriptor.mock.calls[0][0].host).toEqual('127.0.0.1')
|
|
79
82
|
|
|
80
83
|
await connectionManager.stop()
|
|
81
84
|
})
|
|
@@ -103,8 +106,7 @@ describe('ConnectionManager', () => {
|
|
|
103
106
|
})
|
|
104
107
|
|
|
105
108
|
await connectionManager1.start()
|
|
106
|
-
expect(
|
|
107
|
-
expect(createOwnPeerDescriptor.mock.calls[0][0].openInternet).toEqual(true)
|
|
109
|
+
expect(createLocalPeerDescriptor.mock.calls[0][0].host).toEqual('127.0.0.1')
|
|
108
110
|
|
|
109
111
|
const connectionManager2 = createConnectionManager({
|
|
110
112
|
transport: mockConnectorTransport2,
|
|
@@ -115,8 +117,7 @@ describe('ConnectionManager', () => {
|
|
|
115
117
|
})
|
|
116
118
|
|
|
117
119
|
await connectionManager2.start()
|
|
118
|
-
expect(
|
|
119
|
-
expect(createOwnPeerDescriptor.mock.calls[1][0].openInternet).toEqual(true)
|
|
120
|
+
expect(createLocalPeerDescriptor.mock.calls[1][0].host).toEqual('127.0.0.1')
|
|
120
121
|
|
|
121
122
|
await connectionManager1.stop()
|
|
122
123
|
await connectionManager2.stop()
|
|
@@ -130,20 +131,18 @@ describe('ConnectionManager', () => {
|
|
|
130
131
|
})
|
|
131
132
|
|
|
132
133
|
await connectionManager1.start()
|
|
133
|
-
expect(
|
|
134
|
-
expect(createOwnPeerDescriptor.mock.calls[0][0].openInternet).toEqual(true)
|
|
134
|
+
expect(createLocalPeerDescriptor.mock.calls[0][0].host).toEqual('127.0.0.1')
|
|
135
135
|
|
|
136
136
|
const connectionManager2 = createConnectionManager({
|
|
137
137
|
transport: mockConnectorTransport2,
|
|
138
138
|
websocketPortRange: { min: 9996, max: 9996 },
|
|
139
139
|
entryPoints: [
|
|
140
|
-
connectionManager1.
|
|
140
|
+
connectionManager1.getLocalPeerDescriptor()
|
|
141
141
|
]
|
|
142
142
|
})
|
|
143
143
|
|
|
144
144
|
await connectionManager2.start()
|
|
145
|
-
expect(
|
|
146
|
-
expect(createOwnPeerDescriptor.mock.calls[1][0].openInternet).toEqual(true)
|
|
145
|
+
expect(createLocalPeerDescriptor.mock.calls[1][0].host).toEqual('127.0.0.1')
|
|
147
146
|
|
|
148
147
|
const msg: Message = {
|
|
149
148
|
serviceId,
|
|
@@ -174,7 +173,7 @@ describe('ConnectionManager', () => {
|
|
|
174
173
|
})
|
|
175
174
|
})
|
|
176
175
|
|
|
177
|
-
msg.targetDescriptor = connectionManager2.
|
|
176
|
+
msg.targetDescriptor = connectionManager2.getLocalPeerDescriptor()
|
|
178
177
|
connectionManager1.send(msg)
|
|
179
178
|
|
|
180
179
|
await Promise.all([promise, connectedPromise1, connectedPromise2])
|
|
@@ -187,18 +186,18 @@ describe('ConnectionManager', () => {
|
|
|
187
186
|
const connectionManager1 = createConnectionManager({
|
|
188
187
|
transport: mockConnectorTransport1,
|
|
189
188
|
websocketHost: '127.0.0.1',
|
|
190
|
-
websocketPortRange: { min: 9997, max: 9997 }
|
|
189
|
+
websocketPortRange: { min: 9997, max: 9997 },
|
|
191
190
|
})
|
|
192
191
|
|
|
193
192
|
await connectionManager1.start()
|
|
194
|
-
expect(
|
|
195
|
-
expect(createOwnPeerDescriptor.mock.calls[0][0].openInternet).toEqual(true)
|
|
193
|
+
expect(createLocalPeerDescriptor.mock.calls[0][0].host).toEqual('127.0.0.1')
|
|
196
194
|
|
|
197
195
|
const connectionManager2 = createConnectionManager({
|
|
198
196
|
transport: mockConnectorTransport2,
|
|
199
197
|
websocketPortRange: { min: 9999, max: 9999 },
|
|
198
|
+
websocketServerEnableTls: false,
|
|
200
199
|
entryPoints: [
|
|
201
|
-
connectionManager1.
|
|
200
|
+
connectionManager1.getLocalPeerDescriptor()
|
|
202
201
|
]
|
|
203
202
|
})
|
|
204
203
|
|
|
@@ -234,13 +233,13 @@ describe('ConnectionManager', () => {
|
|
|
234
233
|
resolve()
|
|
235
234
|
})
|
|
236
235
|
})
|
|
237
|
-
msg.targetDescriptor = connectionManager2.
|
|
236
|
+
msg.targetDescriptor = connectionManager2.getLocalPeerDescriptor()
|
|
238
237
|
connectionManager1.send(msg)
|
|
239
238
|
|
|
240
239
|
await promise
|
|
241
240
|
|
|
242
241
|
// @ts-expect-error private field
|
|
243
|
-
connectionManager1.closeConnection(connectionManager2.
|
|
242
|
+
connectionManager1.closeConnection(connectionManager2.getLocalPeerDescriptor())
|
|
244
243
|
|
|
245
244
|
await Promise.all([disconnectedPromise1, disconnectedPromise2])
|
|
246
245
|
|
|
@@ -307,7 +306,7 @@ describe('ConnectionManager', () => {
|
|
|
307
306
|
await connectionManager4.stop()
|
|
308
307
|
})
|
|
309
308
|
|
|
310
|
-
it('Cannot send to own
|
|
309
|
+
it('Cannot send to own WebsocketServer if kademliaIds do not match', async () => {
|
|
311
310
|
const connectionManager1 = createConnectionManager({
|
|
312
311
|
transport: mockTransport,
|
|
313
312
|
websocketHost: '127.0.0.1',
|
|
@@ -315,10 +314,9 @@ describe('ConnectionManager', () => {
|
|
|
315
314
|
})
|
|
316
315
|
|
|
317
316
|
await connectionManager1.start()
|
|
318
|
-
expect(
|
|
319
|
-
expect(createOwnPeerDescriptor.mock.calls[0][0].openInternet).toEqual(true)
|
|
317
|
+
expect(createLocalPeerDescriptor.mock.calls[0][0].host).toEqual('127.0.0.1')
|
|
320
318
|
|
|
321
|
-
const peerDescriptor = connectionManager1.
|
|
319
|
+
const peerDescriptor = connectionManager1.getLocalPeerDescriptor()
|
|
322
320
|
peerDescriptor.kademliaId = new Uint8Array([12, 12, 12, 12])
|
|
323
321
|
const msg: Message = {
|
|
324
322
|
serviceId,
|
|
@@ -336,4 +334,83 @@ describe('ConnectionManager', () => {
|
|
|
336
334
|
|
|
337
335
|
await connectionManager1.stop()
|
|
338
336
|
})
|
|
337
|
+
|
|
338
|
+
it('Cannot send to a WebSocketServer if kademliaIds do not match', async () => {
|
|
339
|
+
|
|
340
|
+
const peerDescriptor1 = {
|
|
341
|
+
kademliaId: createRandomKademliaId(),
|
|
342
|
+
type: NodeType.NODEJS,
|
|
343
|
+
websocket: {
|
|
344
|
+
host: '127.0.0.1',
|
|
345
|
+
port: 10002,
|
|
346
|
+
tls: false
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const peerDescriptor2 = {
|
|
351
|
+
kademliaId: createRandomKademliaId(),
|
|
352
|
+
type: NodeType.NODEJS,
|
|
353
|
+
websocket: {
|
|
354
|
+
host: '127.0.0.1',
|
|
355
|
+
port: 10003,
|
|
356
|
+
tls: false
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const connectionManager1 = createConnectionManager({
|
|
360
|
+
transport: mockTransport,
|
|
361
|
+
websocketHost: '127.0.0.1',
|
|
362
|
+
websocketPortRange: { min: 10002, max: 10002 },
|
|
363
|
+
createLocalPeerDescriptor: () => peerDescriptor1
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
await connectionManager1.start()
|
|
367
|
+
|
|
368
|
+
const connectionManager2 = createConnectionManager({
|
|
369
|
+
transport: mockTransport,
|
|
370
|
+
websocketHost: '127.0.0.1',
|
|
371
|
+
websocketPortRange: { min: 10003, max: 10003 },
|
|
372
|
+
createLocalPeerDescriptor: () => peerDescriptor2
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
await connectionManager2.start()
|
|
376
|
+
|
|
377
|
+
const msg: Message = {
|
|
378
|
+
serviceId,
|
|
379
|
+
messageType: MessageType.RPC,
|
|
380
|
+
messageId: '1',
|
|
381
|
+
targetDescriptor: {
|
|
382
|
+
// This is not the correct kademliaId of peerDescriptor2
|
|
383
|
+
kademliaId: new Uint8Array([1, 2, 3, 4]),
|
|
384
|
+
type: NodeType.NODEJS,
|
|
385
|
+
websocket: peerDescriptor2.websocket
|
|
386
|
+
},
|
|
387
|
+
body: {
|
|
388
|
+
oneofKind: 'rpcMessage',
|
|
389
|
+
rpcMessage: RpcMessage.create()
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
await Promise.all([
|
|
393
|
+
waitForEvent3<TransportEvents>(connectionManager1, 'disconnected'),
|
|
394
|
+
expect(connectionManager1.send(msg))
|
|
395
|
+
.rejects
|
|
396
|
+
.toThrow()
|
|
397
|
+
])
|
|
398
|
+
|
|
399
|
+
await connectionManager1.stop()
|
|
400
|
+
await connectionManager2.stop()
|
|
401
|
+
}, 10000)
|
|
402
|
+
|
|
403
|
+
it('Failed autocertification', async () => {
|
|
404
|
+
const connectionManager1 = createConnectionManager({
|
|
405
|
+
transport: mockTransport,
|
|
406
|
+
websocketHost: '127.0.0.1',
|
|
407
|
+
autoCertifierUrl: 'https://localhost:12333',
|
|
408
|
+
websocketServerEnableTls: true,
|
|
409
|
+
websocketPortRange: { min: 10004, max: 10004 }
|
|
410
|
+
})
|
|
411
|
+
|
|
412
|
+
await connectionManager1.start()
|
|
413
|
+
expect(connectionManager1.getLocalPeerDescriptor().websocket!.tls).toEqual(false)
|
|
414
|
+
await connectionManager1.stop()
|
|
415
|
+
})
|
|
339
416
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LatencyType, Simulator } from '../../src/connection/
|
|
2
|
-
import { getRandomRegion } from '../../src/connection/
|
|
1
|
+
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
|
+
import { getRandomRegion } from '../../src/connection/simulator/pings'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
4
|
import { NodeType } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
2
|
-
import { LatencyType, Simulator } from '../../src/connection/
|
|
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.
|
|
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.
|
|
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.
|
|
35
|
-
expect(Any.unpack(foundData[0].data!, PeerDescriptor)).toEqual(dhtNode1.
|
|
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.
|
|
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.
|
|
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.
|
|
48
|
-
const foundData = await remote.findDataViaPeer(key, dhtNode1.
|
|
49
|
-
expect(Any.unpack(foundData[0].data!, PeerDescriptor)).toEqual(dhtNode1.
|
|
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 {
|
|
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 {
|
|
13
|
+
import { DhtNodeRpcClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
|
|
14
14
|
import { generateId } from '../utils/utils'
|
|
15
15
|
|
|
16
|
-
describe('
|
|
16
|
+
describe('DhtNodeRpcRemote', () => {
|
|
17
17
|
|
|
18
|
-
let
|
|
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
|
|
43
|
-
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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 {
|
|
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<
|
|
13
|
-
let client2: ProtoRpcClient<
|
|
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
|
|
43
|
-
client2 = toProtoRpcClient(new
|
|
42
|
+
client1 = toProtoRpcClient(new DhtNodeRpcClient(rpcCommunicator1.getRpcClientTransport()))
|
|
43
|
+
client2 = toProtoRpcClient(new DhtNodeRpcClient(rpcCommunicator1.getRpcClientTransport()))
|
|
44
44
|
})
|
|
45
45
|
|
|
46
46
|
afterEach(async () => {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { LatencyType, Simulator } from '../../src/connection/
|
|
1
|
+
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import {
|
|
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 { peerIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
7
7
|
|
|
8
|
-
describe('
|
|
8
|
+
describe('Find correctness', () => {
|
|
9
9
|
|
|
10
10
|
let entryPoint: DhtNode
|
|
11
11
|
let nodes: DhtNode[]
|
|
12
12
|
let entrypointDescriptor: PeerDescriptor
|
|
13
|
-
const simulator = new Simulator(LatencyType.
|
|
13
|
+
const simulator = new Simulator(LatencyType.REAL)
|
|
14
14
|
const NUM_NODES = 100
|
|
15
15
|
const K = 2
|
|
16
16
|
|
|
@@ -19,10 +19,7 @@ describe('Recursive find correctness', () => {
|
|
|
19
19
|
const entryPointId = '0'
|
|
20
20
|
entryPoint = await createMockConnectionDhtNode(entryPointId, simulator, undefined, K)
|
|
21
21
|
nodes.push(entryPoint)
|
|
22
|
-
entrypointDescriptor =
|
|
23
|
-
kademliaId: entryPoint.getNodeId().value,
|
|
24
|
-
type: NodeType.NODEJS
|
|
25
|
-
}
|
|
22
|
+
entrypointDescriptor = entryPoint.getLocalPeerDescriptor()
|
|
26
23
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
27
24
|
const nodeId = `${i}`
|
|
28
25
|
const node = await createMockConnectionDhtNode(nodeId, simulator, undefined, K, 20, 60000)
|
|
@@ -42,7 +39,7 @@ describe('Recursive find correctness', () => {
|
|
|
42
39
|
|
|
43
40
|
it('Entrypoint can find a node from the network (exact match)', async () => {
|
|
44
41
|
const kademliaIdToFind = nodes[45].getNodeId().value
|
|
45
|
-
const results = await entryPoint.
|
|
42
|
+
const results = await entryPoint.startFind(kademliaIdToFind)
|
|
46
43
|
expect(results.closestNodes.length).toBeGreaterThanOrEqual(5)
|
|
47
44
|
expect(PeerID.fromValue(kademliaIdToFind).equals(peerIdFromPeerDescriptor(results.closestNodes[0])))
|
|
48
45
|
}, 30000)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Simulator } from '../../src/connection/
|
|
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/
|
|
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'
|
|
@@ -7,7 +7,7 @@ import { execSync } from 'child_process'
|
|
|
7
7
|
import fs from 'fs'
|
|
8
8
|
import { Logger } from '@streamr/utils'
|
|
9
9
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
10
|
-
import { keyFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
10
|
+
import { getNodeIdFromPeerDescriptor, keyFromPeerDescriptor, peerIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
11
11
|
import { Any } from '../../src/proto/google/protobuf/any'
|
|
12
12
|
import { SortedContactList } from '../../src/dht/contact/SortedContactList'
|
|
13
13
|
import { Contact } from '../../src/dht/contact/Contact'
|
|
@@ -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.
|
|
86
|
+
sortedList.addContact(new Contact(node.getLocalPeerDescriptor())
|
|
87
87
|
)
|
|
88
88
|
})
|
|
89
89
|
|
|
@@ -91,7 +91,7 @@ describe('Migrating data from node to node in DHT', () => {
|
|
|
91
91
|
|
|
92
92
|
logger.info('Nodes sorted according to distance to data are: ')
|
|
93
93
|
closest.forEach((contact) => {
|
|
94
|
-
logger.info(
|
|
94
|
+
logger.info(getNodeIdFromPeerDescriptor(contact.getPeerDescriptor()))
|
|
95
95
|
})
|
|
96
96
|
|
|
97
97
|
logger.info('node 0 joining to the DHT')
|
|
@@ -114,13 +114,14 @@ describe('Migrating data from node to node in DHT', () => {
|
|
|
114
114
|
hasDataMarker = '<-'
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
// eslint-disable-next-line max-len
|
|
118
|
+
logger.info(peerIdFromPeerDescriptor(contact.getPeerDescriptor()) + ' ' + getNodeIdFromPeerDescriptor(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.
|
|
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(
|
|
146
|
+
logger.info(getNodeIdFromPeerDescriptor(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/
|
|
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/
|
|
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'
|
|
@@ -14,16 +14,16 @@ describe('multiple entry point joining', () => {
|
|
|
14
14
|
let entryPoints: PeerDescriptor[]
|
|
15
15
|
|
|
16
16
|
beforeEach(async () => {
|
|
17
|
-
simulator = new Simulator(LatencyType.
|
|
17
|
+
simulator = new Simulator(LatencyType.REAL)
|
|
18
18
|
|
|
19
19
|
node1 = await createMockConnectionDhtNode('node1', simulator)
|
|
20
20
|
node2 = await createMockConnectionDhtNode('node2', simulator)
|
|
21
21
|
node3 = await createMockConnectionDhtNode('node3', simulator)
|
|
22
22
|
|
|
23
23
|
entryPoints = [
|
|
24
|
-
node1.
|
|
25
|
-
node2.
|
|
26
|
-
node3.
|
|
24
|
+
node1.getLocalPeerDescriptor(),
|
|
25
|
+
node2.getLocalPeerDescriptor(),
|
|
26
|
+
node3.getLocalPeerDescriptor()
|
|
27
27
|
]
|
|
28
28
|
})
|
|
29
29
|
|
|
@@ -67,7 +67,7 @@ describe('multiple entry point joining', () => {
|
|
|
67
67
|
let entryPoints: PeerDescriptor[]
|
|
68
68
|
|
|
69
69
|
beforeEach(async () => {
|
|
70
|
-
simulator = new Simulator(LatencyType.
|
|
70
|
+
simulator = new Simulator(LatencyType.REAL)
|
|
71
71
|
|
|
72
72
|
entryPoint1 = await createMockConnectionDhtNode('entryPoint1', simulator)
|
|
73
73
|
entryPoint2 = await createMockConnectionDhtNode('entryPoint2', simulator)
|
|
@@ -76,8 +76,8 @@ describe('multiple entry point joining', () => {
|
|
|
76
76
|
node2 = await createMockConnectionDhtNode('node2', simulator)
|
|
77
77
|
|
|
78
78
|
entryPoints = [
|
|
79
|
-
entryPoint1.
|
|
80
|
-
entryPoint2.
|
|
79
|
+
entryPoint1.getLocalPeerDescriptor(),
|
|
80
|
+
entryPoint2.getLocalPeerDescriptor(),
|
|
81
81
|
]
|
|
82
82
|
|
|
83
83
|
await entryPoint1.joinDht(entryPoints)
|