@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,9 +1,9 @@
|
|
|
1
1
|
import { areEqualBinaries, waitForEvent3 } from '@streamr/utils'
|
|
2
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
|
-
import { PeerDescriptor } from '../../
|
|
4
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
|
-
import {
|
|
6
|
+
import { toNodeId } from '../../src/exports'
|
|
7
7
|
|
|
8
8
|
describe('Layer0 with WebRTC connections', () => {
|
|
9
9
|
|
|
@@ -64,8 +64,8 @@ describe('Layer0 with WebRTC connections', () => {
|
|
|
64
64
|
node2.joinDht([epPeerDescriptor]),
|
|
65
65
|
node1.joinDht([epPeerDescriptor])
|
|
66
66
|
])
|
|
67
|
-
const nodeId1 =
|
|
68
|
-
const nodeId2 =
|
|
67
|
+
const nodeId1 = toNodeId(node1.getLocalPeerDescriptor())
|
|
68
|
+
const nodeId2 = toNodeId(node2.getLocalPeerDescriptor())
|
|
69
69
|
expect((node1.getTransport() as ConnectionManager).hasConnection(nodeId2)).toEqual(true)
|
|
70
70
|
expect((node2.getTransport() as ConnectionManager).hasConnection(nodeId1)).toEqual(true)
|
|
71
71
|
}, 60000)
|
|
@@ -77,8 +77,8 @@ describe('Layer0 with WebRTC connections', () => {
|
|
|
77
77
|
node3.joinDht([epPeerDescriptor]),
|
|
78
78
|
node4.joinDht([epPeerDescriptor])
|
|
79
79
|
])
|
|
80
|
-
const nodeId1 =
|
|
81
|
-
const nodeId2 =
|
|
80
|
+
const nodeId1 = toNodeId(node1.getLocalPeerDescriptor())
|
|
81
|
+
const nodeId2 = toNodeId(node2.getLocalPeerDescriptor())
|
|
82
82
|
expect((node1.getTransport() as ConnectionManager).hasConnection(nodeId2)).toEqual(true)
|
|
83
83
|
expect((node2.getTransport() as ConnectionManager).hasConnection(nodeId1)).toEqual(true)
|
|
84
84
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
2
|
-
import { PeerDescriptor } from '../../
|
|
2
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
3
3
|
import os from 'os'
|
|
4
4
|
|
|
5
5
|
describe('Failed autocertification', () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PeerDescriptor } from '../../
|
|
1
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
4
|
-
import {
|
|
4
|
+
import { until } from '@streamr/utils'
|
|
5
5
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
6
|
import { areEqualPeerDescriptors } from '../../src/identifiers'
|
|
7
7
|
|
|
@@ -60,7 +60,7 @@ describe('Websocket IConnection Requests', () => {
|
|
|
60
60
|
await node2.joinDht([epPeerDescriptor])
|
|
61
61
|
await node1.joinDht([epPeerDescriptor])
|
|
62
62
|
|
|
63
|
-
await
|
|
63
|
+
await until(() => { return (connected1 && connected2) })
|
|
64
64
|
|
|
65
65
|
expect((node1.getTransport() as ConnectionManager).hasConnection(node2.getNodeId())).toEqual(true)
|
|
66
66
|
expect((node2.getTransport() as ConnectionManager).hasConnection(node1.getNodeId())).toEqual(true)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import LeakDetector from 'jest-leak-detector'
|
|
2
|
-
import {
|
|
2
|
+
import { until } from '@streamr/utils'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
|
-
import { Message } from '../../
|
|
5
|
-
import { RpcMessage } from '../../
|
|
4
|
+
import { Message } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
6
6
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
7
|
-
import {
|
|
7
|
+
import { toNodeId } from '../../src/identifiers'
|
|
8
8
|
|
|
9
9
|
const MESSAGE_ID = 'mock-message-id'
|
|
10
10
|
|
|
@@ -19,7 +19,7 @@ describe('memory leak', () => {
|
|
|
19
19
|
}
|
|
20
20
|
})
|
|
21
21
|
let entryPoint: DhtNode | undefined = new DhtNode({
|
|
22
|
-
nodeId:
|
|
22
|
+
nodeId: toNodeId(entryPointDescriptor),
|
|
23
23
|
websocketHost: entryPointDescriptor.websocket!.host,
|
|
24
24
|
websocketPortRange: {
|
|
25
25
|
min: entryPointDescriptor.websocket!.port,
|
|
@@ -55,7 +55,7 @@ describe('memory leak', () => {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
await sender.send(msg)
|
|
58
|
-
await
|
|
58
|
+
await until(() => receivedMessage !== undefined)
|
|
59
59
|
expect(receivedMessage!.messageId).toEqual(MESSAGE_ID)
|
|
60
60
|
|
|
61
61
|
await Promise.all([
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { MetricsContext,
|
|
1
|
+
import { MetricsContext, until } from '@streamr/utils'
|
|
2
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
3
3
|
import { DefaultConnectorFacade } from '../../src/connection/ConnectorFacade'
|
|
4
4
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
5
5
|
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
6
6
|
import { ITransport } from '../../src/transport/ITransport'
|
|
7
|
-
import { PeerDescriptor } from '../../
|
|
7
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
8
8
|
import { getRandomRegion } from '../../dist/src/connection/simulator/pings'
|
|
9
9
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
10
|
-
import {
|
|
10
|
+
import { toNodeId } from '../../src/identifiers'
|
|
11
11
|
|
|
12
12
|
const createConnectionManager = (localPeerDescriptor: PeerDescriptor, transport: ITransport) => {
|
|
13
13
|
return new ConnectionManager({
|
|
@@ -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: true
|
|
19
20
|
})
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -56,10 +57,11 @@ describe('Connection Locking', () => {
|
|
|
56
57
|
})
|
|
57
58
|
|
|
58
59
|
it('can lock connections', async () => {
|
|
59
|
-
const nodeId1 =
|
|
60
|
-
const nodeId2 =
|
|
60
|
+
const nodeId1 = toNodeId(mockPeerDescriptor1)
|
|
61
|
+
const nodeId2 = toNodeId(mockPeerDescriptor2)
|
|
61
62
|
await Promise.all([
|
|
62
|
-
|
|
63
|
+
until(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
63
65
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock')
|
|
64
66
|
])
|
|
65
67
|
expect(connectionManager1.hasConnection(nodeId2)).toEqual(true)
|
|
@@ -68,14 +70,16 @@ describe('Connection Locking', () => {
|
|
|
68
70
|
})
|
|
69
71
|
|
|
70
72
|
it('Multiple services on the same peer', async () => {
|
|
71
|
-
const nodeId1 =
|
|
72
|
-
const nodeId2 =
|
|
73
|
+
const nodeId1 = toNodeId(mockPeerDescriptor1)
|
|
74
|
+
const nodeId2 = toNodeId(mockPeerDescriptor2)
|
|
73
75
|
await Promise.all([
|
|
74
|
-
|
|
76
|
+
until(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
75
78
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock1')
|
|
76
79
|
])
|
|
77
80
|
await Promise.all([
|
|
78
|
-
|
|
81
|
+
until(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
79
83
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock2')
|
|
80
84
|
])
|
|
81
85
|
expect(connectionManager1.hasConnection(nodeId2)).toEqual(true)
|
|
@@ -84,35 +88,38 @@ describe('Connection Locking', () => {
|
|
|
84
88
|
})
|
|
85
89
|
|
|
86
90
|
it('can unlock connections', async () => {
|
|
87
|
-
const nodeId1 =
|
|
88
|
-
const nodeId2 =
|
|
91
|
+
const nodeId1 = toNodeId(mockPeerDescriptor1)
|
|
92
|
+
const nodeId2 = toNodeId(mockPeerDescriptor2)
|
|
89
93
|
await Promise.all([
|
|
90
|
-
|
|
94
|
+
until(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
91
96
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock')
|
|
92
97
|
])
|
|
93
|
-
expect(connectionManager1.hasConnection(nodeId2))
|
|
98
|
+
expect(connectionManager1.hasConnection(nodeId2)).toEqual(true)
|
|
94
99
|
expect(connectionManager2.hasLocalLockedConnection(nodeId2)).toEqual(false)
|
|
95
100
|
expect(connectionManager2.hasRemoteLockedConnection(nodeId1)).toEqual(true)
|
|
96
101
|
|
|
97
102
|
connectionManager1.unlockConnection(mockPeerDescriptor2, 'testLock')
|
|
98
103
|
expect(connectionManager1.hasLocalLockedConnection(nodeId2)).toEqual(false)
|
|
99
|
-
await
|
|
104
|
+
await until(() => connectionManager2.hasRemoteLockedConnection(nodeId1) === false)
|
|
100
105
|
expect(connectionManager1.hasConnection(nodeId1)).toEqual(false)
|
|
101
106
|
})
|
|
102
107
|
|
|
103
108
|
it('unlocking multiple services', async () => {
|
|
104
|
-
const nodeId1 =
|
|
105
|
-
const nodeId2 =
|
|
109
|
+
const nodeId1 = toNodeId(mockPeerDescriptor1)
|
|
110
|
+
const nodeId2 = toNodeId(mockPeerDescriptor2)
|
|
106
111
|
await Promise.all([
|
|
107
|
-
|
|
112
|
+
until(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
108
114
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock1')
|
|
109
115
|
])
|
|
110
116
|
await Promise.all([
|
|
111
|
-
|
|
117
|
+
until(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
112
119
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock2')
|
|
113
120
|
])
|
|
114
121
|
|
|
115
|
-
expect(connectionManager1.hasConnection(nodeId2))
|
|
122
|
+
expect(connectionManager1.hasConnection(nodeId2)).toEqual(true)
|
|
116
123
|
expect(connectionManager2.hasLocalLockedConnection(nodeId1)).toEqual(false)
|
|
117
124
|
|
|
118
125
|
connectionManager1.unlockConnection(mockPeerDescriptor2, 'testLock1')
|
|
@@ -124,20 +131,22 @@ describe('Connection Locking', () => {
|
|
|
124
131
|
})
|
|
125
132
|
|
|
126
133
|
it('maintains connection if both sides initially lock and then one end unlocks', async () => {
|
|
127
|
-
const nodeId1 =
|
|
128
|
-
const nodeId2 =
|
|
134
|
+
const nodeId1 = toNodeId(mockPeerDescriptor1)
|
|
135
|
+
const nodeId2 = toNodeId(mockPeerDescriptor2)
|
|
129
136
|
await Promise.all([
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
until(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
138
|
+
until(() => connectionManager1.hasRemoteLockedConnection(nodeId2)),
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
132
140
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock1'),
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
133
142
|
connectionManager2.lockConnection(mockPeerDescriptor1, 'testLock1')
|
|
134
143
|
])
|
|
135
144
|
|
|
136
|
-
expect(connectionManager1.hasLocalLockedConnection(nodeId2))
|
|
137
|
-
expect(connectionManager2.hasLocalLockedConnection(nodeId1))
|
|
145
|
+
expect(connectionManager1.hasLocalLockedConnection(nodeId2)).toEqual(true)
|
|
146
|
+
expect(connectionManager2.hasLocalLockedConnection(nodeId1)).toEqual(true)
|
|
138
147
|
|
|
139
148
|
connectionManager1.unlockConnection(mockPeerDescriptor2, 'testLock1')
|
|
140
|
-
await
|
|
149
|
+
await until(() =>
|
|
141
150
|
connectionManager1.hasRemoteLockedConnection(nodeId2)
|
|
142
151
|
&& !connectionManager1.hasLocalLockedConnection(nodeId2)
|
|
143
152
|
&& !connectionManager2.hasRemoteLockedConnection(nodeId1)
|
|
@@ -149,31 +158,33 @@ describe('Connection Locking', () => {
|
|
|
149
158
|
})
|
|
150
159
|
|
|
151
160
|
it('unlocks after graceful disconnect', async () => {
|
|
152
|
-
const nodeId1 =
|
|
153
|
-
const nodeId2 =
|
|
161
|
+
const nodeId1 = toNodeId(mockPeerDescriptor1)
|
|
162
|
+
const nodeId2 = toNodeId(mockPeerDescriptor2)
|
|
154
163
|
await Promise.all([
|
|
155
|
-
|
|
156
|
-
|
|
164
|
+
until(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
165
|
+
until(() => connectionManager1.hasRemoteLockedConnection(nodeId2)),
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
157
167
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock1'),
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
158
169
|
connectionManager2.lockConnection(mockPeerDescriptor1, 'testLock1')
|
|
159
170
|
])
|
|
160
|
-
expect(connectionManager1.hasConnection(nodeId2))
|
|
171
|
+
expect(connectionManager1.hasConnection(nodeId2)).toEqual(true)
|
|
161
172
|
expect(connectionManager2.hasLocalLockedConnection(nodeId1)).toEqual(true)
|
|
162
173
|
expect(connectionManager2.hasRemoteLockedConnection(nodeId1)).toEqual(true)
|
|
163
174
|
|
|
164
175
|
//@ts-expect-error private field
|
|
165
176
|
await connectionManager1.gracefullyDisconnectAsync(mockPeerDescriptor2)
|
|
166
177
|
|
|
167
|
-
await
|
|
178
|
+
await until(() =>
|
|
168
179
|
!connectionManager1.hasRemoteLockedConnection(nodeId2)
|
|
169
180
|
&& !connectionManager1.hasLocalLockedConnection(nodeId2)
|
|
170
181
|
)
|
|
171
|
-
await
|
|
182
|
+
await until(() =>
|
|
172
183
|
!connectionManager2.hasRemoteLockedConnection(nodeId1)
|
|
173
184
|
&& !connectionManager2.hasLocalLockedConnection(nodeId1)
|
|
174
185
|
)
|
|
175
|
-
await
|
|
176
|
-
await
|
|
186
|
+
await until(() => !connectionManager2.hasConnection(nodeId1))
|
|
187
|
+
await until(() => !connectionManager1.hasConnection(nodeId2))
|
|
177
188
|
|
|
178
189
|
expect(connectionManager1.hasConnection(nodeId2)).toEqual(false)
|
|
179
190
|
expect(connectionManager2.hasConnection(nodeId1)).toEqual(false)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Logger, MetricsContext, waitForEvent3 } from '@streamr/utils'
|
|
1
|
+
import { Logger, MetricsContext, until, waitForEvent3 } from '@streamr/utils'
|
|
2
2
|
import { MarkOptional } from 'ts-essentials'
|
|
3
3
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
4
4
|
import { DefaultConnectorFacade, DefaultConnectorFacadeOptions } from '../../src/connection/ConnectorFacade'
|
|
5
5
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
6
6
|
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
7
7
|
import { createPeerDescriptor } from '../../src/helpers/createPeerDescriptor'
|
|
8
|
-
import {
|
|
9
|
-
import { ConnectivityResponse, Message, NodeType, PeerDescriptor } from '../../
|
|
10
|
-
import { RpcMessage } from '../../
|
|
8
|
+
import { randomDhtAddress, toDhtAddressRaw } from '../../src/identifiers'
|
|
9
|
+
import { ConnectivityResponse, Message, NodeType, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
10
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
11
11
|
import { TransportEvents } from '../../src/transport/ITransport'
|
|
12
12
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
13
13
|
import { getRandomRegion } from '../../src/connection/simulator/pings'
|
|
@@ -37,7 +37,8 @@ describe('ConnectionManager', () => {
|
|
|
37
37
|
websocketServerEnableTls: false,
|
|
38
38
|
...opts
|
|
39
39
|
}),
|
|
40
|
-
metricsContext: new MetricsContext()
|
|
40
|
+
metricsContext: new MetricsContext(),
|
|
41
|
+
allowIncomingPrivateConnections: true
|
|
41
42
|
})
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -383,7 +384,7 @@ describe('ConnectionManager', () => {
|
|
|
383
384
|
messageId: '1',
|
|
384
385
|
targetDescriptor: {
|
|
385
386
|
// This is not the correct nodeId of peerDescriptor2
|
|
386
|
-
nodeId:
|
|
387
|
+
nodeId: toDhtAddressRaw(randomDhtAddress()),
|
|
387
388
|
type: NodeType.NODEJS,
|
|
388
389
|
websocket: peerDescriptor2.websocket
|
|
389
390
|
},
|
|
@@ -469,4 +470,59 @@ describe('ConnectionManager', () => {
|
|
|
469
470
|
await connectionManager2.stop()
|
|
470
471
|
})
|
|
471
472
|
|
|
473
|
+
it('private connections', async () => {
|
|
474
|
+
const connectionManager1 = createConnectionManager({
|
|
475
|
+
transport: mockTransport,
|
|
476
|
+
websocketHost: '127.0.0.1',
|
|
477
|
+
websocketServerEnableTls: false,
|
|
478
|
+
websocketPortRange: { min: 10009, max: 10009 }
|
|
479
|
+
})
|
|
480
|
+
|
|
481
|
+
await connectionManager1.start()
|
|
482
|
+
|
|
483
|
+
const connectionManager2 = createConnectionManager({
|
|
484
|
+
transport: mockTransport,
|
|
485
|
+
websocketHost: '127.0.0.1',
|
|
486
|
+
websocketServerEnableTls: false,
|
|
487
|
+
websocketPortRange: { min: 10010, max: 100010 }
|
|
488
|
+
})
|
|
489
|
+
|
|
490
|
+
await connectionManager2.start()
|
|
491
|
+
|
|
492
|
+
const msg: Message = {
|
|
493
|
+
serviceId: SERVICE_ID,
|
|
494
|
+
messageId: '1',
|
|
495
|
+
body: {
|
|
496
|
+
oneofKind: 'rpcMessage',
|
|
497
|
+
rpcMessage: RpcMessage.create()
|
|
498
|
+
},
|
|
499
|
+
targetDescriptor: connectionManager1.getLocalPeerDescriptor()
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const connectedPromise1 = new Promise<void>((resolve, _reject) => {
|
|
503
|
+
connectionManager1.on('connected', () => {
|
|
504
|
+
resolve()
|
|
505
|
+
})
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
const connectedPromise2 = new Promise<void>((resolve, _reject) => {
|
|
509
|
+
connectionManager2.on('connected', () => {
|
|
510
|
+
resolve()
|
|
511
|
+
})
|
|
512
|
+
})
|
|
513
|
+
await Promise.all([connectedPromise1, connectedPromise2, connectionManager2.send(msg)])
|
|
514
|
+
|
|
515
|
+
await connectionManager1.enablePrivateClientMode()
|
|
516
|
+
await until(() => connectionManager2.getConnections().length === 0)
|
|
517
|
+
expect(connectionManager1.getConnections().length).toEqual(1)
|
|
518
|
+
|
|
519
|
+
await connectionManager1.disablePrivateClientMode()
|
|
520
|
+
await until(() => connectionManager2.getConnections().length === 1)
|
|
521
|
+
expect(connectionManager1.getConnections().length).toEqual(1)
|
|
522
|
+
|
|
523
|
+
await connectionManager1.stop()
|
|
524
|
+
await connectionManager2.stop()
|
|
525
|
+
|
|
526
|
+
})
|
|
527
|
+
|
|
472
528
|
})
|
|
@@ -30,7 +30,8 @@ describe('ConnectivityChecking', () => {
|
|
|
30
30
|
websocketServerEnableTls: false,
|
|
31
31
|
transport: new MockTransport()
|
|
32
32
|
}),
|
|
33
|
-
metricsContext: new MetricsContext()
|
|
33
|
+
metricsContext: new MetricsContext(),
|
|
34
|
+
allowIncomingPrivateConnections: false
|
|
34
35
|
})
|
|
35
36
|
await server.start()
|
|
36
37
|
})
|
|
@@ -47,6 +48,6 @@ describe('ConnectivityChecking', () => {
|
|
|
47
48
|
allowSelfSignedCertificate: false
|
|
48
49
|
}
|
|
49
50
|
const response = await sendConnectivityRequest(request, server.getLocalPeerDescriptor())
|
|
50
|
-
expect(response.
|
|
51
|
+
expect(response.protocolVersion).toEqual(LOCAL_PROTOCOL_VERSION)
|
|
51
52
|
})
|
|
52
53
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { getRandomRegion } from '../../src/connection/simulator/pings'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
|
-
import {
|
|
4
|
+
import { toDhtAddress } from '../../src/identifiers'
|
|
5
5
|
import { createMockConnectionDhtNode, createMockPeerDescriptor } from '../utils/utils'
|
|
6
6
|
|
|
7
7
|
const NUM_OF_NODES_PER_KBUCKET = 8
|
|
@@ -11,7 +11,7 @@ const runTest = async (latencyType: LatencyType) => {
|
|
|
11
11
|
const entrypointDescriptor = createMockPeerDescriptor({
|
|
12
12
|
region: getRandomRegion()
|
|
13
13
|
})
|
|
14
|
-
const entryPoint = await createMockConnectionDhtNode(simulator,
|
|
14
|
+
const entryPoint = await createMockConnectionDhtNode(simulator, toDhtAddress(entrypointDescriptor.nodeId), NUM_OF_NODES_PER_KBUCKET)
|
|
15
15
|
const nodes: DhtNode[] = []
|
|
16
16
|
for (let i = 1; i < 100; i++) {
|
|
17
17
|
const node = await createMockConnectionDhtNode(simulator, undefined, NUM_OF_NODES_PER_KBUCKET)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { until } from '@streamr/utils'
|
|
2
2
|
import { range, without } from 'lodash'
|
|
3
3
|
import { DhtNodeRpcLocal } from '../../src/dht/DhtNodeRpcLocal'
|
|
4
|
-
import { DhtNode, ListeningRpcCommunicator,
|
|
5
|
-
import { ClosestPeersRequest, ClosestPeersResponse, PeerDescriptor, PingRequest, PingResponse } from '../../
|
|
4
|
+
import { DhtNode, ListeningRpcCommunicator, toNodeId } from '../../src/exports'
|
|
5
|
+
import { ClosestPeersRequest, ClosestPeersResponse, PeerDescriptor, PingRequest, PingResponse } from '../../generated/packages/dht/protos/DhtRpc'
|
|
6
6
|
import { FakeEnvironment } from '../utils/FakeTransport'
|
|
7
7
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
8
8
|
|
|
@@ -58,9 +58,9 @@ describe('DhtNode', () => {
|
|
|
58
58
|
await localNode.joinDht([entryPointPeerDescriptor])
|
|
59
59
|
await localNode.waitForNetworkConnectivity()
|
|
60
60
|
|
|
61
|
-
await
|
|
62
|
-
const expectedNodeIds = without(getAllPeerDescriptors(), localPeerDescriptor).map((n) =>
|
|
63
|
-
const actualNodeIds = localNode.getClosestContacts().map((n) =>
|
|
61
|
+
await until(() => localNode.getNeighborCount() === otherPeerDescriptors.length + 1)
|
|
62
|
+
const expectedNodeIds = without(getAllPeerDescriptors(), localPeerDescriptor).map((n) => toNodeId(n))
|
|
63
|
+
const actualNodeIds = localNode.getClosestContacts().map((n) => toNodeId(n))
|
|
64
64
|
expect(actualNodeIds).toIncludeSameMembers(expectedNodeIds)
|
|
65
65
|
})
|
|
66
66
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import {
|
|
3
|
+
import { randomDhtAddress, toDhtAddress, toNodeId } from '../../src/identifiers'
|
|
4
4
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
5
5
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
6
6
|
|
|
@@ -27,22 +27,22 @@ describe('DhtNodeExternalApi', () => {
|
|
|
27
27
|
|
|
28
28
|
it('fetch data happy path', async () => {
|
|
29
29
|
const entry = createMockDataEntry()
|
|
30
|
-
await dhtNode1.storeDataToDht(
|
|
31
|
-
const foundData = await remote.fetchDataFromDhtViaPeer(
|
|
30
|
+
await dhtNode1.storeDataToDht(toDhtAddress(entry.key), entry.data!)
|
|
31
|
+
const foundData = await remote.fetchDataFromDhtViaPeer(toDhtAddress(entry.key), dhtNode1.getLocalPeerDescriptor())
|
|
32
32
|
expectEqualData(foundData[0], entry)
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
it('fetch data returns empty array if no data found', async () => {
|
|
36
|
-
const foundData = await remote.fetchDataFromDhtViaPeer(
|
|
36
|
+
const foundData = await remote.fetchDataFromDhtViaPeer(randomDhtAddress(), dhtNode1.getLocalPeerDescriptor())
|
|
37
37
|
expect(foundData).toEqual([])
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
it('external store data happy path', async () => {
|
|
41
41
|
const entry = createMockDataEntry()
|
|
42
|
-
await remote.storeDataToDhtViaPeer(
|
|
43
|
-
const foundData = await remote.fetchDataFromDhtViaPeer(
|
|
42
|
+
await remote.storeDataToDhtViaPeer(toDhtAddress(entry.key), entry.data!, dhtNode1.getLocalPeerDescriptor())
|
|
43
|
+
const foundData = await remote.fetchDataFromDhtViaPeer(toDhtAddress(entry.key), dhtNode1.getLocalPeerDescriptor())
|
|
44
44
|
expectEqualData(foundData[0], entry)
|
|
45
|
-
expect(
|
|
45
|
+
expect(toDhtAddress(foundData[0].creator)).toEqual(toNodeId(remote.getLocalPeerDescriptor()))
|
|
46
46
|
})
|
|
47
47
|
|
|
48
48
|
})
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
ClosestPeersResponse,
|
|
7
7
|
PingRequest,
|
|
8
8
|
PingResponse
|
|
9
|
-
} from '../../
|
|
10
|
-
import { RpcMessage } from '../../
|
|
9
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
10
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
11
11
|
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
12
|
-
import {
|
|
12
|
+
import { toNodeId } from '../../src/identifiers'
|
|
13
13
|
|
|
14
14
|
const SERVICE_ID = 'test'
|
|
15
15
|
|
|
@@ -27,11 +27,11 @@ describe('DhtNodeRpcRemote', () => {
|
|
|
27
27
|
serverRpcCommunicator = new RpcCommunicator()
|
|
28
28
|
serverRpcCommunicator.registerRpcMethod(ClosestPeersRequest, ClosestPeersResponse, 'getClosestPeers', mockDhtRpc.getClosestPeers)
|
|
29
29
|
serverRpcCommunicator.registerRpcMethod(PingRequest, PingResponse, 'ping', mockDhtRpc.ping)
|
|
30
|
-
clientRpcCommunicator.
|
|
31
|
-
serverRpcCommunicator.handleIncomingMessage(message)
|
|
30
|
+
clientRpcCommunicator.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
31
|
+
serverRpcCommunicator.handleIncomingMessage(message, new DhtCallContext())
|
|
32
32
|
})
|
|
33
|
-
serverRpcCommunicator.
|
|
34
|
-
clientRpcCommunicator.handleIncomingMessage(message)
|
|
33
|
+
serverRpcCommunicator.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
34
|
+
clientRpcCommunicator.handleIncomingMessage(message, new DhtCallContext())
|
|
35
35
|
})
|
|
36
36
|
rpcRemote = new DhtNodeRpcRemote(clientPeerDescriptor, serverPeerDescriptor, SERVICE_ID, clientRpcCommunicator)
|
|
37
37
|
})
|
|
@@ -47,7 +47,7 @@ describe('DhtNodeRpcRemote', () => {
|
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
it('getClosestPeers happy path', async () => {
|
|
50
|
-
const neighbors = await rpcRemote.getClosestPeers(
|
|
50
|
+
const neighbors = await rpcRemote.getClosestPeers(toNodeId(clientPeerDescriptor))
|
|
51
51
|
expect(neighbors.length).toEqual(createMockPeers().length)
|
|
52
52
|
})
|
|
53
53
|
|
|
@@ -59,7 +59,7 @@ describe('DhtNodeRpcRemote', () => {
|
|
|
59
59
|
|
|
60
60
|
it('getClosestPeers error path', async () => {
|
|
61
61
|
serverRpcCommunicator.registerRpcMethod(ClosestPeersRequest, ClosestPeersResponse, 'getClosestPeers', mockDhtRpc.throwGetClosestPeersError)
|
|
62
|
-
await expect(rpcRemote.getClosestPeers(
|
|
62
|
+
await expect(rpcRemote.getClosestPeers(toNodeId(clientPeerDescriptor)))
|
|
63
63
|
.rejects.toThrow('Closest peers error')
|
|
64
64
|
})
|
|
65
65
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createMockDhtRpc, createMockPeerDescriptor, createMockPeers } from '../utils/utils'
|
|
2
2
|
import { ProtoRpcClient, RpcCommunicator, RpcError, toProtoRpcClient } from '@streamr/proto-rpc'
|
|
3
|
-
import { DhtNodeRpcClient } from '../../
|
|
4
|
-
import { ClosestPeersRequest, ClosestPeersResponse } from '../../
|
|
3
|
+
import { DhtNodeRpcClient } from '../../generated/packages/dht/protos/DhtRpc.client'
|
|
4
|
+
import { ClosestPeersRequest, ClosestPeersResponse } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { wait } from '@streamr/utils'
|
|
6
|
-
import { RpcMessage } from '../../
|
|
7
|
-
import {
|
|
6
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
7
|
+
import { toNodeId } from '../../src/identifiers'
|
|
8
8
|
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
9
9
|
|
|
10
10
|
describe('DhtRpc', () => {
|
|
@@ -18,8 +18,8 @@ describe('DhtRpc', () => {
|
|
|
18
18
|
const neighbors = createMockPeers()
|
|
19
19
|
const mockDhtRpc = createMockDhtRpc(neighbors)
|
|
20
20
|
|
|
21
|
-
const outgoingListener2 = (message: RpcMessage) => {
|
|
22
|
-
rpcCommunicator1.handleIncomingMessage(message)
|
|
21
|
+
const outgoingListener2 = async (message: RpcMessage) => {
|
|
22
|
+
rpcCommunicator1.handleIncomingMessage(message, new DhtCallContext())
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
beforeEach(() => {
|
|
@@ -29,11 +29,11 @@ describe('DhtRpc', () => {
|
|
|
29
29
|
rpcCommunicator2 = new RpcCommunicator()
|
|
30
30
|
rpcCommunicator2.registerRpcMethod(ClosestPeersRequest, ClosestPeersResponse, 'getClosestPeers', mockDhtRpc.getClosestPeers)
|
|
31
31
|
|
|
32
|
-
rpcCommunicator1.
|
|
33
|
-
rpcCommunicator2.handleIncomingMessage(message)
|
|
32
|
+
rpcCommunicator1.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
33
|
+
rpcCommunicator2.handleIncomingMessage(message, new DhtCallContext())
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
rpcCommunicator2.
|
|
36
|
+
rpcCommunicator2.setOutgoingMessageListener(outgoingListener2)
|
|
37
37
|
|
|
38
38
|
client1 = toProtoRpcClient(new DhtNodeRpcClient(rpcCommunicator1.getRpcClientTransport()))
|
|
39
39
|
client2 = toProtoRpcClient(new DhtNodeRpcClient(rpcCommunicator1.getRpcClientTransport()))
|
|
@@ -53,7 +53,7 @@ describe('DhtRpc', () => {
|
|
|
53
53
|
}
|
|
54
54
|
)
|
|
55
55
|
const res1 = await response1
|
|
56
|
-
expect(res1.peers.map((p) =>
|
|
56
|
+
expect(res1.peers.map((p) => toNodeId(p))).toEqual(neighbors.map((n) => toNodeId(n)))
|
|
57
57
|
|
|
58
58
|
const response2 = client2.getClosestPeers(
|
|
59
59
|
{ nodeId: peerDescriptor2.nodeId, requestId: '1' },
|
|
@@ -63,12 +63,11 @@ describe('DhtRpc', () => {
|
|
|
63
63
|
}
|
|
64
64
|
)
|
|
65
65
|
const res2 = await response2
|
|
66
|
-
expect(res2.peers.map((p) =>
|
|
66
|
+
expect(res2.peers.map((p) => toNodeId(p))).toEqual(neighbors.map((n) => toNodeId(n)))
|
|
67
67
|
})
|
|
68
68
|
|
|
69
69
|
it('Default RPC timeout, client side', async () => {
|
|
70
|
-
rpcCommunicator2.
|
|
71
|
-
rpcCommunicator2.on('outgoingMessage', async () => {
|
|
70
|
+
rpcCommunicator2.setOutgoingMessageListener(async () => {
|
|
72
71
|
await wait(3000)
|
|
73
72
|
})
|
|
74
73
|
const response2 = client2.getClosestPeers(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import { PeerDescriptor } from '../../
|
|
3
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { createMockConnectionDhtNode, waitForStableTopology } from '../utils/utils'
|
|
5
|
-
import {
|
|
5
|
+
import { toDhtAddress, toNodeId, toDhtAddressRaw } from '../../src/identifiers'
|
|
6
6
|
|
|
7
7
|
const NUM_NODES = 100
|
|
8
8
|
const K = 8
|
|
@@ -36,10 +36,10 @@ describe('Find correctness', () => {
|
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
it('Entrypoint can find a node from the network (exact match)', async () => {
|
|
39
|
-
const targetId =
|
|
40
|
-
const closestNodes = await entryPoint.findClosestNodesFromDht(
|
|
39
|
+
const targetId = toDhtAddressRaw(nodes[45].getNodeId())
|
|
40
|
+
const closestNodes = await entryPoint.findClosestNodesFromDht(toDhtAddress(targetId))
|
|
41
41
|
expect(closestNodes.length).toBeGreaterThanOrEqual(5)
|
|
42
|
-
expect(
|
|
42
|
+
expect(toDhtAddress(targetId)).toEqual(toNodeId(closestNodes[0]))
|
|
43
43
|
}, 90000)
|
|
44
44
|
|
|
45
45
|
})
|