@streamr/dht 101.1.1 → 102.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -1
- package/dist/{src/proto → generated}/google/protobuf/any.d.ts +11 -4
- package/dist/generated/google/protobuf/any.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/empty.d.ts +0 -1
- package/dist/generated/google/protobuf/empty.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/timestamp.d.ts +9 -3
- package/dist/generated/google/protobuf/timestamp.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.d.ts +9 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.js +7 -0
- package/dist/generated/packages/dht/protos/DhtRpc.client.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.d.ts +16 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.js +16 -2
- package/dist/generated/packages/dht/protos/DhtRpc.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.d.ts +5 -0
- package/dist/generated/packages/dht/protos/DhtRpc.server.js.map +1 -0
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js.map +1 -0
- package/dist/package.json +11 -11
- package/dist/src/connection/Connection.d.ts +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +5 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +9 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +3 -2
- package/dist/src/connection/ConnectionLockRpcRemote.js +14 -3
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionLockStates.d.ts +5 -0
- package/dist/src/connection/ConnectionLockStates.js +14 -0
- package/dist/src/connection/ConnectionLockStates.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +8 -1
- package/dist/src/connection/ConnectionManager.js +78 -24
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectionsView.d.ts +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +1 -1
- package/dist/src/connection/Handshaker.d.ts +1 -1
- package/dist/src/connection/Handshaker.js +2 -2
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +7 -1
- package/dist/src/connection/ManagedConnection.js +24 -1
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/PendingConnection.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.js +2 -1
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +1 -1
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.d.ts +1 -1
- package/dist/src/connection/simulator/Simulator.js +2 -2
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +9 -9
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +4 -4
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorTransport.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorTransport.js +2 -1
- package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +13 -6
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +2 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +9 -8
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +3 -3
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +4 -4
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +1 -0
- package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnector.js +3 -3
- package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +3 -3
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.js +7 -7
- package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +4 -2
- package/dist/src/dht/DhtNode.js +17 -6
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +2 -2
- package/dist/src/dht/DhtNodeRpcRemote.js +3 -3
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +1 -1
- package/dist/src/dht/PeerManager.js +10 -10
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/Contact.d.ts +1 -1
- package/dist/src/dht/contact/Contact.js +1 -1
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/RingContactList.d.ts +1 -1
- package/dist/src/dht/contact/RingContactList.js +1 -1
- package/dist/src/dht/contact/RingContactList.js.map +1 -1
- package/dist/src/dht/contact/RpcRemote.d.ts +1 -1
- package/dist/src/dht/contact/SortedContactList.js +1 -1
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/contact/ringIdentifiers.d.ts +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +1 -1
- package/dist/src/dht/discovery/DiscoverySession.js +3 -3
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.js +7 -7
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +8 -8
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +7 -7
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/Router.d.ts +4 -1
- package/dist/src/dht/routing/Router.js +17 -9
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcLocal.js +5 -5
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcRemote.js +7 -7
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +1 -1
- package/dist/src/dht/routing/RoutingSession.js +5 -6
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/getPreviousPeer.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.js +2 -2
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +2 -2
- package/dist/src/dht/store/StoreManager.js +8 -8
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/dist/src/dht/store/StoreRpcLocal.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcLocal.js +4 -4
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcRemote.js +7 -4
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +2 -2
- package/dist/src/exports.js +6 -6
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/Connectivity.d.ts +1 -1
- package/dist/src/helpers/Connectivity.js +1 -1
- package/dist/src/helpers/Connectivity.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptor.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptor.js +2 -2
- package/dist/src/helpers/createPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +1 -1
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/identifiers.d.ts +5 -5
- package/dist/src/identifiers.js +11 -11
- package/dist/src/identifiers.js.map +1 -1
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +1 -1
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +1 -1
- package/dist/src/transport/ITransport.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +13 -4
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +1 -1
- package/{src/proto → generated}/google/protobuf/any.ts +11 -4
- package/{src/proto → generated}/google/protobuf/empty.ts +0 -1
- package/{src/proto → generated}/google/protobuf/timestamp.ts +9 -3
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.client.ts +12 -0
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.server.ts +5 -0
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.ts +23 -1
- package/package.json +11 -11
- package/proto.sh +2 -3
- package/protos/DhtRpc.proto +5 -0
- package/src/connection/Connection.ts +1 -1
- package/src/connection/ConnectionLockRpcLocal.ts +16 -7
- package/src/connection/ConnectionLockRpcRemote.ts +18 -6
- package/src/connection/ConnectionLockStates.ts +18 -0
- package/src/connection/ConnectionManager.ts +92 -26
- package/src/connection/ConnectionsView.ts +1 -1
- package/src/connection/ConnectorFacade.ts +1 -1
- package/src/connection/Handshaker.ts +3 -3
- package/src/connection/ManagedConnection.ts +28 -3
- package/src/connection/PendingConnection.ts +1 -1
- package/src/connection/connectivityChecker.ts +2 -1
- package/src/connection/connectivityRequestHandler.ts +1 -1
- package/src/connection/simulator/Simulator.ts +4 -4
- package/src/connection/simulator/SimulatorConnection.ts +10 -10
- package/src/connection/simulator/SimulatorConnector.ts +5 -5
- package/src/connection/simulator/SimulatorTransport.ts +3 -2
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +10 -1
- package/src/connection/webrtc/NodeWebrtcConnection.ts +15 -9
- package/src/connection/webrtc/WebrtcConnector.ts +10 -8
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +8 -8
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +2 -2
- package/src/connection/websocket/WebsocketClientConnector.ts +5 -5
- package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +5 -5
- package/src/connection/websocket/WebsocketClientConnectorRpcRemote.ts +4 -4
- package/src/connection/websocket/WebsocketServerConnector.ts +8 -8
- package/src/dht/DhtNode.ts +21 -8
- package/src/dht/DhtNodeRpcLocal.ts +7 -7
- package/src/dht/DhtNodeRpcRemote.ts +5 -5
- package/src/dht/ExternalApiRpcLocal.ts +8 -8
- package/src/dht/ExternalApiRpcRemote.ts +6 -6
- package/src/dht/PeerManager.ts +12 -12
- package/src/dht/contact/Contact.ts +3 -3
- package/src/dht/contact/RingContactList.ts +3 -3
- package/src/dht/contact/RpcRemote.ts +1 -1
- package/src/dht/contact/SortedContactList.ts +2 -2
- package/src/dht/contact/ringIdentifiers.ts +1 -1
- package/src/dht/discovery/DiscoverySession.ts +5 -5
- package/src/dht/discovery/PeerDiscovery.ts +12 -12
- package/src/dht/discovery/RingDiscoverySession.ts +3 -3
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +9 -9
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +4 -4
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +6 -6
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +8 -8
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +5 -5
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +2 -2
- package/src/dht/routing/Router.ts +19 -10
- package/src/dht/routing/RouterRpcLocal.ts +7 -7
- package/src/dht/routing/RouterRpcRemote.ts +9 -9
- package/src/dht/routing/RoutingSession.ts +7 -8
- package/src/dht/routing/getPreviousPeer.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +4 -4
- package/src/dht/store/StoreManager.ts +12 -12
- package/src/dht/store/StoreRpcLocal.ts +8 -8
- package/src/dht/store/StoreRpcRemote.ts +10 -7
- package/src/exports.ts +5 -5
- package/src/helpers/Connectivity.ts +1 -1
- package/src/helpers/createPeerDescriptor.ts +3 -3
- package/src/helpers/createPeerDescriptorSignaturePayload.ts +1 -1
- package/src/helpers/protoClasses.ts +1 -1
- package/src/identifiers.ts +7 -7
- package/src/rpc-protocol/DhtCallContext.ts +1 -1
- package/src/rpc-protocol/DhtRpcOptions.ts +1 -1
- package/src/transport/ITransport.ts +2 -1
- package/src/transport/ListeningRpcCommunicator.ts +14 -6
- package/src/transport/RoutingRpcCommunicator.ts +2 -2
- package/test/benchmark/Find.test.ts +6 -6
- package/test/benchmark/KademliaCorrectness.test.ts +5 -5
- package/test/benchmark/RingCorrectness.test.ts +5 -5
- package/test/benchmark/SortedContactListBenchmark.test.ts +10 -10
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +1 -1
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +6 -6
- package/test/end-to-end/Layer0Webrtc.test.ts +6 -6
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +1 -1
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +1 -1
- package/test/end-to-end/memory-leak.test.ts +4 -4
- package/test/integration/ConnectionLocking.test.ts +16 -15
- package/test/integration/ConnectionManager.test.ts +62 -6
- package/test/integration/ConnectivityChecking.test.ts +2 -1
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNode.test.ts +4 -4
- package/test/integration/DhtNodeExternalAPI.test.ts +7 -7
- package/test/integration/DhtNodeRpcRemote.test.ts +9 -9
- package/test/integration/DhtRpc.test.ts +12 -13
- package/test/integration/Find.test.ts +5 -5
- package/test/integration/GeoIpConnectivityChecking.test.ts +2 -1
- package/test/integration/Layer1-scale.test.ts +2 -2
- package/test/integration/Mock-Layer1-Layer0.test.ts +6 -6
- package/test/integration/MultipleEntryPointJoining.test.ts +1 -1
- package/test/integration/ReplicateData.test.ts +10 -11
- package/test/integration/RouteMessage.test.ts +9 -9
- package/test/integration/RouterRpcRemote.test.ts +7 -7
- package/test/integration/SimultaneousConnections.test.ts +13 -12
- package/test/integration/Store.test.ts +9 -9
- package/test/integration/StoreAndDelete.test.ts +10 -10
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +9 -9
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +7 -7
- package/test/integration/StoreRpcRemote.test.ts +10 -10
- package/test/integration/WebrtcConnectionManagement.test.ts +4 -3
- package/test/integration/WebrtcConnectorRpc.test.ts +9 -9
- package/test/integration/Websocket.test.ts +0 -2
- package/test/integration/WebsocketClientConnectorRpc.test.ts +8 -8
- package/test/integration/WebsocketConnectionManagement.test.ts +8 -9
- package/test/integration/{rpc-connections-over-webrpc.test.ts → rpc-connections-over-webrtc.test.ts} +4 -3
- package/test/unit/ConnectionManager.test.ts +4 -3
- package/test/unit/ConnectivityHelpers.test.ts +1 -1
- package/test/unit/DiscoverySession.test.ts +6 -6
- package/test/unit/Handshaker.test.ts +1 -1
- package/test/unit/ListeningRpcCommunicator.test.ts +52 -0
- package/test/unit/LocalDataStore.test.ts +21 -21
- package/test/unit/PeerManager.test.ts +13 -13
- package/test/unit/PendingConnection.test.ts +1 -1
- package/test/unit/ProtobufMessage.test.ts +1 -1
- package/test/unit/RandomContactList.test.ts +2 -2
- package/test/unit/RecursiveOperationManager.test.ts +3 -3
- package/test/unit/RecursiveOperationSession.test.ts +4 -4
- package/test/unit/Router.test.ts +6 -6
- package/test/unit/RoutingSession.test.ts +6 -6
- package/test/unit/SortedContactList.test.ts +5 -5
- package/test/unit/StoreManager.test.ts +10 -10
- package/test/unit/StoreRpcLocal.test.ts +9 -9
- package/test/unit/WebrtcConnection.test.ts +29 -0
- package/test/unit/WebsocketClientConnector.test.ts +1 -1
- package/test/unit/WebsocketServerConnector.test.ts +1 -1
- package/test/unit/connectivityRequestHandler.test.ts +1 -1
- package/test/unit/createPeerDescriptor.test.ts +4 -4
- package/test/unit/getClosestNodes.test.ts +5 -5
- package/test/utils/FakeConnectorFacade.ts +1 -1
- package/test/utils/FakeTransport.ts +12 -9
- package/test/utils/customMatchers.ts +3 -3
- package/test/utils/mock/MockConnectionsView.ts +1 -1
- package/test/utils/mock/MockRouter.ts +5 -1
- package/test/utils/mock/MockTransport.ts +6 -1
- package/test/utils/mock/mockDataEntry.ts +6 -6
- package/test/utils/topology.ts +3 -3
- package/test/utils/utils.ts +9 -9
- package/tsconfig.jest.json +2 -1
- package/tsconfig.node.json +1 -0
- package/dist/src/proto/google/protobuf/any.js.map +0 -1
- package/dist/src/proto/google/protobuf/empty.js.map +0 -1
- package/dist/src/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +0 -1
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
- package/dist/src/proto/tests.d.ts +0 -39
- package/dist/src/proto/tests.js +0 -34
- package/dist/src/proto/tests.js.map +0 -1
- package/src/proto/tests.ts +0 -52
- package/test/benchmark/any.test.ts +0 -28
- /package/dist/{src/proto → generated}/google/protobuf/any.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/empty.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/timestamp.js +0 -0
- /package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.js +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.js +0 -0
- /package/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.ts +0 -0
- /package/{src/types/glogal.d.ts → test/types/global.d.ts} +0 -0
|
@@ -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
|
})
|
|
@@ -3,8 +3,8 @@ import { range, sample, sampleSize } from 'lodash'
|
|
|
3
3
|
import { DhtNodeRpcRemote } from '../../src/dht/DhtNodeRpcRemote'
|
|
4
4
|
import { PeerManager } from '../../src/dht/PeerManager'
|
|
5
5
|
import { getClosestNodes } from '../../src/dht/contact/getClosestNodes'
|
|
6
|
-
import { DhtAddress,
|
|
7
|
-
import { NodeType, PeerDescriptor } from '../../
|
|
6
|
+
import { DhtAddress, randomDhtAddress, toNodeId, toDhtAddressRaw } from '../../src/identifiers'
|
|
7
|
+
import { NodeType, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
8
8
|
import { MockRpcCommunicator } from '../utils/mock/MockRpcCommunicator'
|
|
9
9
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ const createDhtNodeRpcRemote = (
|
|
|
16
16
|
const remote = new class extends DhtNodeRpcRemote {
|
|
17
17
|
// eslint-disable-next-line class-methods-use-this
|
|
18
18
|
async ping(): Promise<boolean> {
|
|
19
|
-
return !pingFailures.has(
|
|
19
|
+
return !pingFailures.has(toNodeId(peerDescriptor))
|
|
20
20
|
}
|
|
21
21
|
}(localPeerDescriptor, peerDescriptor, undefined as any, new MockRpcCommunicator())
|
|
22
22
|
return remote
|
|
@@ -28,13 +28,13 @@ const createPeerManager = (
|
|
|
28
28
|
pingFailures: Set<DhtAddress> = new Set()
|
|
29
29
|
) => {
|
|
30
30
|
const manager = new PeerManager({
|
|
31
|
-
localNodeId:
|
|
31
|
+
localNodeId: toNodeId(localPeerDescriptor),
|
|
32
32
|
localPeerDescriptor: localPeerDescriptor,
|
|
33
33
|
isLayer0: true,
|
|
34
34
|
createDhtNodeRpcRemote: (peerDescriptor: PeerDescriptor) => createDhtNodeRpcRemote(peerDescriptor, localPeerDescriptor, pingFailures),
|
|
35
35
|
hasConnection: () => false
|
|
36
36
|
} as any)
|
|
37
|
-
const contacts = nodeIds.map((n) => ({ nodeId:
|
|
37
|
+
const contacts = nodeIds.map((n) => ({ nodeId: toDhtAddressRaw(n), type: NodeType.NODEJS }))
|
|
38
38
|
for (const contact of contacts) {
|
|
39
39
|
manager.addContact(contact)
|
|
40
40
|
}
|
|
@@ -44,29 +44,29 @@ const createPeerManager = (
|
|
|
44
44
|
describe('PeerManager', () => {
|
|
45
45
|
|
|
46
46
|
it('getNearbyContactCount', () => {
|
|
47
|
-
const nodeIds = range(10).map(() =>
|
|
47
|
+
const nodeIds = range(10).map(() => randomDhtAddress())
|
|
48
48
|
const manager = createPeerManager(nodeIds)
|
|
49
49
|
expect(manager.getNearbyContactCount()).toBe(10)
|
|
50
50
|
expect(manager.getNearbyContactCount(new Set(sampleSize(nodeIds, 2)))).toBe(8)
|
|
51
|
-
expect(manager.getNearbyContactCount(new Set([sample(nodeIds)!,
|
|
51
|
+
expect(manager.getNearbyContactCount(new Set([sample(nodeIds)!, randomDhtAddress()]))).toBe(9)
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
it('addContact: ping fails', async () => {
|
|
55
55
|
const localPeerDescriptor = createMockPeerDescriptor()
|
|
56
56
|
const successContacts = range(5).map(() => createMockPeerDescriptor())
|
|
57
57
|
const failureContact = createMockPeerDescriptor()
|
|
58
|
-
const manager = createPeerManager([], localPeerDescriptor, new Set([
|
|
58
|
+
const manager = createPeerManager([], localPeerDescriptor, new Set([toNodeId(failureContact)]))
|
|
59
59
|
for (const successContact of successContacts) {
|
|
60
60
|
manager.addContact(successContact)
|
|
61
|
-
manager.setContactActive(
|
|
62
|
-
manager.removeNeighbor(
|
|
61
|
+
manager.setContactActive(toNodeId(successContact))
|
|
62
|
+
manager.removeNeighbor(toNodeId(successContact))
|
|
63
63
|
}
|
|
64
64
|
expect(manager.getNeighborCount()).toBe(0)
|
|
65
65
|
manager.addContact(failureContact)
|
|
66
|
-
const closesSuccessContact = getClosestNodes(
|
|
66
|
+
const closesSuccessContact = getClosestNodes(toNodeId(localPeerDescriptor), successContacts)[0]
|
|
67
67
|
await waitForCondition(() => {
|
|
68
68
|
const neighborNodeIds = manager.getNeighbors().map((n) => n.getNodeId())
|
|
69
|
-
return neighborNodeIds.includes(
|
|
69
|
+
return neighborNodeIds.includes(toNodeId(closesSuccessContact))
|
|
70
70
|
})
|
|
71
71
|
expect(manager.getNeighborCount()).toBe(1)
|
|
72
72
|
expect(manager.getNeighbors()[0].getPeerDescriptor()).toEqualPeerDescriptor(closesSuccessContact)
|
|
@@ -83,7 +83,7 @@ describe('PeerManager', () => {
|
|
|
83
83
|
}
|
|
84
84
|
manager.addContact(failureContact)
|
|
85
85
|
expect(manager.getNeighborCount()).toBe(6)
|
|
86
|
-
failureSet.add(
|
|
86
|
+
failureSet.add(toNodeId(failureContact))
|
|
87
87
|
await manager.pruneOfflineNodes(
|
|
88
88
|
manager.getNeighbors().map((node) => createDhtNodeRpcRemote(node.getPeerDescriptor(), localPeerDescriptor, failureSet))
|
|
89
89
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
import { ProtobufMessage } from '../../src/protobufclasses/ProtobufMessage'
|
|
3
|
-
import { Message, RpcMessage } from '../../
|
|
3
|
+
import { Message, RpcMessage } from '../../generated/DhtRpc'
|
|
4
4
|
import { v4 } from 'uuid'
|
|
5
5
|
import { MessageType } from '@protobuf-ts/runtime'
|
|
6
6
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RandomContactList } from '../../src/dht/contact/RandomContactList'
|
|
2
|
-
import { DhtAddress, DhtAddressRaw,
|
|
2
|
+
import { DhtAddress, DhtAddressRaw, toDhtAddress } from '../../src/identifiers'
|
|
3
3
|
|
|
4
4
|
const createItem = (nodeId: DhtAddressRaw): { getNodeId: () => DhtAddress } => {
|
|
5
5
|
return {
|
|
6
|
-
getNodeId: () =>
|
|
6
|
+
getNodeId: () => toDhtAddress(nodeId)
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
RouteMessageError,
|
|
6
6
|
RouteMessageWrapper,
|
|
7
7
|
RecursiveOperationRequest
|
|
8
|
-
} from '../../
|
|
8
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
9
9
|
import {
|
|
10
10
|
createWrappedClosestPeersRequest,
|
|
11
11
|
createMockPeerDescriptor
|
|
@@ -18,7 +18,7 @@ import { MockTransport } from '../utils/mock/MockTransport'
|
|
|
18
18
|
import { FakeRpcCommunicator } from '../utils/FakeRpcCommunicator'
|
|
19
19
|
import { Router } from '../../src/dht/routing/Router'
|
|
20
20
|
import { ITransport } from '../../src/transport/ITransport'
|
|
21
|
-
import { areEqualPeerDescriptors,
|
|
21
|
+
import { areEqualPeerDescriptors, randomDhtAddress } from '../../src/identifiers'
|
|
22
22
|
import { MockConnectionsView } from '../utils/mock/MockConnectionsView'
|
|
23
23
|
|
|
24
24
|
const createMockRouter = (error?: RouteMessageError): Partial<Router> => {
|
|
@@ -94,7 +94,7 @@ describe('RecursiveOperationManager', () => {
|
|
|
94
94
|
|
|
95
95
|
it('find closest nodes returns self if no peers', async () => {
|
|
96
96
|
const recursiveOperationManager = createRecursiveOperationManager()
|
|
97
|
-
const res = await recursiveOperationManager.execute(
|
|
97
|
+
const res = await recursiveOperationManager.execute(randomDhtAddress(), RecursiveOperation.FIND_CLOSEST_NODES)
|
|
98
98
|
expect(areEqualPeerDescriptors(res.closestNodes[0], peerDescriptor1)).toEqual(true)
|
|
99
99
|
recursiveOperationManager.stop()
|
|
100
100
|
})
|
|
@@ -3,9 +3,9 @@ import { range } from 'lodash'
|
|
|
3
3
|
import { RecursiveOperationSession } from '../../src/dht/recursive-operation/RecursiveOperationSession'
|
|
4
4
|
import { RecursiveOperationSessionRpcRemote } from '../../src/dht/recursive-operation/RecursiveOperationSessionRpcRemote'
|
|
5
5
|
import { ServiceID } from '../../src/types/ServiceID'
|
|
6
|
-
import {
|
|
7
|
-
import { Message, PeerDescriptor, RecursiveOperation } from '../../
|
|
8
|
-
import { RecursiveOperationSessionRpcClient } from '../../
|
|
6
|
+
import { randomDhtAddress } from '../../src/identifiers'
|
|
7
|
+
import { Message, PeerDescriptor, RecursiveOperation } from '../../generated/packages/dht/protos/DhtRpc'
|
|
8
|
+
import { RecursiveOperationSessionRpcClient } from '../../generated/packages/dht/protos/DhtRpc.client'
|
|
9
9
|
import { RoutingRpcCommunicator } from '../../src/transport/RoutingRpcCommunicator'
|
|
10
10
|
import { FakeEnvironment } from '../utils/FakeTransport'
|
|
11
11
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
@@ -36,7 +36,7 @@ describe('RecursiveOperationSession', () => {
|
|
|
36
36
|
const doRouteRequest = jest.fn()
|
|
37
37
|
const session = new RecursiveOperationSession({
|
|
38
38
|
transport: environment.createTransport(localPeerDescriptor),
|
|
39
|
-
targetId:
|
|
39
|
+
targetId: randomDhtAddress(),
|
|
40
40
|
localPeerDescriptor,
|
|
41
41
|
waitedRoutingPathCompletions: 3,
|
|
42
42
|
operation: RecursiveOperation.FIND_CLOSEST_NODES,
|
package/test/unit/Router.test.ts
CHANGED
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
RouteMessageAck,
|
|
8
8
|
RouteMessageError,
|
|
9
9
|
RouteMessageWrapper
|
|
10
|
-
} from '../../
|
|
10
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
11
11
|
import { createMockPeerDescriptor, createWrappedClosestPeersRequest } from '../utils/utils'
|
|
12
12
|
import { FakeRpcCommunicator } from '../utils/FakeRpcCommunicator'
|
|
13
|
-
import { DhtAddress,
|
|
13
|
+
import { DhtAddress, toNodeId, randomDhtAddress } from '../../src/identifiers'
|
|
14
14
|
import { MockRpcCommunicator } from '../utils/mock/MockRpcCommunicator'
|
|
15
15
|
|
|
16
16
|
describe('Router', () => {
|
|
@@ -73,7 +73,7 @@ describe('Router', () => {
|
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
it('doRouteMessage with connections', async () => {
|
|
76
|
-
connections.set(
|
|
76
|
+
connections.set(randomDhtAddress(), createMockDhtNodeRpcRemote(peerDescriptor2))
|
|
77
77
|
const ack = await rpcCommunicator.callRpcMethod('routeMessage', {
|
|
78
78
|
message,
|
|
79
79
|
target: peerDescriptor2.nodeId,
|
|
@@ -87,7 +87,7 @@ describe('Router', () => {
|
|
|
87
87
|
})
|
|
88
88
|
|
|
89
89
|
it('doRouteMessage with parallelRootNodeIds', async () => {
|
|
90
|
-
const nodeId =
|
|
90
|
+
const nodeId = toNodeId(peerDescriptor2)
|
|
91
91
|
connections.set(nodeId, createMockDhtNodeRpcRemote(peerDescriptor2))
|
|
92
92
|
const ack = await rpcCommunicator.callRpcMethod('routeMessage', {
|
|
93
93
|
message,
|
|
@@ -107,7 +107,7 @@ describe('Router', () => {
|
|
|
107
107
|
})
|
|
108
108
|
|
|
109
109
|
it('route server with connections', async () => {
|
|
110
|
-
connections.set(
|
|
110
|
+
connections.set(randomDhtAddress(), createMockDhtNodeRpcRemote(peerDescriptor2))
|
|
111
111
|
const ack = await rpcCommunicator.callRpcMethod('routeMessage', routedMessage) as RouteMessageAck
|
|
112
112
|
expect(ack.error).toBeUndefined()
|
|
113
113
|
})
|
|
@@ -124,7 +124,7 @@ describe('Router', () => {
|
|
|
124
124
|
})
|
|
125
125
|
|
|
126
126
|
it('forward server with connections', async () => {
|
|
127
|
-
connections.set(
|
|
127
|
+
connections.set(randomDhtAddress(), createMockDhtNodeRpcRemote(peerDescriptor2))
|
|
128
128
|
const ack = await rpcCommunicator.callRpcMethod('forwardMessage', routedMessage) as RouteMessageAck
|
|
129
129
|
expect(ack.error).toBeUndefined()
|
|
130
130
|
})
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { v4 } from 'uuid'
|
|
2
2
|
import { RoutingMode, RoutingSession } from '../../src/dht/routing/RoutingSession'
|
|
3
|
-
import { Message, PeerDescriptor, RouteMessageWrapper } from '../../
|
|
3
|
+
import { Message, PeerDescriptor, RouteMessageWrapper } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { createMockPeerDescriptor, createWrappedClosestPeersRequest } from '../utils/utils'
|
|
5
5
|
import { DhtNodeRpcRemote } from '../../src/dht/DhtNodeRpcRemote'
|
|
6
6
|
import { RoutingRpcCommunicator } from '../../src/transport/RoutingRpcCommunicator'
|
|
7
|
-
import { DhtAddress,
|
|
7
|
+
import { DhtAddress, toNodeId } from '../../src/identifiers'
|
|
8
8
|
import { MockRpcCommunicator } from '../utils/mock/MockRpcCommunicator'
|
|
9
9
|
import { RoutingTablesCache } from '../../src/dht/routing/RoutingTablesCache'
|
|
10
10
|
|
|
@@ -63,16 +63,16 @@ describe('RoutingSession', () => {
|
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
it('findMoreContacts', () => {
|
|
66
|
-
connections.set(
|
|
66
|
+
connections.set(toNodeId(mockPeerDescriptor2), createMockDhtNodeRpcRemote(mockPeerDescriptor2))
|
|
67
67
|
const contacts = session.updateAndGetRoutablePeers()
|
|
68
68
|
expect(contacts.length).toBe(1)
|
|
69
69
|
})
|
|
70
70
|
|
|
71
71
|
it('findMoreContacts peer disconnects', () => {
|
|
72
|
-
connections.set(
|
|
72
|
+
connections.set(toNodeId(mockPeerDescriptor2), createMockDhtNodeRpcRemote(mockPeerDescriptor2))
|
|
73
73
|
expect(session.updateAndGetRoutablePeers().length).toBe(1)
|
|
74
|
-
connections.delete(
|
|
75
|
-
routingTablesCache.onNodeDisconnected(
|
|
74
|
+
connections.delete(toNodeId(mockPeerDescriptor2))
|
|
75
|
+
routingTablesCache.onNodeDisconnected(toNodeId(mockPeerDescriptor2))
|
|
76
76
|
expect(session.updateAndGetRoutablePeers().length).toBe(0)
|
|
77
77
|
})
|
|
78
78
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SortedContactList } from '../../src/dht/contact/SortedContactList'
|
|
2
|
-
import { DhtAddress, DhtAddressRaw,
|
|
2
|
+
import { DhtAddress, DhtAddressRaw, randomDhtAddress, toDhtAddress } from '../../src/identifiers'
|
|
3
3
|
|
|
4
4
|
const createItem = (nodeId: DhtAddressRaw): { getNodeId: () => DhtAddress } => {
|
|
5
5
|
return {
|
|
6
|
-
getNodeId: () =>
|
|
6
|
+
getNodeId: () => toDhtAddress(nodeId)
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -46,7 +46,7 @@ describe('SortedContactList', () => {
|
|
|
46
46
|
const list = new SortedContactList({ referenceId: item0.getNodeId(), maxSize: 8, allowToContainReferenceId: false })
|
|
47
47
|
const onContactRemoved = jest.fn()
|
|
48
48
|
list.on('contactRemoved', onContactRemoved)
|
|
49
|
-
list.removeContact(
|
|
49
|
+
list.removeContact(randomDhtAddress())
|
|
50
50
|
list.addContact(item3)
|
|
51
51
|
list.removeContact(item3.getNodeId())
|
|
52
52
|
list.addContact(item4)
|
|
@@ -58,10 +58,10 @@ describe('SortedContactList', () => {
|
|
|
58
58
|
expect(list.getContact(item2.getNodeId())).toBeFalsy()
|
|
59
59
|
expect(list.getContactIds()).toEqual(list.getContactIds().sort(list.compareIds))
|
|
60
60
|
expect(list.getClosestContacts()).toEqual([item1, item3, item4])
|
|
61
|
-
const ret = list.removeContact(
|
|
61
|
+
const ret = list.removeContact(toDhtAddress(Buffer.from([0, 0, 0, 6])))
|
|
62
62
|
expect(ret).toEqual(false)
|
|
63
63
|
list.removeContact(item3.getNodeId())
|
|
64
|
-
list.removeContact(
|
|
64
|
+
list.removeContact(randomDhtAddress())
|
|
65
65
|
expect(list.getClosestContacts()).toEqual([item1, item4])
|
|
66
66
|
expect(onContactRemoved).toHaveBeenNthCalledWith(1, item3)
|
|
67
67
|
expect(onContactRemoved).toHaveBeenNthCalledWith(2, item2)
|
|
@@ -4,23 +4,23 @@ import { getClosestNodes } from '../../src/dht/contact/getClosestNodes'
|
|
|
4
4
|
import { StoreManager } from '../../src/dht/store/StoreManager'
|
|
5
5
|
import {
|
|
6
6
|
DhtAddress,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
randomDhtAddress,
|
|
8
|
+
toDhtAddress,
|
|
9
|
+
toDhtAddressRaw
|
|
10
10
|
} from '../../src/identifiers'
|
|
11
|
-
import { PeerDescriptor, ReplicateDataRequest } from '../../
|
|
11
|
+
import { PeerDescriptor, ReplicateDataRequest } from '../../generated/packages/dht/protos/DhtRpc'
|
|
12
12
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
13
13
|
|
|
14
14
|
const NODE_COUNT = 10
|
|
15
15
|
|
|
16
16
|
const DATA_ENTRY = {
|
|
17
|
-
key:
|
|
18
|
-
creator:
|
|
17
|
+
key: toDhtAddressRaw(randomDhtAddress()),
|
|
18
|
+
creator: toDhtAddressRaw(randomDhtAddress())
|
|
19
19
|
}
|
|
20
20
|
const ALL_NODES = range(NODE_COUNT).map(() => createMockPeerDescriptor())
|
|
21
21
|
|
|
22
22
|
const getNodeCloseToData = (distanceIndex: number) => {
|
|
23
|
-
const dataKey =
|
|
23
|
+
const dataKey = toDhtAddress(DATA_ENTRY.key)
|
|
24
24
|
return getClosestNodes(dataKey, ALL_NODES)[distanceIndex]
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -42,7 +42,7 @@ describe('StoreManager', () => {
|
|
|
42
42
|
recursiveOperationManager: undefined as any,
|
|
43
43
|
localPeerDescriptor,
|
|
44
44
|
localDataStore: {
|
|
45
|
-
keys: () => [
|
|
45
|
+
keys: () => [toDhtAddress(DATA_ENTRY.key)],
|
|
46
46
|
values: () => [DATA_ENTRY],
|
|
47
47
|
setAllEntriesAsStale
|
|
48
48
|
} as any,
|
|
@@ -70,7 +70,7 @@ describe('StoreManager', () => {
|
|
|
70
70
|
await waitForCondition(() => replicateData.mock.calls.length === 1)
|
|
71
71
|
expect(replicateData).toHaveBeenCalledWith({
|
|
72
72
|
entry: DATA_ENTRY
|
|
73
|
-
})
|
|
73
|
+
}, true)
|
|
74
74
|
expect(setAllEntriesAsStale).not.toHaveBeenCalled()
|
|
75
75
|
})
|
|
76
76
|
|
|
@@ -123,7 +123,7 @@ describe('StoreManager', () => {
|
|
|
123
123
|
await wait(50)
|
|
124
124
|
expect(replicateData).not.toHaveBeenCalled()
|
|
125
125
|
expect(setAllEntriesAsStale).toHaveBeenCalledTimes(1)
|
|
126
|
-
expect(setAllEntriesAsStale).toHaveBeenCalledWith(
|
|
126
|
+
expect(setAllEntriesAsStale).toHaveBeenCalledWith(toDhtAddress(DATA_ENTRY.key))
|
|
127
127
|
})
|
|
128
128
|
|
|
129
129
|
it('this node is within redundancy factor, the node has less than redundancyFactor neighbors', async () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { range } from 'lodash'
|
|
2
2
|
import { StoreRpcLocal } from '../../src/dht/store/StoreRpcLocal'
|
|
3
|
-
import { areEqualPeerDescriptors,
|
|
4
|
-
import { DataEntry, PeerDescriptor, StoreDataRequest } from '../../
|
|
3
|
+
import { areEqualPeerDescriptors, randomDhtAddress, DhtAddress, toDhtAddress, toDhtAddressRaw } from '../../src/identifiers'
|
|
4
|
+
import { DataEntry, PeerDescriptor, StoreDataRequest } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
6
|
import { getClosestNodes } from '../../src/dht/contact/getClosestNodes'
|
|
7
7
|
import { wait } from '@streamr/utils'
|
|
@@ -10,14 +10,14 @@ describe('StoreRpcLocal', () => {
|
|
|
10
10
|
|
|
11
11
|
const NODE_COUNT = 5
|
|
12
12
|
const DATA_ENTRY = {
|
|
13
|
-
key:
|
|
14
|
-
creator:
|
|
13
|
+
key: toDhtAddressRaw(randomDhtAddress()),
|
|
14
|
+
creator: toDhtAddressRaw(randomDhtAddress())
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const ALL_NODES = range(NODE_COUNT).map(() => createMockPeerDescriptor())
|
|
18
18
|
|
|
19
19
|
const getNodeCloseToData = (distanceIndex: number) => {
|
|
20
|
-
const dataKey =
|
|
20
|
+
const dataKey = toDhtAddress(DATA_ENTRY.key)
|
|
21
21
|
return getClosestNodes(dataKey, ALL_NODES)[distanceIndex]
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -41,7 +41,7 @@ describe('StoreRpcLocal', () => {
|
|
|
41
41
|
} as any,
|
|
42
42
|
localPeerDescriptor,
|
|
43
43
|
replicateDataToContact,
|
|
44
|
-
getStorers: () => getClosestNodes(
|
|
44
|
+
getStorers: () => getClosestNodes(toDhtAddress(DATA_ENTRY.key), ALL_NODES)
|
|
45
45
|
})
|
|
46
46
|
})
|
|
47
47
|
|
|
@@ -76,7 +76,7 @@ describe('StoreRpcLocal', () => {
|
|
|
76
76
|
} as any,
|
|
77
77
|
localPeerDescriptor,
|
|
78
78
|
replicateDataToContact,
|
|
79
|
-
getStorers: () => getClosestNodes(
|
|
79
|
+
getStorers: () => getClosestNodes(toDhtAddress(DATA_ENTRY.key), ALL_NODES)
|
|
80
80
|
})
|
|
81
81
|
})
|
|
82
82
|
|
|
@@ -110,7 +110,7 @@ describe('StoreRpcLocal', () => {
|
|
|
110
110
|
} as any,
|
|
111
111
|
localPeerDescriptor,
|
|
112
112
|
replicateDataToContact,
|
|
113
|
-
getStorers: () => getClosestNodes(
|
|
113
|
+
getStorers: () => getClosestNodes(toDhtAddress(DATA_ENTRY.key), ALL_NODES)
|
|
114
114
|
.filter((peerDescriptor) => !areEqualPeerDescriptors(peerDescriptor, localPeerDescriptor))
|
|
115
115
|
})
|
|
116
116
|
})
|
|
@@ -147,7 +147,7 @@ describe('StoreRpcLocal', () => {
|
|
|
147
147
|
} as any,
|
|
148
148
|
localPeerDescriptor,
|
|
149
149
|
replicateDataToContact,
|
|
150
|
-
getStorers: () => getClosestNodes(
|
|
150
|
+
getStorers: () => getClosestNodes(toDhtAddress(DATA_ENTRY.key), ALL_NODES)
|
|
151
151
|
})
|
|
152
152
|
})
|
|
153
153
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { waitForEvent3 } from '@streamr/utils'
|
|
2
|
+
import { NodeWebrtcConnection } from '../../src/connection/webrtc/NodeWebrtcConnection'
|
|
3
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
4
|
+
import { ConnectionEvents } from '../../src/connection/IConnection'
|
|
5
|
+
|
|
6
|
+
describe('WebrtcConnection', () => {
|
|
7
|
+
|
|
8
|
+
let connection: NodeWebrtcConnection
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
const peerDescriptor = createMockPeerDescriptor()
|
|
12
|
+
connection = new NodeWebrtcConnection({
|
|
13
|
+
remotePeerDescriptor: peerDescriptor
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
connection.close(true)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('Disconnects early if remote descriptor is not set', async () => {
|
|
22
|
+
connection.start(true)
|
|
23
|
+
await waitForEvent3<ConnectionEvents>(connection as any, 'disconnected', 5001, (_graceful: boolean, _code: number, reason: string) => {
|
|
24
|
+
expect(reason).toBe('timed out due to remote descriptor not being set')
|
|
25
|
+
return true
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
import { WebsocketClientConnector } from '../../src/connection/websocket/WebsocketClientConnector'
|
|
3
|
-
import { NodeType } from '../../
|
|
3
|
+
import { NodeType } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { MockConnection } from '../utils/mock/MockConnection'
|
|
5
5
|
import { MockRpcCommunicator } from '../utils/mock/MockRpcCommunicator'
|
|
6
6
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
import { WebsocketServerConnector } from '../../src/connection/websocket/WebsocketServerConnector'
|
|
3
|
-
import { NodeType } from '../../
|
|
3
|
+
import { NodeType } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { MockConnection } from '../utils/mock/MockConnection'
|
|
5
5
|
import { MockRpcCommunicator } from '../utils/mock/MockRpcCommunicator'
|
|
6
6
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
@@ -5,7 +5,7 @@ import { Server as HttpServer, createServer as createHttpServer } from 'http'
|
|
|
5
5
|
import { server as WsServer } from 'websocket'
|
|
6
6
|
import { CONNECTIVITY_CHECKER_SERVICE_ID } from '../../src/connection/connectivityChecker'
|
|
7
7
|
import { attachConnectivityRequestHandler } from '../../src/connection/connectivityRequestHandler'
|
|
8
|
-
import { Message } from '../../
|
|
8
|
+
import { Message } from '../../generated/packages/dht/protos/DhtRpc'
|
|
9
9
|
import { LOCAL_PROTOCOL_VERSION } from '../../src/helpers/version'
|
|
10
10
|
|
|
11
11
|
const HOST = '127.0.0.1'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ipv4ToNumber } from '@streamr/utils'
|
|
2
2
|
import { createPeerDescriptor } from '../../src/helpers/createPeerDescriptor'
|
|
3
3
|
import { isBrowserEnvironment } from '../../src/helpers/browser/isBrowserEnvironment'
|
|
4
|
-
import { NodeType } from '../../
|
|
5
|
-
import {
|
|
4
|
+
import { NodeType } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
|
+
import { randomDhtAddress, toDhtAddressRaw } from '../../src/identifiers'
|
|
6
6
|
import { getRandomRegion } from '../../dist/src/connection/simulator/pings'
|
|
7
7
|
|
|
8
8
|
const IP_ADDRESS = '1.2.3.4'
|
|
@@ -52,13 +52,13 @@ describe('createPeerDescriptor', () => {
|
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
it('explicit nodeId', () => {
|
|
55
|
-
const nodeId =
|
|
55
|
+
const nodeId = randomDhtAddress()
|
|
56
56
|
const connectivityResponse = {
|
|
57
57
|
ipAddress: ipv4ToNumber(IP_ADDRESS)
|
|
58
58
|
} as any
|
|
59
59
|
const peerDescriptor = createPeerDescriptor(connectivityResponse, region, nodeId)
|
|
60
60
|
expect(peerDescriptor).toEqual({
|
|
61
|
-
nodeId:
|
|
61
|
+
nodeId: toDhtAddressRaw(nodeId),
|
|
62
62
|
type: isBrowserEnvironment() ? NodeType.BROWSER : NodeType.NODEJS,
|
|
63
63
|
ipAddress: ipv4ToNumber(IP_ADDRESS),
|
|
64
64
|
publicKey: expect.any(Uint8Array),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { range, sampleSize, sortBy } from 'lodash'
|
|
2
2
|
import { getDistance } from '../../src/dht/PeerManager'
|
|
3
3
|
import { getClosestNodes } from '../../src/dht/contact/getClosestNodes'
|
|
4
|
-
import { DhtAddress,
|
|
4
|
+
import { DhtAddress, randomDhtAddress, toNodeId, toDhtAddressRaw } from '../../src/identifiers'
|
|
5
5
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
6
|
import { PeerDescriptor } from '../../src/exports'
|
|
7
7
|
|
|
@@ -9,8 +9,8 @@ describe('getClosestNodes', () => {
|
|
|
9
9
|
|
|
10
10
|
it('happy path', () => {
|
|
11
11
|
const peerDescriptors = range(10).map(() => createMockPeerDescriptor())
|
|
12
|
-
const referenceId =
|
|
13
|
-
const excluded = new Set<DhtAddress>(sampleSize(peerDescriptors.map((n) =>
|
|
12
|
+
const referenceId = randomDhtAddress()
|
|
13
|
+
const excluded = new Set<DhtAddress>(sampleSize(peerDescriptors.map((n) => toNodeId(n), 2)))
|
|
14
14
|
|
|
15
15
|
const actual = getClosestNodes(
|
|
16
16
|
referenceId,
|
|
@@ -22,8 +22,8 @@ describe('getClosestNodes', () => {
|
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
const expected = sortBy(
|
|
25
|
-
peerDescriptors.filter((n) => !excluded.has(
|
|
26
|
-
(peerDescriptor: PeerDescriptor) => getDistance(peerDescriptor.nodeId,
|
|
25
|
+
peerDescriptors.filter((n) => !excluded.has(toNodeId(n))),
|
|
26
|
+
(peerDescriptor: PeerDescriptor) => getDistance(peerDescriptor.nodeId, toDhtAddressRaw(referenceId))
|
|
27
27
|
).slice(0, 5)
|
|
28
28
|
expect(actual).toEqual(expected)
|
|
29
29
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PendingConnection } from '../../src/connection/PendingConnection'
|
|
2
2
|
import { DhtAddress } from '../../src/identifiers'
|
|
3
|
-
import { PeerDescriptor } from '../../
|
|
3
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { ITransport } from '../../src/transport/ITransport'
|
|
5
5
|
|
|
6
6
|
export class FakeConnectorFacade {
|