@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
|
@@ -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/
|
|
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.
|
|
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.
|
|
78
|
-
targetDescriptor: destinationNode.
|
|
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.
|
|
84
|
+
destinationPeer: destinationNode.getLocalPeerDescriptor(),
|
|
85
85
|
requestId: v4(),
|
|
86
|
-
sourcePeer: sourceNode.
|
|
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.
|
|
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.
|
|
112
|
-
targetDescriptor: destinationNode.
|
|
111
|
+
sourceDescriptor: sourceNode.getLocalPeerDescriptor(),
|
|
112
|
+
targetDescriptor: destinationNode.getLocalPeerDescriptor()
|
|
113
113
|
}
|
|
114
114
|
sourceNode.router!.doRouteMessage({
|
|
115
115
|
message,
|
|
116
|
-
destinationPeer: destinationNode.
|
|
116
|
+
destinationPeer: destinationNode.getLocalPeerDescriptor(),
|
|
117
117
|
requestId: v4(),
|
|
118
|
-
sourcePeer: sourceNode.
|
|
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())
|
|
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.
|
|
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.
|
|
168
|
-
targetDescriptor: destinationNode.
|
|
167
|
+
sourceDescriptor: node.getLocalPeerDescriptor(),
|
|
168
|
+
targetDescriptor: destinationNode.getLocalPeerDescriptor()
|
|
169
169
|
}
|
|
170
170
|
node.router!.doRouteMessage({
|
|
171
171
|
message,
|
|
172
|
-
destinationPeer: receiver.
|
|
173
|
-
sourcePeer: node.
|
|
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.
|
|
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.
|
|
203
|
-
targetDescriptor: destinationNode.
|
|
202
|
+
sourceDescriptor: sourceNode.getLocalPeerDescriptor()!,
|
|
203
|
+
targetDescriptor: destinationNode.getLocalPeerDescriptor()!
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
const routeMessageWrapper: RouteMessageWrapper = {
|
|
207
207
|
message: closestPeersRequestMessage,
|
|
208
|
-
destinationPeer: destinationNode.
|
|
208
|
+
destinationPeer: destinationNode.getLocalPeerDescriptor(),
|
|
209
209
|
requestId: v4(),
|
|
210
|
-
sourcePeer: sourceNode.
|
|
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.
|
|
233
|
-
targetDescriptor: entryPoint.
|
|
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.
|
|
240
|
-
destinationPeer: entryPoint.
|
|
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/
|
|
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/
|
|
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 {
|
|
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 = (
|
|
15
|
+
const createConnectionManager = (localPeerDescriptor: PeerDescriptor, transport: ITransport) => {
|
|
16
16
|
return new ConnectionManager({
|
|
17
17
|
createConnectorFacade: () => new DefaultConnectorFacade({
|
|
18
18
|
transport,
|
|
19
|
-
|
|
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<
|
|
34
|
-
//let client2: ProtoRpcClient<
|
|
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
|
|
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
|
|
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
|
|
136
|
+
it('Disconnects WebrtcConnection while being connected', async () => {
|
|
137
137
|
|
|
138
138
|
const rpcMessage: RpcMessage = {
|
|
139
139
|
header: {},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LatencyType, Simulator } from '../../src/connection/
|
|
1
|
+
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
5
|
-
import { areEqualPeerDescriptors,
|
|
5
|
+
import { areEqualPeerDescriptors, getNodeIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
6
6
|
import { Logger } from '@streamr/utils'
|
|
7
7
|
|
|
8
8
|
const logger = new Logger(module)
|
|
@@ -11,7 +11,7 @@ describe('Scaling down a Dht network', () => {
|
|
|
11
11
|
let entryPoint: DhtNode
|
|
12
12
|
let nodes: DhtNode[]
|
|
13
13
|
let entrypointDescriptor: PeerDescriptor
|
|
14
|
-
const simulator = new Simulator(LatencyType.
|
|
14
|
+
const simulator = new Simulator(LatencyType.REAL)
|
|
15
15
|
const NUM_NODES = 80
|
|
16
16
|
const MAX_CONNECTIONS = 15
|
|
17
17
|
const K = 2
|
|
@@ -49,13 +49,13 @@ describe('Scaling down a Dht network', () => {
|
|
|
49
49
|
const index = Math.floor(Math.random() * randomIndices.length)
|
|
50
50
|
const nodeIndex = randomIndices[index]
|
|
51
51
|
randomIndices.splice(index, 1)
|
|
52
|
-
const stoppingPeerDescriptor = nodes[nodeIndex].
|
|
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(
|
|
58
|
-
+
|
|
57
|
+
logger.error(getNodeIdFromPeerDescriptor(node.getLocalPeerDescriptor()) + ', '
|
|
58
|
+
+ getNodeIdFromPeerDescriptor(stoppingPeerDescriptor) + ' cleaning up failed')
|
|
59
59
|
}
|
|
60
60
|
return !areEqualPeerDescriptors(peer, stoppingPeerDescriptor)
|
|
61
61
|
})
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { MetricsContext, waitForCondition } from '@streamr/utils'
|
|
2
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
3
3
|
import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../../src/connection/ConnectorFacade'
|
|
4
|
-
import { Simulator } from '../../src/connection/
|
|
5
|
-
import { SimulatorTransport } from '../../src/connection/
|
|
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 = (
|
|
10
|
+
const createConnectionManager = (localPeerDescriptor: PeerDescriptor, opts: Omit<DefaultConnectorFacadeConfig, 'createLocalPeerDescriptor'>) => {
|
|
11
11
|
return new ConnectionManager({
|
|
12
12
|
createConnectorFacade: () => new DefaultConnectorFacade({
|
|
13
|
-
|
|
13
|
+
createLocalPeerDescriptor: () => localPeerDescriptor,
|
|
14
14
|
...opts
|
|
15
15
|
}),
|
|
16
16
|
metricsContext: new MetricsContext()
|
|
@@ -118,12 +118,14 @@ describe('SimultaneousConnections', () => {
|
|
|
118
118
|
connectionManager1 = createConnectionManager(wsPeer1, {
|
|
119
119
|
transport: simulatorTransport1,
|
|
120
120
|
websocketPortRange,
|
|
121
|
-
entryPoints: [wsPeer1]
|
|
121
|
+
entryPoints: [wsPeer1],
|
|
122
|
+
websocketServerEnableTls: false
|
|
122
123
|
})
|
|
123
124
|
connectionManager2 = createConnectionManager(wsPeer2, {
|
|
124
125
|
transport: simulatorTransport2,
|
|
125
126
|
websocketPortRange,
|
|
126
|
-
entryPoints: [wsPeer1]
|
|
127
|
+
entryPoints: [wsPeer1],
|
|
128
|
+
websocketServerEnableTls: false
|
|
127
129
|
})
|
|
128
130
|
await connectionManager1.start()
|
|
129
131
|
await connectionManager2.start()
|
|
@@ -193,7 +195,8 @@ describe('SimultaneousConnections', () => {
|
|
|
193
195
|
connectionManager1 = createConnectionManager(wsPeer1, {
|
|
194
196
|
transport: simulatorTransport1,
|
|
195
197
|
websocketPortRange: { min: 43432, max: 43432 },
|
|
196
|
-
entryPoints: [wsPeer1]
|
|
198
|
+
entryPoints: [wsPeer1],
|
|
199
|
+
websocketServerEnableTls: false
|
|
197
200
|
})
|
|
198
201
|
connectionManager2 = createConnectionManager(wsPeer2, {
|
|
199
202
|
transport: simulatorTransport2
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LatencyType, Simulator } from '../../src/connection/
|
|
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 { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
@@ -10,7 +10,7 @@ describe('Storing data in DHT', () => {
|
|
|
10
10
|
let entryPoint: DhtNode
|
|
11
11
|
let nodes: DhtNode[]
|
|
12
12
|
let entrypointDescriptor: PeerDescriptor
|
|
13
|
-
const simulator = new Simulator(LatencyType.
|
|
13
|
+
const simulator = new Simulator(LatencyType.REAL)
|
|
14
14
|
const NUM_NODES = 100
|
|
15
15
|
const MAX_CONNECTIONS = 20
|
|
16
16
|
const K = 4
|
|
@@ -27,10 +27,7 @@ describe('Storing data in DHT', () => {
|
|
|
27
27
|
undefined, K, MAX_CONNECTIONS)
|
|
28
28
|
nodes.push(entryPoint)
|
|
29
29
|
nodeIndicesById[entryPoint.getNodeId().toKey()] = 0
|
|
30
|
-
entrypointDescriptor =
|
|
31
|
-
kademliaId: entryPoint.getNodeId().value,
|
|
32
|
-
type: NodeType.NODEJS
|
|
33
|
-
}
|
|
30
|
+
entrypointDescriptor = entryPoint.getLocalPeerDescriptor()
|
|
34
31
|
nodes.push(entryPoint)
|
|
35
32
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
36
33
|
const nodeId = `${i}`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LatencyType, Simulator } from '../../src/connection/
|
|
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 { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
@@ -10,7 +10,7 @@ describe('Storing data in DHT', () => {
|
|
|
10
10
|
let entryPoint: DhtNode
|
|
11
11
|
let nodes: DhtNode[]
|
|
12
12
|
let entrypointDescriptor: PeerDescriptor
|
|
13
|
-
const simulator = new Simulator(LatencyType.
|
|
13
|
+
const simulator = new Simulator(LatencyType.REAL)
|
|
14
14
|
const NUM_NODES = 5
|
|
15
15
|
const MAX_CONNECTIONS = 5
|
|
16
16
|
const K = 4
|
|
@@ -27,10 +27,7 @@ describe('Storing data in DHT', () => {
|
|
|
27
27
|
undefined, K, MAX_CONNECTIONS)
|
|
28
28
|
nodes.push(entryPoint)
|
|
29
29
|
nodeIndicesById[entryPoint.getNodeId().toKey()] = 0
|
|
30
|
-
entrypointDescriptor =
|
|
31
|
-
kademliaId: entryPoint.getNodeId().value,
|
|
32
|
-
type: NodeType.NODEJS
|
|
33
|
-
}
|
|
30
|
+
entrypointDescriptor = entryPoint.getLocalPeerDescriptor()
|
|
34
31
|
nodes.push(entryPoint)
|
|
35
32
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
36
33
|
const nodeId = `${i}`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import { Simulator } from '../../src/connection/
|
|
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.
|
|
34
|
-
await otherNode.joinDht([entryPoint.
|
|
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.
|
|
45
|
+
const data1 = Any.pack(otherNode.getLocalPeerDescriptor(), PeerDescriptor)
|
|
46
46
|
const dataKey2 = PeerID.fromString('other-node-stored-data')
|
|
47
|
-
const data2 = Any.pack(entryPoint.
|
|
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.
|
|
52
|
-
expect(successfulStorers2[0].kademliaId).toStrictEqual(otherNode.
|
|
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.
|
|
57
|
-
expect(areEqualPeerDescriptors(entryPoint.
|
|
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.
|
|
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.
|
|
66
|
+
expect(successfulStorers[0].kademliaId).toStrictEqual(entryPoint.getLocalPeerDescriptor().kademliaId)
|
|
67
67
|
|
|
68
68
|
const foundData = await entryPoint.getDataFromDht(dataKey.value)
|
|
69
|
-
expect(areEqualPeerDescriptors(entryPoint.
|
|
69
|
+
expect(areEqualPeerDescriptors(entryPoint.getLocalPeerDescriptor(), Any.unpack(foundData[0]!.data!, PeerDescriptor))).toBeTrue()
|
|
70
70
|
}, 60000)
|
|
71
71
|
})
|
package/test/integration/{WebRtcConnectionManagement.test.ts → WebrtcConnectionManagement.test.ts}
RENAMED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
2
|
-
import { LatencyType, Simulator } from '../../src/connection/
|
|
2
|
+
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
3
3
|
import { Message, MessageType, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
5
5
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
6
6
|
import { ConnectionType } from '../../src/connection/IConnection'
|
|
7
7
|
import { ITransport } from '../../src/transport/ITransport'
|
|
8
8
|
import * as Err from '../../src/helpers/errors'
|
|
9
|
-
import { SimulatorTransport } from '../../src/connection/
|
|
9
|
+
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
10
10
|
import { DefaultConnectorFacade } from '../../src/connection/ConnectorFacade'
|
|
11
11
|
import { MetricsContext } from '@streamr/utils'
|
|
12
12
|
|
|
13
|
-
const createConnectionManager = (
|
|
13
|
+
const createConnectionManager = (localPeerDescriptor: PeerDescriptor, transport: ITransport) => {
|
|
14
14
|
return new ConnectionManager({
|
|
15
15
|
createConnectorFacade: () => new DefaultConnectorFacade({
|
|
16
16
|
transport,
|
|
17
|
-
|
|
17
|
+
createLocalPeerDescriptor: () => localPeerDescriptor
|
|
18
18
|
}),
|
|
19
19
|
metricsContext: new MetricsContext()
|
|
20
20
|
})
|
|
@@ -200,7 +200,7 @@ describe('WebRTC Connection Management', () => {
|
|
|
200
200
|
|
|
201
201
|
msg.targetDescriptor = peerDescriptor2
|
|
202
202
|
manager1.send(msg).catch((e) => {
|
|
203
|
-
expect(e.code).toEqual('
|
|
203
|
+
expect(e.code).toEqual('SEND_FAILED')
|
|
204
204
|
})
|
|
205
205
|
|
|
206
206
|
// @ts-expect-error private field
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { ProtoRpcClient, RpcCommunicator, toProtoRpcClient } from '@streamr/proto-rpc'
|
|
2
|
-
import {
|
|
2
|
+
import { WebrtcConnectorRpcClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
|
|
3
3
|
import {
|
|
4
4
|
IceCandidate,
|
|
5
5
|
NodeType,
|
|
6
6
|
PeerDescriptor,
|
|
7
7
|
RtcAnswer,
|
|
8
8
|
RtcOffer,
|
|
9
|
-
|
|
9
|
+
WebrtcConnectionRequest
|
|
10
10
|
} from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
11
11
|
import { Empty } from '../../src/proto/google/protobuf/empty'
|
|
12
12
|
import { generateId } from '../utils/utils'
|
|
13
|
-
import {
|
|
13
|
+
import { IWebrtcConnectorRpc } from '../../src/proto/packages/dht/protos/DhtRpc.server'
|
|
14
14
|
import { waitForCondition } from '@streamr/utils'
|
|
15
15
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
16
16
|
|
|
17
17
|
describe('WebRTC rpc messages', () => {
|
|
18
18
|
let rpcCommunicator1: RpcCommunicator
|
|
19
19
|
let rpcCommunicator2: RpcCommunicator
|
|
20
|
-
let client: ProtoRpcClient<
|
|
20
|
+
let client: ProtoRpcClient<WebrtcConnectorRpcClient>
|
|
21
21
|
|
|
22
22
|
let requestConnectionCounter: number
|
|
23
23
|
let rtcOfferCounter: number
|
|
@@ -36,7 +36,7 @@ describe('WebRTC rpc messages', () => {
|
|
|
36
36
|
iceCandidateCounter = 0
|
|
37
37
|
|
|
38
38
|
rpcCommunicator1 = new RpcCommunicator()
|
|
39
|
-
const serverFunctions:
|
|
39
|
+
const serverFunctions: IWebrtcConnectorRpc = {
|
|
40
40
|
|
|
41
41
|
requestConnection: async (): Promise<Empty> => {
|
|
42
42
|
requestConnectionCounter += 1
|
|
@@ -67,7 +67,7 @@ describe('WebRTC rpc messages', () => {
|
|
|
67
67
|
rpcCommunicator2.registerRpcNotification(RtcOffer, 'rtcOffer', serverFunctions.rtcOffer)
|
|
68
68
|
rpcCommunicator2.registerRpcNotification(RtcAnswer, 'rtcAnswer', serverFunctions.rtcAnswer)
|
|
69
69
|
rpcCommunicator2.registerRpcNotification(IceCandidate, 'iceCandidate', serverFunctions.iceCandidate)
|
|
70
|
-
rpcCommunicator2.registerRpcNotification(
|
|
70
|
+
rpcCommunicator2.registerRpcNotification(WebrtcConnectionRequest, 'requestConnection', serverFunctions.requestConnection)
|
|
71
71
|
|
|
72
72
|
rpcCommunicator1.on('outgoingMessage', (message: RpcMessage) => {
|
|
73
73
|
rpcCommunicator2.handleIncomingMessage(message)
|
|
@@ -77,7 +77,7 @@ describe('WebRTC rpc messages', () => {
|
|
|
77
77
|
rpcCommunicator1.handleIncomingMessage(message)
|
|
78
78
|
})
|
|
79
79
|
|
|
80
|
-
client = toProtoRpcClient(new
|
|
80
|
+
client = toProtoRpcClient(new WebrtcConnectorRpcClient(rpcCommunicator1.getRpcClientTransport()))
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
afterEach(async () => {
|
|
@@ -87,7 +87,6 @@ describe('WebRTC rpc messages', () => {
|
|
|
87
87
|
|
|
88
88
|
it('send connectionRequest', async () => {
|
|
89
89
|
client.requestConnection({
|
|
90
|
-
connectionId: 'connectionRequest'
|
|
91
90
|
},
|
|
92
91
|
{ targetDescriptor, notification: true }
|
|
93
92
|
)
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { WebsocketServer } from '../../src/connection/websocket/WebsocketServer'
|
|
4
4
|
import { IConnection } from '../../src/connection/IConnection'
|
|
5
|
-
import {
|
|
5
|
+
import { ClientWebsocket } from '../../src/connection/websocket/ClientWebsocket'
|
|
6
6
|
import { Logger } from '@streamr/utils'
|
|
7
7
|
|
|
8
8
|
const logger = new Logger(module)
|
|
9
9
|
|
|
10
|
-
describe('
|
|
10
|
+
describe('Websocket', () => {
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
portRange: { min:
|
|
12
|
+
const websocketServer = new WebsocketServer({
|
|
13
|
+
portRange: { min: 9977, max: 9977 },
|
|
14
|
+
enableTls: false
|
|
14
15
|
})
|
|
15
|
-
const
|
|
16
|
+
const clientWebsocket = new ClientWebsocket()
|
|
16
17
|
|
|
17
18
|
beforeAll(async () => {
|
|
18
|
-
await
|
|
19
|
+
await websocketServer.start()
|
|
19
20
|
})
|
|
20
21
|
|
|
21
22
|
it('Happy path', (done) => {
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
websocketServer.on('connected', (serverConnection: IConnection) => {
|
|
24
25
|
const time = Date.now()
|
|
25
26
|
logger.info('server side sendind msg at ' + time)
|
|
26
27
|
serverConnection.send(Uint8Array.from([1, 2, 3, 4]))
|
|
@@ -40,11 +41,11 @@ describe('WebSocket', () => {
|
|
|
40
41
|
})
|
|
41
42
|
})
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
clientWebsocket.on('connected', () => {
|
|
44
45
|
const time = Date.now()
|
|
45
46
|
logger.info('client side setting listeners at ' + time)
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
clientWebsocket.on('data', (bytes: Uint8Array) => {
|
|
48
49
|
const time = Date.now()
|
|
49
50
|
logger.info('client side receiving message at ' + time)
|
|
50
51
|
|
|
@@ -53,14 +54,14 @@ describe('WebSocket', () => {
|
|
|
53
54
|
|
|
54
55
|
const time2 = Date.now()
|
|
55
56
|
logger.info('client side sendind msg at ' + time2)
|
|
56
|
-
|
|
57
|
+
clientWebsocket.send(Uint8Array.from([1, 2, 3, 4]))
|
|
57
58
|
})
|
|
58
59
|
})
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
clientWebsocket.connect('ws://127.0.0.1:9977')
|
|
61
62
|
})
|
|
62
63
|
|
|
63
64
|
afterAll(async () => {
|
|
64
|
-
await
|
|
65
|
+
await websocketServer.stop()
|
|
65
66
|
})
|
|
66
67
|
})
|
|
@@ -4,24 +4,24 @@ import { MetricsContext, waitForCondition } from '@streamr/utils'
|
|
|
4
4
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
5
5
|
import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../../src/connection/ConnectorFacade'
|
|
6
6
|
import { ConnectionType } from '../../src/connection/IConnection'
|
|
7
|
-
import { Simulator } from '../../src/connection/
|
|
7
|
+
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
8
8
|
import { SimulatorTransport } from '../../src/exports'
|
|
9
9
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
10
10
|
import * as Err from '../../src/helpers/errors'
|
|
11
11
|
import { Message, MessageType, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
12
12
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
13
13
|
|
|
14
|
-
const createConfig = (
|
|
14
|
+
const createConfig = (localPeerDescriptor: PeerDescriptor, opts: Omit<DefaultConnectorFacadeConfig, 'createLocalPeerDescriptor'>) => {
|
|
15
15
|
return {
|
|
16
16
|
createConnectorFacade: () => new DefaultConnectorFacade({
|
|
17
|
-
|
|
17
|
+
createLocalPeerDescriptor: () => localPeerDescriptor,
|
|
18
18
|
...opts
|
|
19
19
|
}),
|
|
20
20
|
metricsContext: new MetricsContext()
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
describe('
|
|
24
|
+
describe('Websocket Connection Management', () => {
|
|
25
25
|
|
|
26
26
|
const serviceId = 'test'
|
|
27
27
|
let wsServerManager: ConnectionManager
|