@streamr/dht 101.1.2 → 102.0.0-beta.0
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/.eslintignore +1 -1
- package/dist/{src/proto → generated}/google/protobuf/any.d.ts +11 -4
- package/dist/generated/google/protobuf/any.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/empty.d.ts +0 -1
- package/dist/generated/google/protobuf/empty.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/timestamp.d.ts +9 -3
- package/dist/generated/google/protobuf/timestamp.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.d.ts +9 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.js +7 -0
- package/dist/generated/packages/dht/protos/DhtRpc.client.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.d.ts +16 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.js +16 -2
- package/dist/generated/packages/dht/protos/DhtRpc.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.d.ts +5 -0
- package/dist/generated/packages/dht/protos/DhtRpc.server.js.map +1 -0
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js.map +1 -0
- package/dist/package.json +11 -11
- package/dist/src/connection/Connection.d.ts +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +5 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +9 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +3 -2
- package/dist/src/connection/ConnectionLockRpcRemote.js +14 -3
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionLockStates.d.ts +5 -0
- package/dist/src/connection/ConnectionLockStates.js +14 -0
- package/dist/src/connection/ConnectionLockStates.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +8 -1
- package/dist/src/connection/ConnectionManager.js +78 -24
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectionsView.d.ts +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +1 -1
- package/dist/src/connection/Handshaker.d.ts +1 -1
- package/dist/src/connection/Handshaker.js +2 -2
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +7 -1
- package/dist/src/connection/ManagedConnection.js +24 -1
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/PendingConnection.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.js +2 -1
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +1 -1
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.d.ts +1 -1
- package/dist/src/connection/simulator/Simulator.js +2 -2
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +9 -9
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +4 -4
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorTransport.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorTransport.js +2 -1
- package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +13 -6
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +2 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +9 -8
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +3 -3
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +4 -4
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +1 -0
- package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnector.js +3 -3
- package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +3 -3
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.js +7 -7
- package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +4 -2
- package/dist/src/dht/DhtNode.js +17 -6
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +2 -2
- package/dist/src/dht/DhtNodeRpcRemote.js +3 -3
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +1 -1
- package/dist/src/dht/PeerManager.js +10 -10
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/Contact.d.ts +1 -1
- package/dist/src/dht/contact/Contact.js +1 -1
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/RingContactList.d.ts +1 -1
- package/dist/src/dht/contact/RingContactList.js +1 -1
- package/dist/src/dht/contact/RingContactList.js.map +1 -1
- package/dist/src/dht/contact/RpcRemote.d.ts +1 -1
- package/dist/src/dht/contact/SortedContactList.js +1 -1
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/contact/ringIdentifiers.d.ts +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +1 -1
- package/dist/src/dht/discovery/DiscoverySession.js +3 -3
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.js +7 -7
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +8 -8
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +7 -7
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/Router.d.ts +4 -1
- package/dist/src/dht/routing/Router.js +17 -9
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcLocal.js +5 -5
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcRemote.js +7 -7
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +1 -1
- package/dist/src/dht/routing/RoutingSession.js +5 -6
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/getPreviousPeer.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.js +2 -2
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +2 -2
- package/dist/src/dht/store/StoreManager.js +8 -8
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/dist/src/dht/store/StoreRpcLocal.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcLocal.js +4 -4
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcRemote.js +7 -4
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +2 -2
- package/dist/src/exports.js +6 -6
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/Connectivity.d.ts +1 -1
- package/dist/src/helpers/Connectivity.js +1 -1
- package/dist/src/helpers/Connectivity.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptor.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptor.js +2 -2
- package/dist/src/helpers/createPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +1 -1
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/identifiers.d.ts +5 -5
- package/dist/src/identifiers.js +11 -11
- package/dist/src/identifiers.js.map +1 -1
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +1 -1
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +1 -1
- package/dist/src/transport/ITransport.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +13 -4
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +1 -1
- package/{src/proto → generated}/google/protobuf/any.ts +11 -4
- package/{src/proto → generated}/google/protobuf/empty.ts +0 -1
- package/{src/proto → generated}/google/protobuf/timestamp.ts +9 -3
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.client.ts +12 -0
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.server.ts +5 -0
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.ts +23 -1
- package/package.json +11 -11
- package/proto.sh +2 -3
- package/protos/DhtRpc.proto +5 -0
- package/src/connection/Connection.ts +1 -1
- package/src/connection/ConnectionLockRpcLocal.ts +16 -7
- package/src/connection/ConnectionLockRpcRemote.ts +18 -6
- package/src/connection/ConnectionLockStates.ts +18 -0
- package/src/connection/ConnectionManager.ts +92 -26
- package/src/connection/ConnectionsView.ts +1 -1
- package/src/connection/ConnectorFacade.ts +1 -1
- package/src/connection/Handshaker.ts +3 -3
- package/src/connection/ManagedConnection.ts +28 -3
- package/src/connection/PendingConnection.ts +1 -1
- package/src/connection/connectivityChecker.ts +2 -1
- package/src/connection/connectivityRequestHandler.ts +1 -1
- package/src/connection/simulator/Simulator.ts +4 -4
- package/src/connection/simulator/SimulatorConnection.ts +10 -10
- package/src/connection/simulator/SimulatorConnector.ts +5 -5
- package/src/connection/simulator/SimulatorTransport.ts +3 -2
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +10 -1
- package/src/connection/webrtc/NodeWebrtcConnection.ts +15 -9
- package/src/connection/webrtc/WebrtcConnector.ts +10 -8
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +8 -8
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +2 -2
- package/src/connection/websocket/WebsocketClientConnector.ts +5 -5
- package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +5 -5
- package/src/connection/websocket/WebsocketClientConnectorRpcRemote.ts +4 -4
- package/src/connection/websocket/WebsocketServerConnector.ts +8 -8
- package/src/dht/DhtNode.ts +21 -8
- package/src/dht/DhtNodeRpcLocal.ts +7 -7
- package/src/dht/DhtNodeRpcRemote.ts +5 -5
- package/src/dht/ExternalApiRpcLocal.ts +8 -8
- package/src/dht/ExternalApiRpcRemote.ts +6 -6
- package/src/dht/PeerManager.ts +12 -12
- package/src/dht/contact/Contact.ts +3 -3
- package/src/dht/contact/RingContactList.ts +3 -3
- package/src/dht/contact/RpcRemote.ts +1 -1
- package/src/dht/contact/SortedContactList.ts +2 -2
- package/src/dht/contact/ringIdentifiers.ts +1 -1
- package/src/dht/discovery/DiscoverySession.ts +5 -5
- package/src/dht/discovery/PeerDiscovery.ts +12 -12
- package/src/dht/discovery/RingDiscoverySession.ts +3 -3
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +9 -9
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +4 -4
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +6 -6
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +8 -8
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +5 -5
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +2 -2
- package/src/dht/routing/Router.ts +19 -10
- package/src/dht/routing/RouterRpcLocal.ts +7 -7
- package/src/dht/routing/RouterRpcRemote.ts +9 -9
- package/src/dht/routing/RoutingSession.ts +7 -8
- package/src/dht/routing/getPreviousPeer.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +4 -4
- package/src/dht/store/StoreManager.ts +12 -12
- package/src/dht/store/StoreRpcLocal.ts +8 -8
- package/src/dht/store/StoreRpcRemote.ts +10 -7
- package/src/exports.ts +5 -5
- package/src/helpers/Connectivity.ts +1 -1
- package/src/helpers/createPeerDescriptor.ts +3 -3
- package/src/helpers/createPeerDescriptorSignaturePayload.ts +1 -1
- package/src/helpers/protoClasses.ts +1 -1
- package/src/identifiers.ts +7 -7
- package/src/rpc-protocol/DhtCallContext.ts +1 -1
- package/src/rpc-protocol/DhtRpcOptions.ts +1 -1
- package/src/transport/ITransport.ts +2 -1
- package/src/transport/ListeningRpcCommunicator.ts +14 -6
- package/src/transport/RoutingRpcCommunicator.ts +2 -2
- package/test/benchmark/Find.test.ts +6 -6
- package/test/benchmark/KademliaCorrectness.test.ts +5 -5
- package/test/benchmark/RingCorrectness.test.ts +5 -5
- package/test/benchmark/SortedContactListBenchmark.test.ts +10 -10
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +1 -1
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +6 -6
- package/test/end-to-end/Layer0Webrtc.test.ts +6 -6
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +1 -1
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +1 -1
- package/test/end-to-end/memory-leak.test.ts +4 -4
- package/test/integration/ConnectionLocking.test.ts +16 -15
- package/test/integration/ConnectionManager.test.ts +62 -6
- package/test/integration/ConnectivityChecking.test.ts +2 -1
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNode.test.ts +4 -4
- package/test/integration/DhtNodeExternalAPI.test.ts +7 -7
- package/test/integration/DhtNodeRpcRemote.test.ts +9 -9
- package/test/integration/DhtRpc.test.ts +12 -13
- package/test/integration/Find.test.ts +5 -5
- package/test/integration/GeoIpConnectivityChecking.test.ts +2 -1
- package/test/integration/Layer1-scale.test.ts +2 -2
- package/test/integration/Mock-Layer1-Layer0.test.ts +6 -6
- package/test/integration/MultipleEntryPointJoining.test.ts +1 -1
- package/test/integration/ReplicateData.test.ts +10 -11
- package/test/integration/RouteMessage.test.ts +9 -9
- package/test/integration/RouterRpcRemote.test.ts +7 -7
- package/test/integration/SimultaneousConnections.test.ts +13 -12
- package/test/integration/Store.test.ts +9 -9
- package/test/integration/StoreAndDelete.test.ts +10 -10
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +9 -9
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +7 -7
- package/test/integration/StoreRpcRemote.test.ts +10 -10
- package/test/integration/WebrtcConnectionManagement.test.ts +4 -3
- package/test/integration/WebrtcConnectorRpc.test.ts +9 -9
- package/test/integration/Websocket.test.ts +0 -2
- package/test/integration/WebsocketClientConnectorRpc.test.ts +8 -8
- package/test/integration/WebsocketConnectionManagement.test.ts +8 -9
- package/test/integration/{rpc-connections-over-webrpc.test.ts → rpc-connections-over-webrtc.test.ts} +4 -3
- package/test/unit/ConnectionManager.test.ts +4 -3
- package/test/unit/ConnectivityHelpers.test.ts +1 -1
- package/test/unit/DiscoverySession.test.ts +6 -6
- package/test/unit/Handshaker.test.ts +1 -1
- package/test/unit/ListeningRpcCommunicator.test.ts +52 -0
- package/test/unit/LocalDataStore.test.ts +21 -21
- package/test/unit/PeerManager.test.ts +13 -13
- package/test/unit/PendingConnection.test.ts +1 -1
- package/test/unit/ProtobufMessage.test.ts +1 -1
- package/test/unit/RandomContactList.test.ts +2 -2
- package/test/unit/RecursiveOperationManager.test.ts +3 -3
- package/test/unit/RecursiveOperationSession.test.ts +4 -4
- package/test/unit/Router.test.ts +6 -6
- package/test/unit/RoutingSession.test.ts +6 -6
- package/test/unit/SortedContactList.test.ts +5 -5
- package/test/unit/StoreManager.test.ts +10 -10
- package/test/unit/StoreRpcLocal.test.ts +9 -9
- package/test/unit/WebrtcConnection.test.ts +29 -0
- package/test/unit/WebsocketClientConnector.test.ts +1 -1
- package/test/unit/WebsocketServerConnector.test.ts +1 -1
- package/test/unit/connectivityRequestHandler.test.ts +1 -1
- package/test/unit/createPeerDescriptor.test.ts +4 -4
- package/test/unit/getClosestNodes.test.ts +5 -5
- package/test/utils/FakeConnectorFacade.ts +1 -1
- package/test/utils/FakeTransport.ts +12 -9
- package/test/utils/customMatchers.ts +3 -3
- package/test/utils/mock/MockConnectionsView.ts +1 -1
- package/test/utils/mock/MockRouter.ts +5 -1
- package/test/utils/mock/MockTransport.ts +6 -1
- package/test/utils/mock/mockDataEntry.ts +6 -6
- package/test/utils/topology.ts +3 -3
- package/test/utils/utils.ts +9 -9
- package/tsconfig.jest.json +2 -1
- package/tsconfig.node.json +1 -0
- package/dist/src/proto/google/protobuf/any.js.map +0 -1
- package/dist/src/proto/google/protobuf/empty.js.map +0 -1
- package/dist/src/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +0 -1
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
- package/dist/src/proto/tests.d.ts +0 -39
- package/dist/src/proto/tests.js +0 -34
- package/dist/src/proto/tests.js.map +0 -1
- package/src/proto/tests.ts +0 -52
- package/test/benchmark/any.test.ts +0 -28
- /package/dist/{src/proto → generated}/google/protobuf/any.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/empty.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/timestamp.js +0 -0
- /package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.js +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.js +0 -0
- /package/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.ts +0 -0
- /package/{src/types/glogal.d.ts → test/types/global.d.ts} +0 -0
|
@@ -3,12 +3,12 @@ import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
|
3
3
|
import { DefaultConnectorFacade, DefaultConnectorFacadeOptions } from '../../src/connection/ConnectorFacade'
|
|
4
4
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
5
5
|
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
6
|
-
import { Message, PeerDescriptor } from '../../
|
|
7
|
-
import { RpcMessage } from '../../
|
|
6
|
+
import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
7
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
8
8
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
9
9
|
import { getRandomRegion } from '../../src/connection/simulator/pings'
|
|
10
10
|
import { MockTransport } from '../utils/mock/MockTransport'
|
|
11
|
-
import {
|
|
11
|
+
import { toNodeId } from '../../src/identifiers'
|
|
12
12
|
|
|
13
13
|
const BASE_MESSAGE: Message = {
|
|
14
14
|
serviceId: 'serviceId',
|
|
@@ -25,7 +25,8 @@ const createConnectionManager = (localPeerDescriptor: PeerDescriptor, opts: Omit
|
|
|
25
25
|
createLocalPeerDescriptor: async () => localPeerDescriptor,
|
|
26
26
|
...opts
|
|
27
27
|
}),
|
|
28
|
-
metricsContext: new MetricsContext()
|
|
28
|
+
metricsContext: new MetricsContext(),
|
|
29
|
+
allowIncomingPrivateConnections: false
|
|
29
30
|
})
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -78,8 +79,8 @@ describe('SimultaneousConnections', () => {
|
|
|
78
79
|
simTransport1.send(msg1),
|
|
79
80
|
simTransport2.send(msg2)
|
|
80
81
|
])
|
|
81
|
-
await waitForCondition(() => simTransport2.hasConnection(
|
|
82
|
-
await waitForCondition(() => simTransport1.hasConnection(
|
|
82
|
+
await waitForCondition(() => simTransport2.hasConnection(toNodeId(peerDescriptor1)))
|
|
83
|
+
await waitForCondition(() => simTransport1.hasConnection(toNodeId(peerDescriptor2)))
|
|
83
84
|
})
|
|
84
85
|
|
|
85
86
|
describe('Websocket 2 servers', () => {
|
|
@@ -159,8 +160,8 @@ describe('SimultaneousConnections', () => {
|
|
|
159
160
|
connectionManager2.send(msg2)
|
|
160
161
|
])
|
|
161
162
|
|
|
162
|
-
await waitForCondition(() => connectionManager1.hasConnection(
|
|
163
|
-
await waitForCondition(() => connectionManager2.hasConnection(
|
|
163
|
+
await waitForCondition(() => connectionManager1.hasConnection(toNodeId(wsPeerDescriptor2)))
|
|
164
|
+
await waitForCondition(() => connectionManager2.hasConnection(toNodeId(wsPeerDescriptor1)))
|
|
164
165
|
})
|
|
165
166
|
})
|
|
166
167
|
|
|
@@ -239,8 +240,8 @@ describe('SimultaneousConnections', () => {
|
|
|
239
240
|
connectionManager2.send(msg2)
|
|
240
241
|
])
|
|
241
242
|
|
|
242
|
-
await waitForCondition(() => connectionManager1.hasConnection(
|
|
243
|
-
await waitForCondition(() => connectionManager2.hasConnection(
|
|
243
|
+
await waitForCondition(() => connectionManager1.hasConnection(toNodeId(wsPeerDescriptor2)))
|
|
244
|
+
await waitForCondition(() => connectionManager2.hasConnection(toNodeId(wsPeerDescriptor1)))
|
|
244
245
|
})
|
|
245
246
|
})
|
|
246
247
|
|
|
@@ -307,8 +308,8 @@ describe('SimultaneousConnections', () => {
|
|
|
307
308
|
connectionManager2.send(msg2)
|
|
308
309
|
])
|
|
309
310
|
|
|
310
|
-
await waitForCondition(() => connectionManager1.hasConnection(
|
|
311
|
-
await waitForCondition(() => connectionManager2.hasConnection(
|
|
311
|
+
await waitForCondition(() => connectionManager1.hasConnection(toNodeId(wrtcPeerDescriptor2)))
|
|
312
|
+
await waitForCondition(() => connectionManager2.hasConnection(toNodeId(wrtcPeerDescriptor1)))
|
|
312
313
|
})
|
|
313
314
|
})
|
|
314
315
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import {
|
|
4
|
-
import { PeerDescriptor } from '../../
|
|
3
|
+
import { toDhtAddress, toNodeId } from '../../src/identifiers'
|
|
4
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
6
6
|
import { createMockConnectionDhtNode, createMockPeerDescriptor, waitForStableTopology } from '../utils/utils'
|
|
7
7
|
|
|
@@ -44,7 +44,7 @@ describe('Storing data in DHT', () => {
|
|
|
44
44
|
const storingNodeIndex = 34
|
|
45
45
|
const entry = createMockDataEntry()
|
|
46
46
|
const successfulStorers = await nodes[storingNodeIndex].storeDataToDht(
|
|
47
|
-
|
|
47
|
+
toDhtAddress(entry.key),
|
|
48
48
|
entry.data!
|
|
49
49
|
)
|
|
50
50
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
@@ -54,12 +54,12 @@ describe('Storing data in DHT', () => {
|
|
|
54
54
|
const storingNode = getRandomNode()
|
|
55
55
|
const entry = createMockDataEntry()
|
|
56
56
|
const successfulStorers = await storingNode.storeDataToDht(
|
|
57
|
-
|
|
57
|
+
toDhtAddress(entry.key),
|
|
58
58
|
entry.data!
|
|
59
59
|
)
|
|
60
60
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
61
61
|
const fetchingNode = getRandomNode()
|
|
62
|
-
const results = await fetchingNode.fetchDataFromDht(
|
|
62
|
+
const results = await fetchingNode.fetchDataFromDht(toDhtAddress(entry.key))
|
|
63
63
|
results.forEach((result) => {
|
|
64
64
|
expectEqualData(result, entry)
|
|
65
65
|
})
|
|
@@ -70,16 +70,16 @@ describe('Storing data in DHT', () => {
|
|
|
70
70
|
const entry = createMockDataEntry()
|
|
71
71
|
const requestor = createMockPeerDescriptor()
|
|
72
72
|
const successfulStorers = await storingNode.storeDataToDht(
|
|
73
|
-
|
|
73
|
+
toDhtAddress(entry.key),
|
|
74
74
|
entry.data!,
|
|
75
|
-
|
|
75
|
+
toDhtAddress(requestor.nodeId)
|
|
76
76
|
)
|
|
77
77
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
78
78
|
const fetchingNode = getRandomNode()
|
|
79
|
-
const results = await fetchingNode.fetchDataFromDht(
|
|
79
|
+
const results = await fetchingNode.fetchDataFromDht(toDhtAddress(entry.key))
|
|
80
80
|
results.forEach((result) => {
|
|
81
81
|
expectEqualData(result, entry)
|
|
82
|
-
expect(
|
|
82
|
+
expect(toDhtAddress(result.creator)).toEqual(toNodeId(requestor))
|
|
83
83
|
})
|
|
84
84
|
}, 30000)
|
|
85
85
|
})
|
|
@@ -2,7 +2,7 @@ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator
|
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { createMockConnectionDhtNode, waitForStableTopology } from '../utils/utils'
|
|
4
4
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
5
|
-
import {
|
|
5
|
+
import { randomDhtAddress, toDhtAddress } from '../../src/identifiers'
|
|
6
6
|
import { wait } from '@streamr/utils'
|
|
7
7
|
|
|
8
8
|
const NUM_NODES = 5
|
|
@@ -21,7 +21,7 @@ describe('Storing data in DHT', () => {
|
|
|
21
21
|
beforeEach(async () => {
|
|
22
22
|
nodes = []
|
|
23
23
|
const entryPoint = await createMockConnectionDhtNode(simulator,
|
|
24
|
-
|
|
24
|
+
randomDhtAddress(), K, MAX_CONNECTIONS)
|
|
25
25
|
nodes.push(entryPoint)
|
|
26
26
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
27
27
|
const node = await createMockConnectionDhtNode(simulator,
|
|
@@ -39,13 +39,13 @@ describe('Storing data in DHT', () => {
|
|
|
39
39
|
it('Data can be deleted', async () => {
|
|
40
40
|
const storingNode = getRandomNode()
|
|
41
41
|
const entry = createMockDataEntry()
|
|
42
|
-
const successfulStorers = await storingNode.storeDataToDht(
|
|
42
|
+
const successfulStorers = await storingNode.storeDataToDht(toDhtAddress(entry.key), entry.data!)
|
|
43
43
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
44
|
-
await storingNode.deleteDataFromDht(
|
|
44
|
+
await storingNode.deleteDataFromDht(toDhtAddress(entry.key), true)
|
|
45
45
|
// Wait for the delete operation to propagate
|
|
46
46
|
await wait(500)
|
|
47
47
|
const fetchingNode = getRandomNode()
|
|
48
|
-
const results = await fetchingNode.fetchDataFromDht(
|
|
48
|
+
const results = await fetchingNode.fetchDataFromDht(toDhtAddress(entry.key))
|
|
49
49
|
results.forEach((result) => {
|
|
50
50
|
expect(result.deleted).toBeTrue()
|
|
51
51
|
expectEqualData(result, entry)
|
|
@@ -55,20 +55,20 @@ describe('Storing data in DHT', () => {
|
|
|
55
55
|
it('Data can be deleted and re-stored', async () => {
|
|
56
56
|
const storingNode = getRandomNode()
|
|
57
57
|
const entry = createMockDataEntry()
|
|
58
|
-
const successfulStorers1 = await storingNode.storeDataToDht(
|
|
58
|
+
const successfulStorers1 = await storingNode.storeDataToDht(toDhtAddress(entry.key), entry.data!)
|
|
59
59
|
expect(successfulStorers1.length).toBeGreaterThan(4)
|
|
60
|
-
await storingNode.deleteDataFromDht(
|
|
60
|
+
await storingNode.deleteDataFromDht(toDhtAddress(entry.key), true)
|
|
61
61
|
// Wait for the delete operation to propagate
|
|
62
62
|
await wait(500)
|
|
63
63
|
const fetchingNode = getRandomNode()
|
|
64
|
-
const results1 = await fetchingNode.fetchDataFromDht(
|
|
64
|
+
const results1 = await fetchingNode.fetchDataFromDht(toDhtAddress(entry.key))
|
|
65
65
|
results1.forEach((result) => {
|
|
66
66
|
expect(result.deleted).toBeTrue()
|
|
67
67
|
expectEqualData(result, entry)
|
|
68
68
|
})
|
|
69
|
-
const successfulStorers2 = await storingNode.storeDataToDht(
|
|
69
|
+
const successfulStorers2 = await storingNode.storeDataToDht(toDhtAddress(entry.key), entry.data!)
|
|
70
70
|
expect(successfulStorers2.length).toBeGreaterThan(4)
|
|
71
|
-
const results2 = await fetchingNode.fetchDataFromDht(
|
|
71
|
+
const results2 = await fetchingNode.fetchDataFromDht(toDhtAddress(entry.key))
|
|
72
72
|
results2.forEach((result) => {
|
|
73
73
|
expect(result.deleted).toBeFalse()
|
|
74
74
|
expectEqualData(result, entry)
|
|
@@ -2,7 +2,7 @@ import { createMockConnectionDhtNode } from '../utils/utils'
|
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
4
4
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
5
|
-
import {
|
|
5
|
+
import { toDhtAddress } from '../../src/identifiers'
|
|
6
6
|
|
|
7
7
|
describe('Storing data in DHT with two peers', () => {
|
|
8
8
|
|
|
@@ -41,15 +41,15 @@ describe('Storing data in DHT with two peers', () => {
|
|
|
41
41
|
const storedData1 = createMockDataEntry()
|
|
42
42
|
const storedData2 = createMockDataEntry()
|
|
43
43
|
// Here we effectively test that fetching "null" data doesn't take too long. A test timeout here indicates an issue.
|
|
44
|
-
await node1.fetchDataFromDht(
|
|
45
|
-
await node2.fetchDataFromDht(
|
|
44
|
+
await node1.fetchDataFromDht(toDhtAddress(storedData1.key))
|
|
45
|
+
await node2.fetchDataFromDht(toDhtAddress(storedData1.key))
|
|
46
46
|
|
|
47
|
-
await node1.storeDataToDht(
|
|
48
|
-
await node2.storeDataToDht(
|
|
49
|
-
await entryPoint.storeDataToDht(
|
|
50
|
-
const foundData1 = await node1.fetchDataFromDht(
|
|
51
|
-
const foundData2 = await node2.fetchDataFromDht(
|
|
52
|
-
const foundData3 = await entryPoint.fetchDataFromDht(
|
|
47
|
+
await node1.storeDataToDht(toDhtAddress(storedData1.key), storedData1.data!)
|
|
48
|
+
await node2.storeDataToDht(toDhtAddress(storedData1.key), storedData1.data!)
|
|
49
|
+
await entryPoint.storeDataToDht(toDhtAddress(storedData2.key), storedData2.data!)
|
|
50
|
+
const foundData1 = await node1.fetchDataFromDht(toDhtAddress(storedData1.key))
|
|
51
|
+
const foundData2 = await node2.fetchDataFromDht(toDhtAddress(storedData1.key))
|
|
52
|
+
const foundData3 = await entryPoint.fetchDataFromDht(toDhtAddress(storedData2.key))
|
|
53
53
|
expectEqualData(foundData1[0], storedData1)
|
|
54
54
|
expectEqualData(foundData1[1], storedData1)
|
|
55
55
|
expectEqualData(foundData2[0], storedData1)
|
|
@@ -3,7 +3,7 @@ import { DhtNode } from '../../src/dht/DhtNode'
|
|
|
3
3
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
4
4
|
import { waitForCondition } from '@streamr/utils'
|
|
5
5
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
6
|
-
import {
|
|
6
|
+
import { toDhtAddress } from '../../src/identifiers'
|
|
7
7
|
|
|
8
8
|
describe('Storing data in DHT with two peers', () => {
|
|
9
9
|
|
|
@@ -32,10 +32,10 @@ describe('Storing data in DHT with two peers', () => {
|
|
|
32
32
|
it('Node can store on two peer DHT', async () => {
|
|
33
33
|
const storedData1 = createMockDataEntry()
|
|
34
34
|
const storedData2 = createMockDataEntry()
|
|
35
|
-
await otherNode.storeDataToDht(
|
|
36
|
-
await entryPoint.storeDataToDht(
|
|
37
|
-
const foundData1 = await otherNode.fetchDataFromDht(
|
|
38
|
-
const foundData2 = await entryPoint.fetchDataFromDht(
|
|
35
|
+
await otherNode.storeDataToDht(toDhtAddress(storedData1.key), storedData1.data!)
|
|
36
|
+
await entryPoint.storeDataToDht(toDhtAddress(storedData2.key), storedData2.data!)
|
|
37
|
+
const foundData1 = await otherNode.fetchDataFromDht(toDhtAddress(storedData1.key))
|
|
38
|
+
const foundData2 = await entryPoint.fetchDataFromDht(toDhtAddress(storedData2.key))
|
|
39
39
|
expectEqualData(foundData1[0], storedData1)
|
|
40
40
|
expectEqualData(foundData2[0], storedData2)
|
|
41
41
|
})
|
|
@@ -44,8 +44,8 @@ describe('Storing data in DHT with two peers', () => {
|
|
|
44
44
|
await otherNode.stop()
|
|
45
45
|
await waitForCondition(() => entryPoint.getNeighborCount() === 0)
|
|
46
46
|
const storedData = createMockDataEntry()
|
|
47
|
-
await entryPoint.storeDataToDht(
|
|
48
|
-
const foundData = await entryPoint.fetchDataFromDht(
|
|
47
|
+
await entryPoint.storeDataToDht(toDhtAddress(storedData.key), storedData.data!)
|
|
48
|
+
const foundData = await entryPoint.fetchDataFromDht(toDhtAddress(storedData.key))
|
|
49
49
|
expectEqualData(foundData[0], storedData)
|
|
50
50
|
}, 60000)
|
|
51
51
|
})
|
|
@@ -2,14 +2,14 @@ import { RpcCommunicator } from '@streamr/proto-rpc'
|
|
|
2
2
|
import {
|
|
3
3
|
StoreDataRequest,
|
|
4
4
|
StoreDataResponse
|
|
5
|
-
} from '../../
|
|
5
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
6
6
|
import { createMockPeerDescriptor, mockStoreRpc } from '../utils/utils'
|
|
7
|
-
import { RpcMessage } from '../../
|
|
8
|
-
import { StoreRpcClient } from '../../
|
|
7
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
8
|
+
import { StoreRpcClient } from '../../generated/packages/dht/protos/DhtRpc.client'
|
|
9
9
|
import { StoreRpcRemote } from '../../src/dht/store/StoreRpcRemote'
|
|
10
10
|
import { createMockDataEntry } from '../utils/mock/mockDataEntry'
|
|
11
11
|
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
12
|
-
import {
|
|
12
|
+
import { randomDhtAddress, toNodeId, toDhtAddressRaw } from '../../src/identifiers'
|
|
13
13
|
|
|
14
14
|
describe('StoreRpcRemote', () => {
|
|
15
15
|
|
|
@@ -22,7 +22,7 @@ describe('StoreRpcRemote', () => {
|
|
|
22
22
|
const request: StoreDataRequest = {
|
|
23
23
|
key: data.key,
|
|
24
24
|
data: data.data,
|
|
25
|
-
creator:
|
|
25
|
+
creator: toDhtAddressRaw(randomDhtAddress()),
|
|
26
26
|
ttl: 10
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -30,11 +30,11 @@ describe('StoreRpcRemote', () => {
|
|
|
30
30
|
clientRpcCommunicator = new RpcCommunicator()
|
|
31
31
|
serverRpcCommunicator = new RpcCommunicator()
|
|
32
32
|
serverRpcCommunicator.registerRpcMethod(StoreDataRequest, StoreDataResponse, 'storeData', mockStoreRpc.storeData)
|
|
33
|
-
clientRpcCommunicator.
|
|
34
|
-
serverRpcCommunicator.handleIncomingMessage(message)
|
|
33
|
+
clientRpcCommunicator.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
34
|
+
serverRpcCommunicator.handleIncomingMessage(message, new DhtCallContext())
|
|
35
35
|
})
|
|
36
|
-
serverRpcCommunicator.
|
|
37
|
-
clientRpcCommunicator.handleIncomingMessage(message)
|
|
36
|
+
serverRpcCommunicator.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
37
|
+
clientRpcCommunicator.handleIncomingMessage(message, new DhtCallContext())
|
|
38
38
|
})
|
|
39
39
|
rpcRemote = new StoreRpcRemote(clientPeerDescriptor, serverPeerDescriptor, clientRpcCommunicator, StoreRpcClient)
|
|
40
40
|
})
|
|
@@ -47,7 +47,7 @@ describe('StoreRpcRemote', () => {
|
|
|
47
47
|
serverRpcCommunicator.registerRpcMethod(StoreDataRequest, StoreDataResponse, 'storeData', mockStoreRpc.throwStoreDataError)
|
|
48
48
|
await expect(rpcRemote.storeData(request)).rejects.toThrowError(
|
|
49
49
|
'Could not store data to'
|
|
50
|
-
+ ` ${
|
|
50
|
+
+ ` ${toNodeId(serverPeerDescriptor)} from ${toNodeId(clientPeerDescriptor)}`
|
|
51
51
|
+ ' Error: Mock'
|
|
52
52
|
)
|
|
53
53
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
2
2
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
3
|
-
import { Message, NodeType, PeerDescriptor } from '../../
|
|
4
|
-
import { RpcMessage } from '../../
|
|
3
|
+
import { Message, NodeType, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
5
5
|
import { ITransport } from '../../src/transport/ITransport'
|
|
6
6
|
import * as Err from '../../src/helpers/errors'
|
|
7
7
|
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
@@ -15,7 +15,8 @@ const createConnectionManager = (localPeerDescriptor: PeerDescriptor, transport:
|
|
|
15
15
|
transport,
|
|
16
16
|
createLocalPeerDescriptor: async () => localPeerDescriptor
|
|
17
17
|
}),
|
|
18
|
-
metricsContext: new MetricsContext()
|
|
18
|
+
metricsContext: new MetricsContext(),
|
|
19
|
+
allowIncomingPrivateConnections: false
|
|
19
20
|
})
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ProtoRpcClient, RpcCommunicator, toProtoRpcClient } from '@streamr/proto-rpc'
|
|
2
|
-
import { WebrtcConnectorRpcClient } from '../../
|
|
2
|
+
import { WebrtcConnectorRpcClient } from '../../generated/packages/dht/protos/DhtRpc.client'
|
|
3
3
|
import {
|
|
4
4
|
IceCandidate,
|
|
5
5
|
RtcAnswer,
|
|
6
6
|
RtcOffer,
|
|
7
7
|
WebrtcConnectionRequest
|
|
8
|
-
} from '../../
|
|
9
|
-
import { Empty } from '../../
|
|
8
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
9
|
+
import { Empty } from '../../generated/google/protobuf/empty'
|
|
10
10
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
11
|
-
import { IWebrtcConnectorRpc } from '../../
|
|
11
|
+
import { IWebrtcConnectorRpc } from '../../generated/packages/dht/protos/DhtRpc.server'
|
|
12
12
|
import { waitForCondition } from '@streamr/utils'
|
|
13
|
-
import { RpcMessage } from '../../
|
|
13
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
14
14
|
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
15
15
|
|
|
16
16
|
describe('WebRTC rpc messages', () => {
|
|
@@ -64,12 +64,12 @@ describe('WebRTC rpc messages', () => {
|
|
|
64
64
|
rpcCommunicator2.registerRpcNotification(IceCandidate, 'iceCandidate', serverFunctions.iceCandidate)
|
|
65
65
|
rpcCommunicator2.registerRpcNotification(WebrtcConnectionRequest, 'requestConnection', serverFunctions.requestConnection)
|
|
66
66
|
|
|
67
|
-
rpcCommunicator1.
|
|
68
|
-
rpcCommunicator2.handleIncomingMessage(message)
|
|
67
|
+
rpcCommunicator1.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
68
|
+
rpcCommunicator2.handleIncomingMessage(message, new DhtCallContext())
|
|
69
69
|
})
|
|
70
70
|
|
|
71
|
-
rpcCommunicator2.
|
|
72
|
-
rpcCommunicator1.handleIncomingMessage(message)
|
|
71
|
+
rpcCommunicator2.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
72
|
+
rpcCommunicator1.handleIncomingMessage(message, new DhtCallContext())
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
client = toProtoRpcClient(new WebrtcConnectorRpcClient(rpcCommunicator1.getRpcClientTransport()))
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
1
|
import { WebsocketServer } from '../../src/connection/websocket/WebsocketServer'
|
|
4
2
|
import { IConnection } from '../../src/connection/IConnection'
|
|
5
3
|
import { WebsocketClientConnection } from '../../src/connection/websocket/NodeWebsocketClientConnection'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ProtoRpcClient, RpcCommunicator, toProtoRpcClient } from '@streamr/proto-rpc'
|
|
2
|
-
import { WebsocketClientConnectorRpcClient } from '../../
|
|
2
|
+
import { WebsocketClientConnectorRpcClient } from '../../generated/packages/dht/protos/DhtRpc.client'
|
|
3
3
|
import { createMockPeerDescriptor, mockWebsocketClientConnectorRpc } from '../utils/utils'
|
|
4
|
-
import { WebsocketConnectionRequest } from '../../
|
|
5
|
-
import { RpcMessage } from '../../
|
|
6
|
-
import { Empty } from '../../
|
|
4
|
+
import { WebsocketConnectionRequest } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
6
|
+
import { Empty } from '../../generated/google/protobuf/empty'
|
|
7
7
|
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
8
8
|
|
|
9
9
|
describe('WebsocketClientConnectorRpc', () => {
|
|
@@ -32,12 +32,12 @@ describe('WebsocketClientConnectorRpc', () => {
|
|
|
32
32
|
mockWebsocketClientConnectorRpc.requestConnection
|
|
33
33
|
)
|
|
34
34
|
|
|
35
|
-
rpcCommunicator1.
|
|
36
|
-
rpcCommunicator2.handleIncomingMessage(message)
|
|
35
|
+
rpcCommunicator1.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
36
|
+
rpcCommunicator2.handleIncomingMessage(message, new DhtCallContext())
|
|
37
37
|
})
|
|
38
38
|
|
|
39
|
-
rpcCommunicator2.
|
|
40
|
-
rpcCommunicator1.handleIncomingMessage(message)
|
|
39
|
+
rpcCommunicator2.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
40
|
+
rpcCommunicator1.handleIncomingMessage(message, new DhtCallContext())
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
client1 = toProtoRpcClient(new WebsocketClientConnectorRpcClient(rpcCommunicator1.getRpcClientTransport()))
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
/* eslint-disable promise/no-nesting */
|
|
2
|
-
|
|
3
1
|
import { MetricsContext, waitForCondition, waitForEvent3 } from '@streamr/utils'
|
|
4
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
5
3
|
import { DefaultConnectorFacade, DefaultConnectorFacadeOptions } from '../../src/connection/ConnectorFacade'
|
|
6
4
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
7
5
|
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
8
6
|
import * as Err from '../../src/helpers/errors'
|
|
9
|
-
import { Message, NodeType, PeerDescriptor } from '../../
|
|
10
|
-
import { RpcMessage } from '../../
|
|
7
|
+
import { Message, NodeType, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
8
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
11
9
|
import { TransportEvents } from '../../src/transport/ITransport'
|
|
12
|
-
import {
|
|
10
|
+
import { toNodeId } from '../../src/identifiers'
|
|
13
11
|
|
|
14
12
|
const SERVICE_ID = 'test'
|
|
15
13
|
|
|
@@ -19,7 +17,8 @@ const createOptions = (localPeerDescriptor: PeerDescriptor, opts: Omit<DefaultCo
|
|
|
19
17
|
createLocalPeerDescriptor: async () => localPeerDescriptor,
|
|
20
18
|
...opts
|
|
21
19
|
}),
|
|
22
|
-
metricsContext: new MetricsContext()
|
|
20
|
+
metricsContext: new MetricsContext(),
|
|
21
|
+
allowIncomingPrivateConnections: false
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
|
|
@@ -145,7 +144,7 @@ describe('Websocket Connection Management', () => {
|
|
|
145
144
|
waitForEvent3<TransportEvents>(wsServerManager, 'disconnected', 15000),
|
|
146
145
|
wsServerManager.send(dummyMessage)
|
|
147
146
|
])
|
|
148
|
-
expect(wsServerManager.hasConnection(
|
|
147
|
+
expect(wsServerManager.hasConnection(toNodeId(dummyMessage.targetDescriptor!))).toBeFalse()
|
|
149
148
|
}, 20000)
|
|
150
149
|
|
|
151
150
|
it('Can open connections to peer with server', async () => {
|
|
@@ -161,12 +160,12 @@ describe('Websocket Connection Management', () => {
|
|
|
161
160
|
await noWsServerManager.send(dummyMessage)
|
|
162
161
|
await waitForCondition(
|
|
163
162
|
() => {
|
|
164
|
-
const nodeId =
|
|
163
|
+
const nodeId = toNodeId(noWsServerConnectorPeerDescriptor)
|
|
165
164
|
return wsServerManager.hasConnection(nodeId)
|
|
166
165
|
}
|
|
167
166
|
)
|
|
168
167
|
await waitForCondition(
|
|
169
|
-
() => noWsServerManager.hasConnection(
|
|
168
|
+
() => noWsServerManager.hasConnection(toNodeId(wsServerConnectorPeerDescriptor))
|
|
170
169
|
)
|
|
171
170
|
})
|
|
172
171
|
|
package/test/integration/{rpc-connections-over-webrpc.test.ts → rpc-connections-over-webrtc.test.ts}
RENAMED
|
@@ -6,8 +6,8 @@ import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTran
|
|
|
6
6
|
import { DhtRpcOptions } from '../../src/rpc-protocol/DhtRpcOptions'
|
|
7
7
|
import { ListeningRpcCommunicator } from '../../src/transport/ListeningRpcCommunicator'
|
|
8
8
|
import { ProtoRpcClient, toProtoRpcClient } from '@streamr/proto-rpc'
|
|
9
|
-
import { DhtNodeRpcClient } from '../../
|
|
10
|
-
import { PeerDescriptor, PingRequest, PingResponse } from '../../
|
|
9
|
+
import { DhtNodeRpcClient } from '../../generated/packages/dht/protos/DhtRpc.client'
|
|
10
|
+
import { PeerDescriptor, PingRequest, PingResponse } from '../../generated/packages/dht/protos/DhtRpc'
|
|
11
11
|
import { DefaultConnectorFacade } from '../../src/connection/ConnectorFacade'
|
|
12
12
|
import { MetricsContext } from '@streamr/utils'
|
|
13
13
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
@@ -20,7 +20,8 @@ const createConnectionManager = (localPeerDescriptor: PeerDescriptor, transport:
|
|
|
20
20
|
transport,
|
|
21
21
|
createLocalPeerDescriptor: async () => localPeerDescriptor
|
|
22
22
|
}),
|
|
23
|
-
metricsContext: new MetricsContext()
|
|
23
|
+
metricsContext: new MetricsContext(),
|
|
24
|
+
allowIncomingPrivateConnections: false
|
|
24
25
|
})
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MetricsContext } from '@streamr/utils'
|
|
2
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
3
|
-
import {
|
|
3
|
+
import { toNodeId, PendingConnection } from '../../src/exports'
|
|
4
4
|
import { FakeConnectorFacade } from '../utils/FakeConnectorFacade'
|
|
5
5
|
import { MockConnection } from '../utils/mock/MockConnection'
|
|
6
6
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
@@ -15,6 +15,7 @@ describe('ConnetionManager', () => {
|
|
|
15
15
|
beforeEach(async () => {
|
|
16
16
|
connectionManager = new ConnectionManager({
|
|
17
17
|
metricsContext: new MetricsContext(),
|
|
18
|
+
allowIncomingPrivateConnections: false,
|
|
18
19
|
createConnectorFacade: () => {
|
|
19
20
|
fakeConnectorFacade = new FakeConnectorFacade(localPeerDescriptor)
|
|
20
21
|
return fakeConnectorFacade
|
|
@@ -30,7 +31,7 @@ describe('ConnetionManager', () => {
|
|
|
30
31
|
it('should replace a duplicate connecting connection', () => {
|
|
31
32
|
const remotePeerDescriptor = createMockPeerDescriptor()
|
|
32
33
|
const pendingConnection1 = new PendingConnection(remotePeerDescriptor)
|
|
33
|
-
const offerer = getOfferer(
|
|
34
|
+
const offerer = getOfferer(toNodeId(localPeerDescriptor), toNodeId(remotePeerDescriptor))
|
|
34
35
|
const accepted1 = fakeConnectorFacade.callOnNewConnection(pendingConnection1)
|
|
35
36
|
expect(accepted1).toBeTrue()
|
|
36
37
|
const pendingConnection2 = new PendingConnection(remotePeerDescriptor)
|
|
@@ -45,7 +46,7 @@ describe('ConnetionManager', () => {
|
|
|
45
46
|
it('should replace a duplicate connected connection', () => {
|
|
46
47
|
const remotePeerDescriptor = createMockPeerDescriptor()
|
|
47
48
|
const pendingConnection1 = new PendingConnection(remotePeerDescriptor)
|
|
48
|
-
const offerer = getOfferer(
|
|
49
|
+
const offerer = getOfferer(toNodeId(localPeerDescriptor), toNodeId(remotePeerDescriptor))
|
|
49
50
|
const accepted1 = fakeConnectorFacade.callOnNewConnection(pendingConnection1)
|
|
50
51
|
expect(accepted1).toBeTrue()
|
|
51
52
|
pendingConnection1.onHandshakeCompleted(new MockConnection())
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeType } from '../../
|
|
1
|
+
import { NodeType } from '../../generated/packages/dht/protos/DhtRpc'
|
|
2
2
|
import { expectedConnectionType } from '../../src/helpers/Connectivity'
|
|
3
3
|
import { ConnectionType } from '../../src/connection/IConnection'
|
|
4
4
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
@@ -3,8 +3,8 @@ import { sampleSize } from 'lodash'
|
|
|
3
3
|
import { DhtNodeRpcRemote } from '../../src/dht/DhtNodeRpcRemote'
|
|
4
4
|
import { PeerManager, getDistance } from '../../src/dht/PeerManager'
|
|
5
5
|
import { DiscoverySession } from '../../src/dht/discovery/DiscoverySession'
|
|
6
|
-
import { DhtAddress,
|
|
7
|
-
import { NodeType, PeerDescriptor } from '../../
|
|
6
|
+
import { DhtAddress, toNodeId, toDhtAddressRaw } from '../../src/identifiers'
|
|
7
|
+
import { NodeType, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
8
8
|
import { createTestTopology } from '../utils/topology'
|
|
9
9
|
import { getClosestNodes } from '../../src/dht/contact/getClosestNodes'
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ const QUERY_BATCH_SIZE = 5 // the default value in DhtNode's options, not relev
|
|
|
16
16
|
|
|
17
17
|
const createPeerDescriptor = (nodeId: DhtAddress): PeerDescriptor => {
|
|
18
18
|
return {
|
|
19
|
-
nodeId:
|
|
19
|
+
nodeId: toDhtAddressRaw(nodeId),
|
|
20
20
|
type: NodeType.NODEJS
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -45,9 +45,9 @@ describe('DiscoverySession', () => {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const createMockRpcRemote = (peerDescriptor: PeerDescriptor): Partial<DhtNodeRpcRemote> => {
|
|
48
|
-
const nodeId =
|
|
48
|
+
const nodeId = toNodeId(peerDescriptor)
|
|
49
49
|
return {
|
|
50
|
-
id:
|
|
50
|
+
id: toDhtAddressRaw(nodeId),
|
|
51
51
|
getPeerDescriptor: () => peerDescriptor,
|
|
52
52
|
getNodeId: () => nodeId,
|
|
53
53
|
getClosestPeers: async (referenceId: DhtAddress) => {
|
|
@@ -79,7 +79,7 @@ describe('DiscoverySession', () => {
|
|
|
79
79
|
// Each queried node should closer to the target than the previous queried node, because we
|
|
80
80
|
// use parallelism=1 and noProgressLimit=1
|
|
81
81
|
const distancesToTarget = queriedNodes
|
|
82
|
-
.map((nodeId) => getDistance(
|
|
82
|
+
.map((nodeId) => getDistance(toDhtAddressRaw(nodeId), toDhtAddressRaw(targetId)))
|
|
83
83
|
for (let i = 1; i < distancesToTarget.length ; i++) {
|
|
84
84
|
expect(distancesToTarget[i]).toBeLessThan(distancesToTarget[i - 1])
|
|
85
85
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '../../src/connection/Handshaker'
|
|
11
11
|
import { ConnectionEvents, IConnection } from '../../src/connection/IConnection'
|
|
12
12
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
13
|
-
import { HandshakeError, Message } from '../../
|
|
13
|
+
import { HandshakeError, Message } from '../../generated/packages/dht/protos/DhtRpc'
|
|
14
14
|
import { PendingConnection } from '../../src/connection/PendingConnection'
|
|
15
15
|
|
|
16
16
|
describe('Handshaker', () => {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { waitForCondition } from '@streamr/utils'
|
|
2
|
+
import { ListeningRpcCommunicator } from '../../src/transport/ListeningRpcCommunicator'
|
|
3
|
+
import { MockTransport } from '../utils/mock/MockTransport'
|
|
4
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
5
|
+
import { RpcMessage } from '@streamr/proto-rpc'
|
|
6
|
+
import { Deferred, RpcMetadata, RpcStatus } from '@protobuf-ts/runtime-rpc'
|
|
7
|
+
|
|
8
|
+
const createDeferredPromises = () => {
|
|
9
|
+
|
|
10
|
+
const defHeader = new Deferred<RpcMetadata>()
|
|
11
|
+
const defMessage = new Deferred<any>()
|
|
12
|
+
const defStatus = new Deferred<RpcStatus>()
|
|
13
|
+
const defTrailer = new Deferred<RpcMetadata>()
|
|
14
|
+
|
|
15
|
+
const deferredParser = () => {}
|
|
16
|
+
return {
|
|
17
|
+
message: defMessage,
|
|
18
|
+
header: defHeader,
|
|
19
|
+
trailer: defTrailer,
|
|
20
|
+
status: defStatus,
|
|
21
|
+
messageParser: deferredParser as any
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('ListeningRpcCommunicator', () => {
|
|
26
|
+
const SERVICE_ID = 'test'
|
|
27
|
+
let rpcCommunicator: ListeningRpcCommunicator
|
|
28
|
+
let transport: MockTransport
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
transport = new MockTransport()
|
|
32
|
+
rpcCommunicator = new ListeningRpcCommunicator(SERVICE_ID, transport)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
rpcCommunicator.destroy()
|
|
37
|
+
transport.stop()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('rejects requests on disconnect event to the target', async () => {
|
|
41
|
+
const peerDescriptor = createMockPeerDescriptor()
|
|
42
|
+
rpcCommunicator.getRpcClientTransport().emit(
|
|
43
|
+
'rpcRequest',
|
|
44
|
+
RpcMessage.create(),
|
|
45
|
+
{ targetDescriptor: peerDescriptor }, createDeferredPromises()
|
|
46
|
+
)
|
|
47
|
+
await waitForCondition(() => rpcCommunicator.getRequestIds(() => true).length > 0)
|
|
48
|
+
transport.emit('disconnected', peerDescriptor, false)
|
|
49
|
+
await waitForCondition(() => rpcCommunicator.getRequestIds(() => true).length === 0)
|
|
50
|
+
}, 10000)
|
|
51
|
+
|
|
52
|
+
})
|