@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
|
@@ -8,12 +8,12 @@ import { LOCAL_PROTOCOL_VERSION } from '../../src/helpers/version'
|
|
|
8
8
|
import { WebsocketServerConnection } from '../../src/connection/websocket/WebsocketServerConnection'
|
|
9
9
|
import fs from 'fs'
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
const testIp = '
|
|
11
|
+
// helsinki.fi
|
|
12
|
+
const testIp = '128.214.222.50'
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
const testLatitude =
|
|
16
|
-
const testLongitude =
|
|
14
|
+
// Helsinki, Finland
|
|
15
|
+
const testLatitude = 60.1719
|
|
16
|
+
const testLongitude = 24.9347
|
|
17
17
|
|
|
18
18
|
const dbPath = '/tmp/geoipdatabasesintegration'
|
|
19
19
|
|
|
@@ -43,7 +43,8 @@ describe('ConnectivityChecking', () => {
|
|
|
43
43
|
transport: new MockTransport(),
|
|
44
44
|
geoIpDatabaseFolder: dbPath
|
|
45
45
|
}),
|
|
46
|
-
metricsContext: new MetricsContext()
|
|
46
|
+
metricsContext: new MetricsContext(),
|
|
47
|
+
allowIncomingPrivateConnections: false
|
|
47
48
|
})
|
|
48
49
|
await server.start()
|
|
49
50
|
mock = jest.spyOn(WebsocketServerConnection.prototype, 'getRemoteIpAddress').mockImplementation(() => testIp)
|
|
@@ -64,7 +65,7 @@ describe('ConnectivityChecking', () => {
|
|
|
64
65
|
allowSelfSignedCertificate: false
|
|
65
66
|
}
|
|
66
67
|
const response = await sendConnectivityRequest(request, server.getLocalPeerDescriptor())
|
|
67
|
-
expect(response.
|
|
68
|
+
expect(response.protocolVersion).toEqual(LOCAL_PROTOCOL_VERSION)
|
|
68
69
|
expect(response.latitude).toEqual(testLatitude)
|
|
69
70
|
expect(response.longitude).toEqual(testLongitude)
|
|
70
71
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import {
|
|
3
|
+
import { toDhtAddress } from '../../src/identifiers'
|
|
4
4
|
import { createMockConnectionDhtNode, createMockConnectionLayer1Node, createMockPeerDescriptor } from '../utils/utils'
|
|
5
5
|
|
|
6
6
|
const NODE_COUNT = 48
|
|
@@ -16,7 +16,7 @@ describe('Layer1', () => {
|
|
|
16
16
|
|
|
17
17
|
beforeEach(async () => {
|
|
18
18
|
simulator = new Simulator()
|
|
19
|
-
layer0EntryPoint = await createMockConnectionDhtNode(simulator,
|
|
19
|
+
layer0EntryPoint = await createMockConnectionDhtNode(simulator, toDhtAddress(entryPoint0Descriptor.nodeId))
|
|
20
20
|
await layer0EntryPoint.joinDht([entryPoint0Descriptor])
|
|
21
21
|
|
|
22
22
|
nodes = []
|
|
@@ -178,7 +178,7 @@ describe('Layer1', () => {
|
|
|
178
178
|
// })
|
|
179
179
|
// })
|
|
180
180
|
//
|
|
181
|
-
// await
|
|
181
|
+
// await until(() => {
|
|
182
182
|
// return [...receivedMessages.values()].every((set) => {
|
|
183
183
|
// return set.size === receivedMessages.size - 1
|
|
184
184
|
// })
|
|
@@ -2,7 +2,7 @@ import { Logger } from '@streamr/utils'
|
|
|
2
2
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
4
|
import { createMockConnectionDhtNode, createMockConnectionLayer1Node } from '../utils/utils'
|
|
5
|
-
import {
|
|
5
|
+
import { randomDhtAddress } from '../../src/identifiers'
|
|
6
6
|
|
|
7
7
|
const logger = new Logger(module)
|
|
8
8
|
|
|
@@ -22,11 +22,11 @@ describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
|
22
22
|
|
|
23
23
|
beforeEach(async () => {
|
|
24
24
|
|
|
25
|
-
layer0EntryPoint = await createMockConnectionDhtNode(simulator,
|
|
26
|
-
layer0Node1 = await createMockConnectionDhtNode(simulator,
|
|
27
|
-
layer0Node2 = await createMockConnectionDhtNode(simulator,
|
|
28
|
-
layer0Node3 = await createMockConnectionDhtNode(simulator,
|
|
29
|
-
layer0Node4 = await createMockConnectionDhtNode(simulator,
|
|
25
|
+
layer0EntryPoint = await createMockConnectionDhtNode(simulator, randomDhtAddress())
|
|
26
|
+
layer0Node1 = await createMockConnectionDhtNode(simulator, randomDhtAddress())
|
|
27
|
+
layer0Node2 = await createMockConnectionDhtNode(simulator, randomDhtAddress())
|
|
28
|
+
layer0Node3 = await createMockConnectionDhtNode(simulator, randomDhtAddress())
|
|
29
|
+
layer0Node4 = await createMockConnectionDhtNode(simulator, randomDhtAddress())
|
|
30
30
|
|
|
31
31
|
layer1EntryPoint = await createMockConnectionLayer1Node(layer0EntryPoint)
|
|
32
32
|
|
|
@@ -1,6 +1,6 @@
|
|
|
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 } from '../utils/utils'
|
|
5
5
|
|
|
6
6
|
describe('multiple entry point joining', () => {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
3
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
3
|
import { createMockConnectionDhtNode, waitForStableTopology } from '../utils/utils'
|
|
5
4
|
import { SortedContactList } from '../../src/dht/contact/SortedContactList'
|
|
6
5
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
7
|
-
import { DhtAddress,
|
|
6
|
+
import { DhtAddress, randomDhtAddress, toDhtAddress, toNodeId } from '../../src/identifiers'
|
|
8
7
|
import { sample } from 'lodash'
|
|
9
|
-
import { DataEntry, PeerDescriptor } from '../../
|
|
8
|
+
import { DataEntry, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
10
9
|
|
|
11
10
|
const DATA = createMockDataEntry()
|
|
12
11
|
const NUM_NODES = 100
|
|
@@ -17,7 +16,7 @@ const ENTRY_POINT_INDEX = 0
|
|
|
17
16
|
const getDataEntries = (node: DhtNode): DataEntry[] => {
|
|
18
17
|
// @ts-expect-error private field
|
|
19
18
|
const store = node.localDataStore
|
|
20
|
-
return Array.from(store.values(
|
|
19
|
+
return Array.from(store.values(toDhtAddress(DATA.key)))
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
describe('Replicate data from node to node in DHT', () => {
|
|
@@ -27,7 +26,7 @@ describe('Replicate data from node to node in DHT', () => {
|
|
|
27
26
|
const simulator = new Simulator(LatencyType.FIXED, 20)
|
|
28
27
|
|
|
29
28
|
beforeEach(async () => {
|
|
30
|
-
const entryPoint = await createMockConnectionDhtNode(simulator,
|
|
29
|
+
const entryPoint = await createMockConnectionDhtNode(simulator, randomDhtAddress(), K, MAX_CONNECTIONS)
|
|
31
30
|
entryPointDescriptor = entryPoint.getLocalPeerDescriptor()
|
|
32
31
|
await entryPoint.joinDht([entryPointDescriptor])
|
|
33
32
|
nodes = []
|
|
@@ -35,7 +34,7 @@ describe('Replicate data from node to node in DHT', () => {
|
|
|
35
34
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
36
35
|
const node = await createMockConnectionDhtNode(
|
|
37
36
|
simulator,
|
|
38
|
-
|
|
37
|
+
randomDhtAddress(),
|
|
39
38
|
K,
|
|
40
39
|
MAX_CONNECTIONS
|
|
41
40
|
)
|
|
@@ -54,14 +53,14 @@ describe('Replicate data from node to node in DHT', () => {
|
|
|
54
53
|
it('Data replicates to the closest node no matter where it is stored', async () => {
|
|
55
54
|
// calculate offline which node is closest to the data
|
|
56
55
|
const sortedList = new SortedContactList<DhtNode>({
|
|
57
|
-
referenceId:
|
|
56
|
+
referenceId: toDhtAddress(DATA.key),
|
|
58
57
|
maxSize: 10000,
|
|
59
58
|
allowToContainReferenceId: true
|
|
60
59
|
})
|
|
61
60
|
nodes.forEach((node) => sortedList.addContact(node))
|
|
62
61
|
|
|
63
62
|
const closest = sortedList.getClosestContacts()
|
|
64
|
-
const successfulStorers = await nodes[0].storeDataToDht(
|
|
63
|
+
const successfulStorers = await nodes[0].storeDataToDht(toDhtAddress(DATA.key), DATA.data!)
|
|
65
64
|
expect(successfulStorers.length).toBe(1)
|
|
66
65
|
|
|
67
66
|
await Promise.all(
|
|
@@ -89,16 +88,16 @@ describe('Replicate data from node to node in DHT', () => {
|
|
|
89
88
|
await waitForStableTopology(nodes)
|
|
90
89
|
|
|
91
90
|
const randomIndex = Math.floor(Math.random() * nodes.length)
|
|
92
|
-
const storerDescriptors = await nodes[randomIndex].storeDataToDht(
|
|
91
|
+
const storerDescriptors = await nodes[randomIndex].storeDataToDht(toDhtAddress(DATA.key), DATA.data!)
|
|
93
92
|
const stoppedNodeIds: DhtAddress[] = []
|
|
94
93
|
await Promise.all(storerDescriptors.map(async (storerDescriptor) => {
|
|
95
|
-
const storer = nodes.find((n) => n.getNodeId() ===
|
|
94
|
+
const storer = nodes.find((n) => n.getNodeId() === toNodeId(storerDescriptor))!
|
|
96
95
|
await storer.stop()
|
|
97
96
|
stoppedNodeIds.push(storer.getNodeId())
|
|
98
97
|
}))
|
|
99
98
|
|
|
100
99
|
const randomNonStoppedNode = sample(nodes.filter((n) => !stoppedNodeIds.includes(n.getNodeId())))!
|
|
101
|
-
const data = await randomNonStoppedNode.fetchDataFromDht(
|
|
100
|
+
const data = await randomNonStoppedNode.fetchDataFromDht(toDhtAddress(DATA.key))
|
|
102
101
|
expect(data).toHaveLength(1)
|
|
103
102
|
expectEqualData(data[0], DATA)
|
|
104
103
|
}, 180000)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { DhtNode, Events as DhtNodeEvents } from '../../src/dht/DhtNode'
|
|
2
|
-
import { Message, NodeType, PeerDescriptor, RouteMessageWrapper } from '../../
|
|
3
|
-
import { RpcMessage } from '../../
|
|
4
|
-
import { Logger, runAndWaitForEvents3,
|
|
2
|
+
import { Message, NodeType, PeerDescriptor, RouteMessageWrapper } from '../../generated/packages/dht/protos/DhtRpc'
|
|
3
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
4
|
+
import { Logger, runAndWaitForEvents3, until } from '@streamr/utils'
|
|
5
5
|
import { createMockConnectionDhtNode, createWrappedClosestPeersRequest } from '../utils/utils'
|
|
6
6
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
7
7
|
import { v4 } from 'uuid'
|
|
8
|
-
import { Any } from '../../
|
|
8
|
+
import { Any } from '../../generated/google/protobuf/any'
|
|
9
9
|
import { RoutingMode } from '../../src/dht/routing/RoutingSession'
|
|
10
|
-
import { DhtAddress,
|
|
10
|
+
import { DhtAddress, randomDhtAddress, toDhtAddressRaw } from '../../src/identifiers'
|
|
11
11
|
|
|
12
12
|
const logger = new Logger(module)
|
|
13
13
|
|
|
@@ -25,18 +25,18 @@ describe('Route Message With Mock Connections', () => {
|
|
|
25
25
|
beforeEach(async () => {
|
|
26
26
|
routerNodes = []
|
|
27
27
|
simulator = new Simulator()
|
|
28
|
-
entryPoint = await createMockConnectionDhtNode(simulator,
|
|
28
|
+
entryPoint = await createMockConnectionDhtNode(simulator, randomDhtAddress())
|
|
29
29
|
|
|
30
30
|
entryPointDescriptor = {
|
|
31
|
-
nodeId:
|
|
31
|
+
nodeId: toDhtAddressRaw(entryPoint.getNodeId()),
|
|
32
32
|
type: NodeType.NODEJS
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
sourceNode = await createMockConnectionDhtNode(simulator,
|
|
36
|
-
destinationNode = await createMockConnectionDhtNode(simulator,
|
|
35
|
+
sourceNode = await createMockConnectionDhtNode(simulator, randomDhtAddress())
|
|
36
|
+
destinationNode = await createMockConnectionDhtNode(simulator, randomDhtAddress())
|
|
37
37
|
|
|
38
38
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
39
|
-
const node = await createMockConnectionDhtNode(simulator,
|
|
39
|
+
const node = await createMockConnectionDhtNode(simulator, randomDhtAddress())
|
|
40
40
|
routerNodes.push(node)
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -116,7 +116,7 @@ describe('Route Message With Mock Connections', () => {
|
|
|
116
116
|
parallelRootNodeIds: []
|
|
117
117
|
})
|
|
118
118
|
}
|
|
119
|
-
await
|
|
119
|
+
await until(() => receivedMessages === messageCount)
|
|
120
120
|
})
|
|
121
121
|
|
|
122
122
|
it('From all to all', async () => {
|
|
@@ -157,10 +157,10 @@ describe('Route Message With Mock Connections', () => {
|
|
|
157
157
|
}))
|
|
158
158
|
)
|
|
159
159
|
)
|
|
160
|
-
await
|
|
160
|
+
await until(() => receivedMessageCounts[routerNodes[0].getNodeId()] >= routerNodes.length - 1, 30000)
|
|
161
161
|
await Promise.all(
|
|
162
162
|
Object.keys(receivedMessageCounts).map(async (key) =>
|
|
163
|
-
|
|
163
|
+
until(() => receivedMessageCounts[key as DhtAddress] >= routerNodes.length - 1, 30000)
|
|
164
164
|
)
|
|
165
165
|
)
|
|
166
166
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RpcCommunicator } from '@streamr/proto-rpc'
|
|
2
2
|
import { RouterRpcRemote } from '../../src/dht/routing/RouterRpcRemote'
|
|
3
|
-
import { Message, RouteMessageAck, RouteMessageWrapper } from '../../
|
|
4
|
-
import { RouterRpcClient } from '../../
|
|
5
|
-
import { RpcMessage } from '../../
|
|
3
|
+
import { Message, RouteMessageAck, RouteMessageWrapper } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
|
+
import { RouterRpcClient } from '../../generated/packages/dht/protos/DhtRpc.client'
|
|
5
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
6
6
|
import { createMockPeerDescriptor, createWrappedClosestPeersRequest, mockRouterRpc } from '../utils/utils'
|
|
7
7
|
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
8
8
|
|
|
@@ -20,11 +20,11 @@ describe('RemoteRouter', () => {
|
|
|
20
20
|
clientRpcCommunicator = new RpcCommunicator()
|
|
21
21
|
serverRpcCommunicator = new RpcCommunicator()
|
|
22
22
|
serverRpcCommunicator.registerRpcMethod(RouteMessageWrapper, RouteMessageAck, 'routeMessage', mockRouterRpc.routeMessage)
|
|
23
|
-
clientRpcCommunicator.
|
|
24
|
-
serverRpcCommunicator.handleIncomingMessage(message)
|
|
23
|
+
clientRpcCommunicator.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
24
|
+
serverRpcCommunicator.handleIncomingMessage(message, new DhtCallContext())
|
|
25
25
|
})
|
|
26
|
-
serverRpcCommunicator.
|
|
27
|
-
clientRpcCommunicator.handleIncomingMessage(message)
|
|
26
|
+
serverRpcCommunicator.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
27
|
+
clientRpcCommunicator.handleIncomingMessage(message, new DhtCallContext())
|
|
28
28
|
})
|
|
29
29
|
remoteRouter = new RouterRpcRemote(clientPeerDescriptor, serverPeerDescriptor, clientRpcCommunicator, RouterRpcClient)
|
|
30
30
|
})
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { MetricsContext,
|
|
1
|
+
import { MetricsContext, until } from '@streamr/utils'
|
|
2
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
3
3
|
import { DefaultConnectorFacade, DefaultConnectorFacadeOptions } from '../../src/connection/ConnectorFacade'
|
|
4
4
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
5
5
|
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
6
|
-
import { Message, PeerDescriptor } from '../../
|
|
7
|
-
import { RpcMessage } from '../../
|
|
6
|
+
import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
7
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
8
8
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
9
9
|
import { getRandomRegion } from '../../src/connection/simulator/pings'
|
|
10
10
|
import { MockTransport } from '../utils/mock/MockTransport'
|
|
11
|
-
import {
|
|
11
|
+
import { toNodeId } from '../../src/identifiers'
|
|
12
12
|
|
|
13
13
|
const BASE_MESSAGE: Message = {
|
|
14
14
|
serviceId: 'serviceId',
|
|
@@ -25,7 +25,8 @@ const createConnectionManager = (localPeerDescriptor: PeerDescriptor, opts: Omit
|
|
|
25
25
|
createLocalPeerDescriptor: async () => localPeerDescriptor,
|
|
26
26
|
...opts
|
|
27
27
|
}),
|
|
28
|
-
metricsContext: new MetricsContext()
|
|
28
|
+
metricsContext: new MetricsContext(),
|
|
29
|
+
allowIncomingPrivateConnections: false
|
|
29
30
|
})
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -78,8 +79,8 @@ describe('SimultaneousConnections', () => {
|
|
|
78
79
|
simTransport1.send(msg1),
|
|
79
80
|
simTransport2.send(msg2)
|
|
80
81
|
])
|
|
81
|
-
await
|
|
82
|
-
await
|
|
82
|
+
await until(() => simTransport2.hasConnection(toNodeId(peerDescriptor1)))
|
|
83
|
+
await until(() => simTransport1.hasConnection(toNodeId(peerDescriptor2)))
|
|
83
84
|
})
|
|
84
85
|
|
|
85
86
|
describe('Websocket 2 servers', () => {
|
|
@@ -159,8 +160,8 @@ describe('SimultaneousConnections', () => {
|
|
|
159
160
|
connectionManager2.send(msg2)
|
|
160
161
|
])
|
|
161
162
|
|
|
162
|
-
await
|
|
163
|
-
await
|
|
163
|
+
await until(() => connectionManager1.hasConnection(toNodeId(wsPeerDescriptor2)))
|
|
164
|
+
await until(() => connectionManager2.hasConnection(toNodeId(wsPeerDescriptor1)))
|
|
164
165
|
})
|
|
165
166
|
})
|
|
166
167
|
|
|
@@ -239,8 +240,8 @@ describe('SimultaneousConnections', () => {
|
|
|
239
240
|
connectionManager2.send(msg2)
|
|
240
241
|
])
|
|
241
242
|
|
|
242
|
-
await
|
|
243
|
-
await
|
|
243
|
+
await until(() => connectionManager1.hasConnection(toNodeId(wsPeerDescriptor2)))
|
|
244
|
+
await until(() => connectionManager2.hasConnection(toNodeId(wsPeerDescriptor1)))
|
|
244
245
|
})
|
|
245
246
|
})
|
|
246
247
|
|
|
@@ -307,8 +308,8 @@ describe('SimultaneousConnections', () => {
|
|
|
307
308
|
connectionManager2.send(msg2)
|
|
308
309
|
])
|
|
309
310
|
|
|
310
|
-
await
|
|
311
|
-
await
|
|
311
|
+
await until(() => connectionManager1.hasConnection(toNodeId(wrtcPeerDescriptor2)))
|
|
312
|
+
await until(() => connectionManager2.hasConnection(toNodeId(wrtcPeerDescriptor1)))
|
|
312
313
|
})
|
|
313
314
|
})
|
|
314
315
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import {
|
|
4
|
-
import { PeerDescriptor } from '../../
|
|
3
|
+
import { toDhtAddress, toNodeId } from '../../src/identifiers'
|
|
4
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
6
6
|
import { createMockConnectionDhtNode, createMockPeerDescriptor, waitForStableTopology } from '../utils/utils'
|
|
7
7
|
|
|
@@ -44,7 +44,7 @@ describe('Storing data in DHT', () => {
|
|
|
44
44
|
const storingNodeIndex = 34
|
|
45
45
|
const entry = createMockDataEntry()
|
|
46
46
|
const successfulStorers = await nodes[storingNodeIndex].storeDataToDht(
|
|
47
|
-
|
|
47
|
+
toDhtAddress(entry.key),
|
|
48
48
|
entry.data!
|
|
49
49
|
)
|
|
50
50
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
@@ -54,12 +54,12 @@ describe('Storing data in DHT', () => {
|
|
|
54
54
|
const storingNode = getRandomNode()
|
|
55
55
|
const entry = createMockDataEntry()
|
|
56
56
|
const successfulStorers = await storingNode.storeDataToDht(
|
|
57
|
-
|
|
57
|
+
toDhtAddress(entry.key),
|
|
58
58
|
entry.data!
|
|
59
59
|
)
|
|
60
60
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
61
61
|
const fetchingNode = getRandomNode()
|
|
62
|
-
const results = await fetchingNode.fetchDataFromDht(
|
|
62
|
+
const results = await fetchingNode.fetchDataFromDht(toDhtAddress(entry.key))
|
|
63
63
|
results.forEach((result) => {
|
|
64
64
|
expectEqualData(result, entry)
|
|
65
65
|
})
|
|
@@ -70,16 +70,16 @@ describe('Storing data in DHT', () => {
|
|
|
70
70
|
const entry = createMockDataEntry()
|
|
71
71
|
const requestor = createMockPeerDescriptor()
|
|
72
72
|
const successfulStorers = await storingNode.storeDataToDht(
|
|
73
|
-
|
|
73
|
+
toDhtAddress(entry.key),
|
|
74
74
|
entry.data!,
|
|
75
|
-
|
|
75
|
+
toDhtAddress(requestor.nodeId)
|
|
76
76
|
)
|
|
77
77
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
78
78
|
const fetchingNode = getRandomNode()
|
|
79
|
-
const results = await fetchingNode.fetchDataFromDht(
|
|
79
|
+
const results = await fetchingNode.fetchDataFromDht(toDhtAddress(entry.key))
|
|
80
80
|
results.forEach((result) => {
|
|
81
81
|
expectEqualData(result, entry)
|
|
82
|
-
expect(
|
|
82
|
+
expect(toDhtAddress(result.creator)).toEqual(toNodeId(requestor))
|
|
83
83
|
})
|
|
84
84
|
}, 30000)
|
|
85
85
|
})
|
|
@@ -2,7 +2,7 @@ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator
|
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { createMockConnectionDhtNode, waitForStableTopology } from '../utils/utils'
|
|
4
4
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
5
|
-
import {
|
|
5
|
+
import { randomDhtAddress, toDhtAddress } from '../../src/identifiers'
|
|
6
6
|
import { wait } from '@streamr/utils'
|
|
7
7
|
|
|
8
8
|
const NUM_NODES = 5
|
|
@@ -21,7 +21,7 @@ describe('Storing data in DHT', () => {
|
|
|
21
21
|
beforeEach(async () => {
|
|
22
22
|
nodes = []
|
|
23
23
|
const entryPoint = await createMockConnectionDhtNode(simulator,
|
|
24
|
-
|
|
24
|
+
randomDhtAddress(), K, MAX_CONNECTIONS)
|
|
25
25
|
nodes.push(entryPoint)
|
|
26
26
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
27
27
|
const node = await createMockConnectionDhtNode(simulator,
|
|
@@ -39,13 +39,13 @@ describe('Storing data in DHT', () => {
|
|
|
39
39
|
it('Data can be deleted', async () => {
|
|
40
40
|
const storingNode = getRandomNode()
|
|
41
41
|
const entry = createMockDataEntry()
|
|
42
|
-
const successfulStorers = await storingNode.storeDataToDht(
|
|
42
|
+
const successfulStorers = await storingNode.storeDataToDht(toDhtAddress(entry.key), entry.data!)
|
|
43
43
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
44
|
-
await storingNode.deleteDataFromDht(
|
|
44
|
+
await storingNode.deleteDataFromDht(toDhtAddress(entry.key), true)
|
|
45
45
|
// Wait for the delete operation to propagate
|
|
46
46
|
await wait(500)
|
|
47
47
|
const fetchingNode = getRandomNode()
|
|
48
|
-
const results = await fetchingNode.fetchDataFromDht(
|
|
48
|
+
const results = await fetchingNode.fetchDataFromDht(toDhtAddress(entry.key))
|
|
49
49
|
results.forEach((result) => {
|
|
50
50
|
expect(result.deleted).toBeTrue()
|
|
51
51
|
expectEqualData(result, entry)
|
|
@@ -55,20 +55,20 @@ describe('Storing data in DHT', () => {
|
|
|
55
55
|
it('Data can be deleted and re-stored', async () => {
|
|
56
56
|
const storingNode = getRandomNode()
|
|
57
57
|
const entry = createMockDataEntry()
|
|
58
|
-
const successfulStorers1 = await storingNode.storeDataToDht(
|
|
58
|
+
const successfulStorers1 = await storingNode.storeDataToDht(toDhtAddress(entry.key), entry.data!)
|
|
59
59
|
expect(successfulStorers1.length).toBeGreaterThan(4)
|
|
60
|
-
await storingNode.deleteDataFromDht(
|
|
60
|
+
await storingNode.deleteDataFromDht(toDhtAddress(entry.key), true)
|
|
61
61
|
// Wait for the delete operation to propagate
|
|
62
62
|
await wait(500)
|
|
63
63
|
const fetchingNode = getRandomNode()
|
|
64
|
-
const results1 = await fetchingNode.fetchDataFromDht(
|
|
64
|
+
const results1 = await fetchingNode.fetchDataFromDht(toDhtAddress(entry.key))
|
|
65
65
|
results1.forEach((result) => {
|
|
66
66
|
expect(result.deleted).toBeTrue()
|
|
67
67
|
expectEqualData(result, entry)
|
|
68
68
|
})
|
|
69
|
-
const successfulStorers2 = await storingNode.storeDataToDht(
|
|
69
|
+
const successfulStorers2 = await storingNode.storeDataToDht(toDhtAddress(entry.key), entry.data!)
|
|
70
70
|
expect(successfulStorers2.length).toBeGreaterThan(4)
|
|
71
|
-
const results2 = await fetchingNode.fetchDataFromDht(
|
|
71
|
+
const results2 = await fetchingNode.fetchDataFromDht(toDhtAddress(entry.key))
|
|
72
72
|
results2.forEach((result) => {
|
|
73
73
|
expect(result.deleted).toBeFalse()
|
|
74
74
|
expectEqualData(result, entry)
|
|
@@ -2,7 +2,7 @@ import { createMockConnectionDhtNode } from '../utils/utils'
|
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
4
4
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
5
|
-
import {
|
|
5
|
+
import { toDhtAddress } from '../../src/identifiers'
|
|
6
6
|
|
|
7
7
|
describe('Storing data in DHT with two peers', () => {
|
|
8
8
|
|
|
@@ -34,22 +34,22 @@ describe('Storing data in DHT with two peers', () => {
|
|
|
34
34
|
await entryPoint.stop()
|
|
35
35
|
await node1.stop()
|
|
36
36
|
await node2.stop()
|
|
37
|
-
simulator
|
|
37
|
+
simulator!.stop()
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
it('Node can store on three peer DHT', async () => {
|
|
41
41
|
const storedData1 = createMockDataEntry()
|
|
42
42
|
const storedData2 = createMockDataEntry()
|
|
43
43
|
// Here we effectively test that fetching "null" data doesn't take too long. A test timeout here indicates an issue.
|
|
44
|
-
await node1.fetchDataFromDht(
|
|
45
|
-
await node2.fetchDataFromDht(
|
|
44
|
+
await node1.fetchDataFromDht(toDhtAddress(storedData1.key))
|
|
45
|
+
await node2.fetchDataFromDht(toDhtAddress(storedData1.key))
|
|
46
46
|
|
|
47
|
-
await node1.storeDataToDht(
|
|
48
|
-
await node2.storeDataToDht(
|
|
49
|
-
await entryPoint.storeDataToDht(
|
|
50
|
-
const foundData1 = await node1.fetchDataFromDht(
|
|
51
|
-
const foundData2 = await node2.fetchDataFromDht(
|
|
52
|
-
const foundData3 = await entryPoint.fetchDataFromDht(
|
|
47
|
+
await node1.storeDataToDht(toDhtAddress(storedData1.key), storedData1.data!)
|
|
48
|
+
await node2.storeDataToDht(toDhtAddress(storedData1.key), storedData1.data!)
|
|
49
|
+
await entryPoint.storeDataToDht(toDhtAddress(storedData2.key), storedData2.data!)
|
|
50
|
+
const foundData1 = await node1.fetchDataFromDht(toDhtAddress(storedData1.key))
|
|
51
|
+
const foundData2 = await node2.fetchDataFromDht(toDhtAddress(storedData1.key))
|
|
52
|
+
const foundData3 = await entryPoint.fetchDataFromDht(toDhtAddress(storedData2.key))
|
|
53
53
|
expectEqualData(foundData1[0], storedData1)
|
|
54
54
|
expectEqualData(foundData1[1], storedData1)
|
|
55
55
|
expectEqualData(foundData2[0], storedData1)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
4
|
-
import {
|
|
4
|
+
import { until } from '@streamr/utils'
|
|
5
5
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
6
|
-
import {
|
|
6
|
+
import { toDhtAddress } from '../../src/identifiers'
|
|
7
7
|
|
|
8
8
|
describe('Storing data in DHT with two peers', () => {
|
|
9
9
|
|
|
@@ -26,26 +26,26 @@ describe('Storing data in DHT with two peers', () => {
|
|
|
26
26
|
afterEach(async () => {
|
|
27
27
|
await entryPoint.stop()
|
|
28
28
|
await otherNode.stop()
|
|
29
|
-
simulator
|
|
29
|
+
simulator!.stop()
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
it('Node can store on two peer DHT', async () => {
|
|
33
33
|
const storedData1 = createMockDataEntry()
|
|
34
34
|
const storedData2 = createMockDataEntry()
|
|
35
|
-
await otherNode.storeDataToDht(
|
|
36
|
-
await entryPoint.storeDataToDht(
|
|
37
|
-
const foundData1 = await otherNode.fetchDataFromDht(
|
|
38
|
-
const foundData2 = await entryPoint.fetchDataFromDht(
|
|
35
|
+
await otherNode.storeDataToDht(toDhtAddress(storedData1.key), storedData1.data!)
|
|
36
|
+
await entryPoint.storeDataToDht(toDhtAddress(storedData2.key), storedData2.data!)
|
|
37
|
+
const foundData1 = await otherNode.fetchDataFromDht(toDhtAddress(storedData1.key))
|
|
38
|
+
const foundData2 = await entryPoint.fetchDataFromDht(toDhtAddress(storedData2.key))
|
|
39
39
|
expectEqualData(foundData1[0], storedData1)
|
|
40
40
|
expectEqualData(foundData2[0], storedData2)
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
it('Can store on one peer DHT', async () => {
|
|
44
44
|
await otherNode.stop()
|
|
45
|
-
await
|
|
45
|
+
await until(() => entryPoint.getNeighborCount() === 0)
|
|
46
46
|
const storedData = createMockDataEntry()
|
|
47
|
-
await entryPoint.storeDataToDht(
|
|
48
|
-
const foundData = await entryPoint.fetchDataFromDht(
|
|
47
|
+
await entryPoint.storeDataToDht(toDhtAddress(storedData.key), storedData.data!)
|
|
48
|
+
const foundData = await entryPoint.fetchDataFromDht(toDhtAddress(storedData.key))
|
|
49
49
|
expectEqualData(foundData[0], storedData)
|
|
50
50
|
}, 60000)
|
|
51
51
|
})
|
|
@@ -2,14 +2,14 @@ import { RpcCommunicator } from '@streamr/proto-rpc'
|
|
|
2
2
|
import {
|
|
3
3
|
StoreDataRequest,
|
|
4
4
|
StoreDataResponse
|
|
5
|
-
} from '../../
|
|
5
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
6
6
|
import { createMockPeerDescriptor, mockStoreRpc } from '../utils/utils'
|
|
7
|
-
import { RpcMessage } from '../../
|
|
8
|
-
import { StoreRpcClient } from '../../
|
|
7
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
8
|
+
import { StoreRpcClient } from '../../generated/packages/dht/protos/DhtRpc.client'
|
|
9
9
|
import { StoreRpcRemote } from '../../src/dht/store/StoreRpcRemote'
|
|
10
10
|
import { createMockDataEntry } from '../utils/mock/mockDataEntry'
|
|
11
11
|
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
12
|
-
import {
|
|
12
|
+
import { randomDhtAddress, toNodeId, toDhtAddressRaw } from '../../src/identifiers'
|
|
13
13
|
|
|
14
14
|
describe('StoreRpcRemote', () => {
|
|
15
15
|
|
|
@@ -22,7 +22,7 @@ describe('StoreRpcRemote', () => {
|
|
|
22
22
|
const request: StoreDataRequest = {
|
|
23
23
|
key: data.key,
|
|
24
24
|
data: data.data,
|
|
25
|
-
creator:
|
|
25
|
+
creator: toDhtAddressRaw(randomDhtAddress()),
|
|
26
26
|
ttl: 10
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -30,11 +30,11 @@ describe('StoreRpcRemote', () => {
|
|
|
30
30
|
clientRpcCommunicator = new RpcCommunicator()
|
|
31
31
|
serverRpcCommunicator = new RpcCommunicator()
|
|
32
32
|
serverRpcCommunicator.registerRpcMethod(StoreDataRequest, StoreDataResponse, 'storeData', mockStoreRpc.storeData)
|
|
33
|
-
clientRpcCommunicator.
|
|
34
|
-
serverRpcCommunicator.handleIncomingMessage(message)
|
|
33
|
+
clientRpcCommunicator.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
34
|
+
serverRpcCommunicator.handleIncomingMessage(message, new DhtCallContext())
|
|
35
35
|
})
|
|
36
|
-
serverRpcCommunicator.
|
|
37
|
-
clientRpcCommunicator.handleIncomingMessage(message)
|
|
36
|
+
serverRpcCommunicator.setOutgoingMessageListener(async (message: RpcMessage) => {
|
|
37
|
+
clientRpcCommunicator.handleIncomingMessage(message, new DhtCallContext())
|
|
38
38
|
})
|
|
39
39
|
rpcRemote = new StoreRpcRemote(clientPeerDescriptor, serverPeerDescriptor, clientRpcCommunicator, StoreRpcClient)
|
|
40
40
|
})
|
|
@@ -45,9 +45,9 @@ describe('StoreRpcRemote', () => {
|
|
|
45
45
|
|
|
46
46
|
it('storeData rejects', async () => {
|
|
47
47
|
serverRpcCommunicator.registerRpcMethod(StoreDataRequest, StoreDataResponse, 'storeData', mockStoreRpc.throwStoreDataError)
|
|
48
|
-
await expect(rpcRemote.storeData(request)).rejects.
|
|
48
|
+
await expect(rpcRemote.storeData(request)).rejects.toThrow(
|
|
49
49
|
'Could not store data to'
|
|
50
|
-
+ ` ${
|
|
50
|
+
+ ` ${toNodeId(serverPeerDescriptor)} from ${toNodeId(clientPeerDescriptor)}`
|
|
51
51
|
+ ' Error: Mock'
|
|
52
52
|
)
|
|
53
53
|
})
|