@streamr/dht 100.0.0-pretestnet.2 → 100.0.0-pretestnet.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +6 -6
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +5 -8
- package/dist/src/connection/ConnectionManager.js +77 -107
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.d.ts +7 -6
- package/dist/src/connection/ConnectivityChecker.js +23 -20
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +15 -12
- package/dist/src/connection/ConnectorFacade.js +61 -26
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +2 -2
- package/dist/src/connection/Handshaker.js +28 -28
- 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 +3 -4
- package/dist/src/connection/ManagedConnection.js +30 -30
- 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 +22 -22
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.d.ts +2 -2
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js +11 -11
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js.map +1 -1
- 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} +36 -36
- 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} +20 -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} +23 -27
- package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -0
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcLocal.d.ts → websocket/WebsocketConnector.d.ts} +23 -15
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcLocal.js → websocket/WebsocketConnector.js} +107 -101
- 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} +5 -10
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js.map → websocket/WebsocketConnectorRpcRemote.js.map} +1 -1
- 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 +119 -150
- 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} +17 -21
- 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 +8 -8
- 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 +5 -5
- 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 +47 -90
- 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 +15 -43
- 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 +25 -24
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.js +3 -7
- 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/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 +64 -84
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +64 -66
- 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 +32 -35
- package/src/connection/ConnectionLockHandler.ts +19 -17
- package/src/connection/ConnectionLockRpcLocal.ts +74 -0
- package/src/connection/ConnectionLockRpcRemote.ts +7 -6
- package/src/connection/ConnectionManager.ts +59 -95
- package/src/connection/ConnectivityChecker.ts +30 -26
- package/src/connection/ConnectorFacade.ts +74 -34
- package/src/connection/Handshaker.ts +9 -9
- package/src/connection/IConnection.ts +5 -6
- package/src/connection/ManagedConnection.ts +21 -22
- package/src/connection/{ManagedWebRtcConnection.ts → ManagedWebrtcConnection.ts} +9 -9
- package/src/connection/{Simulator → simulator}/Simulator.ts +4 -4
- package/src/connection/{Simulator → simulator}/SimulatorConnection.ts +23 -24
- package/src/connection/{Simulator → simulator}/SimulatorConnector.ts +13 -13
- package/src/connection/{Simulator → simulator}/SimulatorTransport.ts +2 -2
- package/src/connection/{WebRTC/BrowserWebRtcConnection.ts → webrtc/BrowserWebrtcConnection.ts} +12 -13
- package/src/connection/{WebRTC/IWebRtcConnection.ts → webrtc/IWebrtcConnection.ts} +2 -2
- package/src/connection/{WebRTC/NodeWebRtcConnection.ts → webrtc/NodeWebrtcConnection.ts} +32 -33
- package/src/connection/webrtc/WebrtcConnector.ts +225 -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} +19 -17
- package/src/connection/{WebSocket/ServerWebSocket.ts → websocket/ServerWebsocket.ts} +21 -27
- package/src/connection/{WebSocket/WebSocketConnectorRpcLocal.ts → websocket/WebsocketConnector.ts} +109 -100
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +41 -0
- package/src/connection/{WebSocket/WebSocketConnectorRpcRemote.ts → websocket/WebsocketConnectorRpcRemote.ts} +6 -12
- package/src/connection/{WebSocket/WebSocketServer.ts → websocket/WebsocketServer.ts} +40 -22
- package/src/dht/DhtNode.ts +144 -179
- package/src/dht/DhtNodeRpcLocal.ts +68 -0
- package/src/dht/{RemoteDhtNode.ts → DhtNodeRpcRemote.ts} +12 -13
- 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 +23 -20
- package/src/dht/discovery/PeerDiscovery.ts +14 -17
- 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 +69 -105
- package/src/dht/routing/RouterRpcLocal.ts +81 -0
- package/src/dht/routing/RouterRpcRemote.ts +15 -45
- package/src/dht/routing/RoutingSession.ts +56 -61
- package/src/dht/routing/getPreviousPeer.ts +6 -0
- package/src/dht/store/StoreRpcLocal.ts +44 -37
- package/src/dht/store/StoreRpcRemote.ts +4 -8
- package/src/exports.ts +11 -5
- package/src/helpers/Connectivity.ts +19 -0
- package/src/helpers/errors.ts +3 -3
- 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 +87 -114
- 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} +6 -6
- package/test/benchmark/KademliaCorrectness.test.ts +2 -2
- 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 +24 -6
- 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 +4 -4
- package/test/integration/ConnectionManager.test.ts +37 -28
- 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} +3 -3
- package/test/integration/Layer1-scale.test.ts +1 -1
- package/test/integration/MigrateData.test.ts +6 -5
- package/test/integration/Mock-Layer1-Layer0.test.ts +1 -1
- package/test/integration/MultipleEntryPointJoining.test.ts +6 -6
- package/test/integration/RouteMessage.test.ts +26 -26
- package/test/integration/RpcErrors.test.ts +10 -10
- package/test/integration/ScaleDownDht.test.ts +3 -3
- package/test/integration/SimultaneousConnections.test.ts +10 -7
- package/test/integration/Store.test.ts +1 -1
- package/test/integration/StoreAndDelete.test.ts +1 -1
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +12 -12
- package/test/integration/{WebRtcConnectionManagement.test.ts → WebrtcConnectionManagement.test.ts} +4 -4
- 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 +14 -24
- 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/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.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/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,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,11 +1,11 @@
|
|
|
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, 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[]
|
|
@@ -42,7 +42,7 @@ describe('Recursive find correctness', () => {
|
|
|
42
42
|
|
|
43
43
|
it('Entrypoint can find a node from the network (exact match)', async () => {
|
|
44
44
|
const kademliaIdToFind = nodes[45].getNodeId().value
|
|
45
|
-
const results = await entryPoint.
|
|
45
|
+
const results = await entryPoint.startFind(kademliaIdToFind)
|
|
46
46
|
expect(results.closestNodes.length).toBeGreaterThanOrEqual(5)
|
|
47
47
|
expect(PeerID.fromValue(kademliaIdToFind).equals(peerIdFromPeerDescriptor(results.closestNodes[0])))
|
|
48
48
|
}, 30000)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Simulator } from '../../src/connection/
|
|
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'
|
|
@@ -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
|
|
|
@@ -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(keyFromPeerDescriptor(contact.getPeerDescriptor()) + ' ' + keyFromPeerDescriptor(node.getLocalPeerDescriptor()) + hasDataMarker)
|
|
118
119
|
})
|
|
119
120
|
|
|
120
121
|
logger.info(NUM_NODES + ' nodes joining layer0 DHT')
|
|
121
122
|
await Promise.all(
|
|
122
123
|
nodes.map((node) => {
|
|
123
|
-
if (keyFromPeerDescriptor(node.
|
|
124
|
+
if (keyFromPeerDescriptor(node.getLocalPeerDescriptor()) != '0') {
|
|
124
125
|
node.joinDht([entrypointDescriptor])
|
|
125
126
|
}
|
|
126
127
|
})
|
|
@@ -142,7 +143,7 @@ describe('Migrating data from node to node in DHT', () => {
|
|
|
142
143
|
hasDataMarker = '<-'
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
logger.info(keyFromPeerDescriptor(node.
|
|
146
|
+
logger.info(keyFromPeerDescriptor(node.getLocalPeerDescriptor()) + hasDataMarker)
|
|
146
147
|
})
|
|
147
148
|
|
|
148
149
|
const closestNode = nodesById.get(PeerID.fromValue(closest[0].getPeerDescriptor().kademliaId).toKey())!
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@streamr/utils'
|
|
2
|
-
import { Simulator } from '../../src/connection/
|
|
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'
|
|
@@ -21,9 +21,9 @@ describe('multiple entry point joining', () => {
|
|
|
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
|
|
|
@@ -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)
|
|
@@ -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,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 { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
@@ -49,12 +49,12 @@ describe('Scaling down a Dht network', () => {
|
|
|
49
49
|
const index = Math.floor(Math.random() * randomIndices.length)
|
|
50
50
|
const nodeIndex = randomIndices[index]
|
|
51
51
|
randomIndices.splice(index, 1)
|
|
52
|
-
const stoppingPeerDescriptor = nodes[nodeIndex].
|
|
52
|
+
const stoppingPeerDescriptor = nodes[nodeIndex].getLocalPeerDescriptor()
|
|
53
53
|
await nodes[nodeIndex].stop()
|
|
54
54
|
const nodeIsCleaned = nodes.every((node) =>
|
|
55
55
|
node.getAllConnectionPeerDescriptors().every((peer) => {
|
|
56
56
|
if (areEqualPeerDescriptors(peer, stoppingPeerDescriptor)) {
|
|
57
|
-
logger.error(keyFromPeerDescriptor(node.
|
|
57
|
+
logger.error(keyFromPeerDescriptor(node.getLocalPeerDescriptor()) + ', '
|
|
58
58
|
+ keyFromPeerDescriptor(stoppingPeerDescriptor) + ' cleaning up failed')
|
|
59
59
|
}
|
|
60
60
|
return !areEqualPeerDescriptors(peer, stoppingPeerDescriptor)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { MetricsContext, waitForCondition } from '@streamr/utils'
|
|
2
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
3
3
|
import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../../src/connection/ConnectorFacade'
|
|
4
|
-
import { Simulator } from '../../src/connection/
|
|
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,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 { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { createMockConnectionDhtNode, waitConnectionManagersReadyForTesting } from '../utils/utils'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LatencyType, Simulator } from '../../src/connection/
|
|
1
|
+
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { createMockConnectionDhtNode, waitConnectionManagersReadyForTesting } from '../utils/utils'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import { Simulator } from '../../src/connection/
|
|
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
|
})
|