@streamr/dht 101.1.2 → 102.0.0-beta.1
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/package.json +17 -18
- 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 +96 -32
- 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 +2 -2
- package/dist/src/connection/Handshaker.js +11 -7
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +7 -1
- package/dist/src/connection/ManagedConnection.js +41 -8
- 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 +22 -11
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +4 -4
- 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 +5 -4
- 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/simulator/pings.d.ts +1 -1
- package/dist/src/connection/simulator/pings.js +3 -3
- package/dist/src/connection/simulator/pings.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +13 -8
- 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 +28 -17
- 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/webrtc/iceServerAsString.js +1 -2
- package/dist/src/connection/webrtc/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +0 -1
- 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 -4
- 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/WebsocketServerConnection.d.ts +0 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.js +34 -24
- package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +5 -2
- package/dist/src/dht/DhtNode.js +20 -8
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +4 -4
- 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 +3 -2
- package/dist/src/dht/PeerManager.js +12 -11
- 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 +2 -2
- 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 -2
- 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 -2
- 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.d.ts +0 -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 +3 -3
- 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/DuplicateDetector.js.map +1 -1
- 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 +7 -8
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/RoutingTablesCache.d.ts +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 +3 -3
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +3 -3
- 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 +4 -4
- 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/AddressTools.js +2 -3
- package/dist/src/helpers/AddressTools.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/debugHelpers.js +2 -2
- package/dist/src/helpers/debugHelpers.js.map +1 -1
- package/dist/src/helpers/protoClasses.d.ts +1 -1
- package/dist/src/helpers/protoClasses.js +1 -1
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/helpers/protoToString.js +1 -2
- package/dist/src/helpers/protoToString.js.map +1 -1
- package/dist/src/helpers/version.d.ts +1 -1
- package/dist/src/helpers/version.js +4 -4
- package/dist/src/helpers/version.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/eslint.config.mjs +12 -0
- package/jest.config.ts +12 -0
- package/package.json +17 -18
- package/proto.sh +2 -3
- package/protos/DhtRpc.proto +11 -4
- 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 +93 -27
- package/src/connection/ConnectionsView.ts +1 -1
- package/src/connection/ConnectorFacade.ts +1 -1
- package/src/connection/Handshaker.ts +18 -14
- package/src/connection/ManagedConnection.ts +28 -3
- package/src/connection/PendingConnection.ts +1 -1
- package/src/connection/connectivityChecker.ts +6 -5
- package/src/connection/connectivityRequestHandler.ts +4 -4
- package/src/connection/simulator/Simulator.ts +8 -7
- 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/simulator/pings.ts +1 -1
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +10 -1
- package/src/connection/webrtc/NodeWebrtcConnection.ts +15 -11
- package/src/connection/webrtc/WebrtcConnector.ts +13 -11
- 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 +24 -20
- package/src/dht/DhtNode.ts +29 -11
- package/src/dht/DhtNodeRpcLocal.ts +8 -8
- 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 +16 -14
- 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 +3 -3
- 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 +10 -10
- 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/DuplicateDetector.ts +1 -1
- 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 +9 -10
- package/src/dht/routing/RoutingTablesCache.ts +1 -1
- package/src/dht/routing/getPreviousPeer.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +5 -5
- package/src/dht/store/StoreManager.ts +13 -13
- package/src/dht/store/StoreRpcLocal.ts +9 -9
- 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 +2 -2
- package/src/helpers/version.ts +2 -2
- 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 +9 -9
- package/test/benchmark/KademliaCorrectness.test.ts +7 -7
- package/test/benchmark/RingCorrectness.test.ts +8 -8
- package/test/benchmark/SortedContactListBenchmark.test.ts +10 -10
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +3 -3
- 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 +3 -3
- package/test/end-to-end/memory-leak.test.ts +6 -6
- package/test/integration/ConnectionLocking.test.ts +48 -37
- package/test/integration/ConnectionManager.test.ts +62 -6
- package/test/integration/ConnectivityChecking.test.ts +3 -2
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNode.test.ts +6 -6
- 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 +8 -7
- package/test/integration/Layer1-scale.test.ts +3 -3
- 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 +13 -13
- package/test/integration/RouterRpcRemote.test.ts +7 -7
- package/test/integration/SimultaneousConnections.test.ts +14 -13
- package/test/integration/Store.test.ts +9 -9
- package/test/integration/StoreAndDelete.test.ts +10 -10
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +10 -10
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +10 -10
- package/test/integration/StoreRpcRemote.test.ts +11 -11
- package/test/integration/WebrtcConnectionManagement.test.ts +4 -31
- package/test/integration/WebrtcConnectorRpc.test.ts +14 -14
- package/test/integration/Websocket.test.ts +0 -2
- package/test/integration/WebsocketClientConnectorRpc.test.ts +8 -8
- package/test/integration/WebsocketConnectionManagement.test.ts +11 -12
- package/test/integration/{rpc-connections-over-webrpc.test.ts → rpc-connections-over-webrtc.test.ts} +12 -46
- package/test/unit/AutoCertifierClientFacade.test.ts +6 -6
- 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 +2 -2
- package/test/unit/ListeningRpcCommunicator.test.ts +52 -0
- package/test/unit/LocalDataStore.test.ts +21 -21
- package/test/unit/PeerManager.test.ts +15 -15
- 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 +6 -6
- package/test/unit/Router.test.ts +6 -6
- package/test/unit/RoutingSession.test.ts +13 -6
- package/test/unit/SortedContactList.test.ts +8 -8
- package/test/unit/StoreManager.test.ts +12 -12
- 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 +6 -6
- package/test/unit/createPeerDescriptor.test.ts +4 -4
- package/test/unit/customMatchers.test.ts +18 -0
- package/test/unit/getClosestNodes.test.ts +5 -5
- package/test/unit/version.test.ts +9 -9
- package/test/utils/FakeConnectorFacade.ts +1 -1
- package/test/utils/FakeTransport.ts +12 -9
- package/test/utils/customMatchers.ts +9 -9
- 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 -4
- package/test/utils/utils.ts +11 -11
- package/tsconfig.jest.json +2 -1
- package/tsconfig.node.json +1 -0
- package/.eslintignore +0 -5
- package/.eslintrc +0 -3
- package/dist/src/proto/google/protobuf/any.d.ts +0 -173
- package/dist/src/proto/google/protobuf/any.js +0 -155
- package/dist/src/proto/google/protobuf/any.js.map +0 -1
- package/dist/src/proto/google/protobuf/empty.d.ts +0 -32
- package/dist/src/proto/google/protobuf/empty.js +0 -32
- package/dist/src/proto/google/protobuf/empty.js.map +0 -1
- package/dist/src/proto/google/protobuf/timestamp.d.ts +0 -149
- package/dist/src/proto/google/protobuf/timestamp.js +0 -136
- package/dist/src/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +0 -352
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +0 -278
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +0 -975
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +0 -661
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +0 -157
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js +0 -3
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +0 -1
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -87
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +0 -66
- 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/jest.config.js +0 -5
- package/src/proto/google/protobuf/any.ts +0 -319
- package/src/proto/google/protobuf/empty.ts +0 -82
- package/src/proto/google/protobuf/timestamp.ts +0 -281
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +0 -407
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +0 -160
- package/src/proto/packages/dht/protos/DhtRpc.ts +0 -1244
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +0 -108
- package/src/proto/tests.ts +0 -52
- package/test/benchmark/any.test.ts +0 -28
- /package/{src/types/glogal.d.ts → test/types/global.d.ts} +0 -0
|
@@ -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
|
|
|
@@ -161,34 +162,6 @@ describe('WebRTC Connection Management', () => {
|
|
|
161
162
|
|
|
162
163
|
}, 20000)
|
|
163
164
|
|
|
164
|
-
it('Disconnects webrtcconnection while being connected', async () => {
|
|
165
|
-
const msg: Message = {
|
|
166
|
-
serviceId,
|
|
167
|
-
messageId: '1',
|
|
168
|
-
body: {
|
|
169
|
-
oneofKind: 'rpcMessage',
|
|
170
|
-
rpcMessage: RpcMessage.create()
|
|
171
|
-
},
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const disconnectedPromise1 = new Promise<void>((resolve, _reject) => {
|
|
175
|
-
manager1.on('disconnected', () => {
|
|
176
|
-
resolve()
|
|
177
|
-
})
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
msg.targetDescriptor = peerDescriptor2
|
|
181
|
-
manager1.send(msg).catch((e) => {
|
|
182
|
-
expect(e.code).toEqual('SEND_FAILED')
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
// @ts-expect-error private field
|
|
186
|
-
manager1.closeConnection(peerDescriptor2)
|
|
187
|
-
|
|
188
|
-
await disconnectedPromise1
|
|
189
|
-
|
|
190
|
-
}, 20000)
|
|
191
|
-
|
|
192
165
|
it('failed connections are cleaned up', async () => {
|
|
193
166
|
const msg: Message = {
|
|
194
167
|
serviceId,
|
|
@@ -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 '../../
|
|
12
|
-
import {
|
|
13
|
-
import { RpcMessage } from '../../
|
|
11
|
+
import { IWebrtcConnectorRpc } from '../../generated/packages/dht/protos/DhtRpc.server'
|
|
12
|
+
import { until } from '@streamr/utils'
|
|
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()))
|
|
@@ -86,7 +86,7 @@ describe('WebRTC rpc messages', () => {
|
|
|
86
86
|
{ targetDescriptor, notification: true }
|
|
87
87
|
)
|
|
88
88
|
|
|
89
|
-
await
|
|
89
|
+
await until(() => requestConnectionCounter === 1)
|
|
90
90
|
})
|
|
91
91
|
|
|
92
92
|
it('send rtcOffer', async () => {
|
|
@@ -97,7 +97,7 @@ describe('WebRTC rpc messages', () => {
|
|
|
97
97
|
{ targetDescriptor, notification: true }
|
|
98
98
|
)
|
|
99
99
|
|
|
100
|
-
await
|
|
100
|
+
await until(() => rtcOfferCounter === 1)
|
|
101
101
|
})
|
|
102
102
|
|
|
103
103
|
it('send rtcAnswer', async () => {
|
|
@@ -108,7 +108,7 @@ describe('WebRTC rpc messages', () => {
|
|
|
108
108
|
{ targetDescriptor, notification: true }
|
|
109
109
|
)
|
|
110
110
|
|
|
111
|
-
await
|
|
111
|
+
await until(() => rtcAnswerCounter === 1)
|
|
112
112
|
})
|
|
113
113
|
|
|
114
114
|
it('send iceCandidate', async () => {
|
|
@@ -120,6 +120,6 @@ describe('WebRTC rpc messages', () => {
|
|
|
120
120
|
{ targetDescriptor, notification: true }
|
|
121
121
|
)
|
|
122
122
|
|
|
123
|
-
await
|
|
123
|
+
await until(() => iceCandidateCounter === 1)
|
|
124
124
|
})
|
|
125
125
|
})
|
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
import { MetricsContext, waitForCondition, waitForEvent3 } from '@streamr/utils'
|
|
1
|
+
import { MetricsContext, until, 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 () => {
|
|
@@ -159,14 +158,14 @@ describe('Websocket Connection Management', () => {
|
|
|
159
158
|
targetDescriptor: wsServerConnectorPeerDescriptor
|
|
160
159
|
}
|
|
161
160
|
await noWsServerManager.send(dummyMessage)
|
|
162
|
-
await
|
|
161
|
+
await until(
|
|
163
162
|
() => {
|
|
164
|
-
const nodeId =
|
|
163
|
+
const nodeId = toNodeId(noWsServerConnectorPeerDescriptor)
|
|
165
164
|
return wsServerManager.hasConnection(nodeId)
|
|
166
165
|
}
|
|
167
166
|
)
|
|
168
|
-
await
|
|
169
|
-
() => noWsServerManager.hasConnection(
|
|
167
|
+
await until(
|
|
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
|
|
|
@@ -50,7 +51,6 @@ describe('RPC connections over WebRTC', () => {
|
|
|
50
51
|
await connectorTransport2.start()
|
|
51
52
|
manager2 = createConnectionManager(peerDescriptor2, connectorTransport2)
|
|
52
53
|
rpcCommunicator2 = new ListeningRpcCommunicator(SERVICE_ID, manager2)
|
|
53
|
-
//client2 = toProtoRpcClient(new DhtNodeRpcClient(rpcCommunicator2.getRpcClientTransport()))
|
|
54
54
|
|
|
55
55
|
await manager1.start()
|
|
56
56
|
await manager2.start()
|
|
@@ -87,7 +87,7 @@ describe('RPC connections over WebRTC', () => {
|
|
|
87
87
|
const response = await client1.ping(request, options)
|
|
88
88
|
|
|
89
89
|
expect(response.requestId).toEqual(request.requestId)
|
|
90
|
-
}
|
|
90
|
+
})
|
|
91
91
|
|
|
92
92
|
it('Throws an exception if RPC method is not defined', async () => {
|
|
93
93
|
|
|
@@ -101,57 +101,23 @@ describe('RPC connections over WebRTC', () => {
|
|
|
101
101
|
|
|
102
102
|
await expect(client1.ping(request, options))
|
|
103
103
|
.rejects.toThrow('Server does not implement method ping')
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/*
|
|
107
|
-
|
|
108
|
-
TODO enable these tests (NET-1177)
|
|
104
|
+
})
|
|
109
105
|
|
|
110
|
-
it
|
|
106
|
+
it('Throws a client-side exception if WebRTC connection fails', async () => {
|
|
111
107
|
|
|
112
108
|
const request: PingRequest = {
|
|
113
109
|
requestId: v4()
|
|
114
110
|
}
|
|
115
111
|
const options: DhtRpcOptions = {
|
|
116
112
|
sourceDescriptor: peerDescriptor1,
|
|
117
|
-
targetDescriptor: peerDescriptor2
|
|
113
|
+
targetDescriptor: peerDescriptor2,
|
|
114
|
+
timeout: 10000
|
|
118
115
|
}
|
|
119
|
-
await connectorTransport1.stop()
|
|
120
116
|
await manager2.stop()
|
|
121
117
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}, 60000)
|
|
125
|
-
|
|
126
|
-
it('Disconnects WebrtcConnection while being connected', async () => {
|
|
127
|
-
|
|
128
|
-
const rpcMessage: RpcMessage = {
|
|
129
|
-
header: {},
|
|
130
|
-
body: new Uint8Array(10),
|
|
131
|
-
requestId: v4()
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const msg: Message = {
|
|
135
|
-
serviceId,
|
|
136
|
-
messageId: '1',
|
|
137
|
-
body: RpcMessage.toBinary(rpcMessage)
|
|
138
|
-
}
|
|
118
|
+
await expect(client1.ping(request, options))
|
|
119
|
+
.rejects.toThrow('Peer disconnected')
|
|
139
120
|
|
|
140
|
-
|
|
141
|
-
manager1.on('disconnected', () => {
|
|
142
|
-
//expect(message.body.oneofKind).toBe('rpcMessage')
|
|
143
|
-
resolve()
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
msg.targetDescriptor = peerDescriptor2
|
|
148
|
-
manager1.send(msg).catch((e) => {
|
|
149
|
-
expect(e.code).toEqual('CONNECTION_FAILED')
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
manager1.disconnect(peerDescriptor2!, undefined, 100)
|
|
153
|
-
await disconnectedPromise1
|
|
121
|
+
}, 10000)
|
|
154
122
|
|
|
155
|
-
}, 20000)
|
|
156
|
-
*/
|
|
157
123
|
})
|
|
@@ -42,17 +42,17 @@ describe('AutoCertifierClientFacade', () => {
|
|
|
42
42
|
|
|
43
43
|
it('start', async () => {
|
|
44
44
|
await client.start()
|
|
45
|
-
expect(setHost).
|
|
46
|
-
expect(updateCertificate).
|
|
45
|
+
expect(setHost).toHaveBeenCalled()
|
|
46
|
+
expect(updateCertificate).toHaveBeenCalled()
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
it('updated events are processed', async () => {
|
|
50
50
|
await client.start()
|
|
51
|
-
expect(setHost).
|
|
52
|
-
expect(updateCertificate).
|
|
51
|
+
expect(setHost).toHaveBeenCalledTimes(1)
|
|
52
|
+
expect(updateCertificate).toHaveBeenCalledTimes(1);
|
|
53
53
|
(mockClient as MockAutoCertifierClient).emitUpdateSubdomain()
|
|
54
|
-
expect(setHost).
|
|
55
|
-
expect(updateCertificate).
|
|
54
|
+
expect(setHost).toHaveBeenCalledTimes(2)
|
|
55
|
+
expect(updateCertificate).toHaveBeenCalledTimes(2)
|
|
56
56
|
})
|
|
57
57
|
|
|
58
58
|
})
|
|
@@ -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', () => {
|
|
@@ -104,7 +104,7 @@ describe('Handshaker', () => {
|
|
|
104
104
|
})
|
|
105
105
|
|
|
106
106
|
it('onHandshakeFailed unsupported version', () => {
|
|
107
|
-
handshaker.emit('handshakeFailed', HandshakeError.
|
|
107
|
+
handshaker.emit('handshakeFailed', HandshakeError.UNSUPPORTED_PROTOCOL_VERSION)
|
|
108
108
|
expect(mockOnHandshakeCompleted).not.toHaveBeenCalled()
|
|
109
109
|
expect(mockPendingConnectionClose).toHaveBeenCalledTimes(1)
|
|
110
110
|
})
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { until } 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 until(() => rpcCommunicator.getRequestIds(() => true).length > 0)
|
|
48
|
+
transport.emit('disconnected', peerDescriptor, false)
|
|
49
|
+
await until(() => rpcCommunicator.getRequestIds(() => true).length === 0)
|
|
50
|
+
}, 10000)
|
|
51
|
+
|
|
52
|
+
})
|
|
@@ -2,7 +2,7 @@ import { wait } from '@streamr/utils'
|
|
|
2
2
|
import { LocalDataStore } from '../../src/dht/store/LocalDataStore'
|
|
3
3
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
4
4
|
import { createMockDataEntry } from '../utils/mock/mockDataEntry'
|
|
5
|
-
import {
|
|
5
|
+
import { randomDhtAddress, toDhtAddress, toNodeId } from '../../src/identifiers'
|
|
6
6
|
|
|
7
7
|
describe('LocalDataStore', () => {
|
|
8
8
|
|
|
@@ -19,14 +19,14 @@ describe('LocalDataStore', () => {
|
|
|
19
19
|
it('can store', () => {
|
|
20
20
|
const storedEntry = createMockDataEntry()
|
|
21
21
|
localDataStore.storeEntry(storedEntry)
|
|
22
|
-
const fetchedEntries = Array.from(localDataStore.values(
|
|
22
|
+
const fetchedEntries = Array.from(localDataStore.values(toDhtAddress(storedEntry.key)))
|
|
23
23
|
expect(fetchedEntries).toIncludeSameMembers([storedEntry])
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
it('multiple storers behind one key', () => {
|
|
27
|
-
const creator1 =
|
|
28
|
-
const creator2 =
|
|
29
|
-
const key =
|
|
27
|
+
const creator1 = randomDhtAddress()
|
|
28
|
+
const creator2 = randomDhtAddress()
|
|
29
|
+
const key = randomDhtAddress()
|
|
30
30
|
const storedEntry1 = createMockDataEntry({ key, creator: creator1 })
|
|
31
31
|
const storedEntry2 = createMockDataEntry({ key, creator: creator2 })
|
|
32
32
|
localDataStore.storeEntry(storedEntry1)
|
|
@@ -36,9 +36,9 @@ describe('LocalDataStore', () => {
|
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
it('can remove data entries', () => {
|
|
39
|
-
const creator1 =
|
|
40
|
-
const creator2 =
|
|
41
|
-
const key =
|
|
39
|
+
const creator1 = randomDhtAddress()
|
|
40
|
+
const creator2 = randomDhtAddress()
|
|
41
|
+
const key = randomDhtAddress()
|
|
42
42
|
const storedEntry1 = createMockDataEntry({ key, creator: creator1 })
|
|
43
43
|
const storedEntry2 = createMockDataEntry({ key, creator: creator2 })
|
|
44
44
|
localDataStore.storeEntry(storedEntry1)
|
|
@@ -49,9 +49,9 @@ describe('LocalDataStore', () => {
|
|
|
49
49
|
})
|
|
50
50
|
|
|
51
51
|
it('can remove all data entries', () => {
|
|
52
|
-
const creator1 =
|
|
53
|
-
const creator2 =
|
|
54
|
-
const key =
|
|
52
|
+
const creator1 = randomDhtAddress()
|
|
53
|
+
const creator2 = randomDhtAddress()
|
|
54
|
+
const key = randomDhtAddress()
|
|
55
55
|
const storedEntry1 = createMockDataEntry({ key, creator: creator1 })
|
|
56
56
|
const storedEntry2 = createMockDataEntry({ key, creator: creator2 })
|
|
57
57
|
localDataStore.storeEntry(storedEntry1)
|
|
@@ -64,33 +64,33 @@ describe('LocalDataStore', () => {
|
|
|
64
64
|
it('data is deleted after TTL', async () => {
|
|
65
65
|
const storedEntry = createMockDataEntry({ ttl: 1000 })
|
|
66
66
|
localDataStore.storeEntry(storedEntry)
|
|
67
|
-
expect(Array.from(localDataStore.values(
|
|
67
|
+
expect(Array.from(localDataStore.values(toDhtAddress(storedEntry.key)))).toHaveLength(1)
|
|
68
68
|
await wait(1100)
|
|
69
|
-
expect(Array.from(localDataStore.values(
|
|
69
|
+
expect(Array.from(localDataStore.values(toDhtAddress(storedEntry.key)))).toHaveLength(0)
|
|
70
70
|
})
|
|
71
71
|
|
|
72
72
|
describe('mark data as deleted', () => {
|
|
73
73
|
|
|
74
74
|
it('happy path', () => {
|
|
75
|
-
const creator1 =
|
|
75
|
+
const creator1 = randomDhtAddress()
|
|
76
76
|
const storedEntry = createMockDataEntry({ creator: creator1 })
|
|
77
77
|
localDataStore.storeEntry(storedEntry)
|
|
78
|
-
const notDeletedData = Array.from(localDataStore.values(
|
|
78
|
+
const notDeletedData = Array.from(localDataStore.values(toDhtAddress(storedEntry.key)))
|
|
79
79
|
expect(notDeletedData[0].deleted).toBeFalse()
|
|
80
80
|
const returnValue = localDataStore.markAsDeleted(
|
|
81
|
-
|
|
81
|
+
toDhtAddress(storedEntry.key),
|
|
82
82
|
creator1
|
|
83
83
|
)
|
|
84
84
|
expect(returnValue).toBe(true)
|
|
85
|
-
const deletedData = Array.from(localDataStore.values(
|
|
85
|
+
const deletedData = Array.from(localDataStore.values(toDhtAddress(storedEntry.key)))
|
|
86
86
|
expect(deletedData[0].deleted).toBeTrue()
|
|
87
87
|
})
|
|
88
88
|
|
|
89
89
|
it('data not stored', () => {
|
|
90
|
-
const key =
|
|
90
|
+
const key = randomDhtAddress()
|
|
91
91
|
const returnValue = localDataStore.markAsDeleted(
|
|
92
92
|
key,
|
|
93
|
-
|
|
93
|
+
toNodeId(createMockPeerDescriptor())
|
|
94
94
|
)
|
|
95
95
|
expect(returnValue).toBe(false)
|
|
96
96
|
})
|
|
@@ -99,8 +99,8 @@ describe('LocalDataStore', () => {
|
|
|
99
99
|
const storedEntry = createMockDataEntry()
|
|
100
100
|
localDataStore.storeEntry(storedEntry)
|
|
101
101
|
const returnValue = localDataStore.markAsDeleted(
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
toDhtAddress(storedEntry.key),
|
|
103
|
+
toNodeId(createMockPeerDescriptor())
|
|
104
104
|
)
|
|
105
105
|
expect(returnValue).toBe(false)
|
|
106
106
|
})
|