@streamr/dht 100.0.0-pretestnet.6 → 100.0.0-rc.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/README.md +90 -8
- package/dist/package.json +70 -0
- package/dist/src/connection/Connection.d.ts +1 -0
- package/dist/src/connection/Connection.js +10 -3
- package/dist/src/connection/Connection.js.map +1 -1
- package/dist/src/connection/ConnectionLockHandler.d.ts +14 -14
- package/dist/src/connection/ConnectionLockHandler.js +22 -16
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +7 -6
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +4 -6
- package/dist/src/connection/ConnectionLockRpcRemote.js +10 -37
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +19 -20
- package/dist/src/connection/ConnectionManager.js +132 -117
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +3 -2
- package/dist/src/connection/ConnectorFacade.js +10 -3
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +3 -1
- package/dist/src/connection/Handshaker.js +18 -9
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/IConnection.d.ts +2 -7
- package/dist/src/connection/IConnection.js +1 -8
- package/dist/src/connection/IConnection.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +5 -7
- package/dist/src/connection/ManagedConnection.js +42 -26
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -1
- package/dist/src/connection/connectivityChecker.d.ts +9 -0
- package/dist/src/connection/connectivityChecker.js +130 -0
- package/dist/src/connection/connectivityChecker.js.map +1 -0
- package/dist/src/connection/connectivityRequestHandler.d.ts +3 -0
- package/dist/src/connection/connectivityRequestHandler.js +101 -0
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -0
- package/dist/src/connection/simulator/Simulator.d.ts +0 -3
- package/dist/src/connection/simulator/Simulator.js +34 -69
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +27 -25
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +16 -12
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/simulator/pings.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -3
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +40 -27
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +0 -2
- package/dist/src/connection/webrtc/WebrtcConnector.js +24 -25
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +2 -2
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +27 -20
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +3 -6
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js +2 -5
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +1 -2
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +6 -4
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
- package/dist/src/connection/websocket/ClientWebsocket.d.ts +1 -0
- package/dist/src/connection/websocket/ClientWebsocket.js +14 -7
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +3 -9
- package/dist/src/connection/websocket/WebsocketConnector.js +142 -74
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +5 -3
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +9 -12
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +4 -7
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js +7 -44
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServer.d.ts +1 -4
- package/dist/src/connection/websocket/WebsocketServer.js +49 -40
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
- package/dist/src/connection/websocket/{ServerWebsocket.d.ts → WebsocketServerConnection.d.ts} +8 -4
- package/dist/src/connection/websocket/WebsocketServerConnection.js +97 -0
- package/dist/src/connection/websocket/WebsocketServerConnection.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +45 -49
- package/dist/src/dht/DhtNode.js +229 -317
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +10 -9
- package/dist/src/dht/DhtNodeRpcLocal.js +19 -11
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +15 -10
- package/dist/src/dht/DhtNodeRpcRemote.js +38 -21
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +7 -6
- package/dist/src/dht/ExternalApiRpcLocal.js +9 -13
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +6 -5
- package/dist/src/dht/ExternalApiRpcRemote.js +10 -7
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +61 -0
- package/dist/src/dht/PeerManager.js +288 -0
- package/dist/src/dht/PeerManager.js.map +1 -0
- package/dist/src/dht/contact/Contact.d.ts +2 -2
- package/dist/src/dht/contact/Contact.js +4 -3
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/ContactList.d.ts +8 -8
- package/dist/src/dht/contact/ContactList.js +12 -7
- package/dist/src/dht/contact/ContactList.js.map +1 -1
- package/dist/src/dht/contact/RandomContactList.d.ts +4 -4
- package/dist/src/dht/contact/RandomContactList.js +13 -12
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/RingContactList.d.ts +31 -0
- package/dist/src/dht/contact/RingContactList.js +133 -0
- package/dist/src/dht/contact/RingContactList.js.map +1 -0
- package/dist/src/dht/contact/{Remote.d.ts → RpcRemote.d.ts} +8 -7
- package/dist/src/dht/contact/{Remote.js → RpcRemote.js} +16 -13
- package/dist/src/dht/contact/RpcRemote.js.map +1 -0
- package/dist/src/dht/contact/SortedContactList.d.ts +29 -15
- package/dist/src/dht/contact/SortedContactList.js +79 -42
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/contact/ringIdentifiers.d.ts +16 -0
- package/dist/src/dht/contact/ringIdentifiers.js +54 -0
- package/dist/src/dht/contact/ringIdentifiers.js.map +1 -0
- package/dist/src/dht/discovery/DiscoverySession.d.ts +8 -18
- package/dist/src/dht/discovery/DiscoverySession.js +32 -48
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +16 -12
- package/dist/src/dht/discovery/PeerDiscovery.js +82 -39
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.d.ts +29 -0
- package/dist/src/dht/discovery/RingDiscoverySession.js +123 -0
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +36 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +166 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +14 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +26 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +6 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +44 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +44 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +187 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +14 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +20 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +6 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js +21 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js.map +1 -0
- package/dist/src/dht/routing/DuplicateDetector.d.ts +2 -4
- package/dist/src/dht/routing/DuplicateDetector.js +10 -15
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +11 -27
- package/dist/src/dht/routing/Router.js +92 -58
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +3 -4
- package/dist/src/dht/routing/RouterRpcLocal.js +17 -16
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +3 -3
- package/dist/src/dht/routing/RouterRpcRemote.js +29 -20
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +29 -21
- package/dist/src/dht/routing/RoutingSession.js +93 -68
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/RoutingTablesCache.d.ts +24 -0
- package/dist/src/dht/routing/RoutingTablesCache.js +46 -0
- package/dist/src/dht/routing/RoutingTablesCache.js.map +1 -0
- package/dist/src/dht/routing/getPreviousPeer.js.map +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +9 -14
- package/dist/src/dht/store/LocalDataStore.js +46 -72
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +33 -0
- package/dist/src/dht/store/StoreManager.js +182 -0
- package/dist/src/dht/store/StoreManager.js.map +1 -0
- package/dist/src/dht/store/StoreRpcLocal.d.ts +11 -41
- package/dist/src/dht/store/StoreRpcLocal.js +27 -234
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +6 -7
- package/dist/src/dht/store/StoreRpcRemote.js +10 -20
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +5 -3
- package/dist/src/exports.js +10 -8
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/AddressTools.js +2 -0
- package/dist/src/helpers/AddressTools.js.map +1 -1
- package/dist/src/helpers/Connectivity.js.map +1 -1
- package/dist/src/helpers/MapWithTtl.d.ts +14 -0
- package/dist/src/helpers/MapWithTtl.js +60 -0
- package/dist/src/helpers/MapWithTtl.js.map +1 -0
- package/dist/src/helpers/createPeerDescriptor.d.ts +3 -0
- package/dist/src/helpers/createPeerDescriptor.js +57 -0
- package/dist/src/helpers/createPeerDescriptor.js.map +1 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +2 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +30 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -0
- package/dist/src/helpers/debugHelpers.js.map +1 -1
- package/dist/src/helpers/errors.js +2 -0
- package/dist/src/helpers/errors.js.map +1 -1
- package/dist/src/helpers/offering.d.ts +4 -0
- package/dist/src/helpers/offering.js +18 -0
- package/dist/src/helpers/offering.js.map +1 -0
- package/dist/src/helpers/protoClasses.js +2 -3
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/helpers/protoToString.js.map +1 -1
- package/dist/src/helpers/version.d.ts +6 -0
- package/dist/src/helpers/version.js +38 -0
- package/dist/src/helpers/version.js.map +1 -0
- package/dist/src/identifiers.d.ts +10 -0
- package/dist/src/identifiers.js +31 -0
- package/dist/src/identifiers.js.map +1 -0
- package/dist/src/proto/google/protobuf/any.js +8 -8
- package/dist/src/proto/google/protobuf/any.js.map +1 -1
- package/dist/src/proto/google/protobuf/empty.js +2 -4
- package/dist/src/proto/google/protobuf/empty.js.map +1 -1
- package/dist/src/proto/google/protobuf/timestamp.js +10 -10
- package/dist/src/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +46 -49
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +63 -54
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +226 -232
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +146 -168
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +26 -29
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +2 -2
- package/dist/src/rpc-protocol/DhtCallContext.js +8 -0
- package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +2 -1
- package/dist/src/transport/ITransport.d.ts +10 -2
- package/dist/src/transport/ITransport.js +5 -0
- package/dist/src/transport/ITransport.js.map +1 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +3 -1
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +4 -2
- package/dist/src/transport/RoutingRpcCommunicator.js +19 -12
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/jest.config.js +4 -1
- package/karma-setup.js +2 -0
- package/karma.config.js +13 -9
- package/package.json +16 -13
- package/protos/DhtRpc.proto +76 -76
- package/src/connection/Connection.ts +6 -1
- package/src/connection/ConnectionLockHandler.ts +30 -22
- package/src/connection/ConnectionLockRpcLocal.ts +7 -12
- package/src/connection/ConnectionLockRpcRemote.ts +9 -19
- package/src/connection/ConnectionManager.ts +132 -138
- package/src/connection/ConnectorFacade.ts +10 -9
- package/src/connection/Handshaker.ts +23 -11
- package/src/connection/IConnection.ts +2 -8
- package/src/connection/ManagedConnection.ts +34 -35
- package/src/connection/connectivityChecker.ts +109 -0
- package/src/connection/connectivityRequestHandler.ts +103 -0
- package/src/connection/simulator/Simulator.ts +6 -37
- package/src/connection/simulator/SimulatorConnection.ts +23 -25
- package/src/connection/simulator/SimulatorConnector.ts +11 -11
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +17 -25
- package/src/connection/webrtc/NodeWebrtcConnection.ts +24 -26
- package/src/connection/webrtc/WebrtcConnector.ts +18 -29
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +29 -24
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +4 -14
- package/src/connection/webrtc/iceServerAsString.ts +1 -1
- package/src/connection/websocket/AutoCertifierClientFacade.ts +4 -6
- package/src/connection/websocket/ClientWebsocket.ts +10 -4
- package/src/connection/websocket/WebsocketConnector.ts +120 -97
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +13 -15
- package/src/connection/websocket/WebsocketConnectorRpcRemote.ts +7 -27
- package/src/connection/websocket/WebsocketServer.ts +50 -53
- package/src/connection/websocket/WebsocketServerConnection.ts +104 -0
- package/src/dht/DhtNode.ts +289 -410
- package/src/dht/DhtNodeRpcLocal.ts +25 -17
- package/src/dht/DhtNodeRpcRemote.ts +43 -27
- package/src/dht/ExternalApiRpcLocal.ts +30 -17
- package/src/dht/ExternalApiRpcRemote.ts +14 -11
- package/src/dht/PeerManager.ts +339 -0
- package/src/dht/contact/Contact.ts +4 -4
- package/src/dht/contact/ContactList.ts +11 -10
- package/src/dht/contact/RandomContactList.ts +15 -15
- package/src/dht/contact/RingContactList.ts +151 -0
- package/src/dht/contact/{Remote.ts → RpcRemote.ts} +16 -19
- package/src/dht/contact/SortedContactList.ts +120 -72
- package/src/dht/contact/ringIdentifiers.ts +62 -0
- package/src/dht/discovery/DiscoverySession.ts +36 -61
- package/src/dht/discovery/PeerDiscovery.ts +98 -43
- package/src/dht/discovery/RingDiscoverySession.ts +160 -0
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +246 -0
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +34 -0
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +43 -0
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +232 -0
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +35 -0
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +30 -0
- package/src/dht/routing/DuplicateDetector.ts +9 -21
- package/src/dht/routing/Router.ts +95 -92
- package/src/dht/routing/RouterRpcLocal.ts +16 -18
- package/src/dht/routing/RouterRpcRemote.ts +26 -24
- package/src/dht/routing/RoutingSession.ts +119 -98
- package/src/dht/routing/RoutingTablesCache.ts +58 -0
- package/src/dht/routing/getPreviousPeer.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +47 -77
- package/src/dht/store/StoreManager.ts +209 -0
- package/src/dht/store/StoreRpcLocal.ts +39 -308
- package/src/dht/store/StoreRpcRemote.ts +13 -31
- package/src/exports.ts +13 -3
- package/src/helpers/AddressTools.ts +2 -0
- package/src/helpers/MapWithTtl.ts +71 -0
- package/src/helpers/createPeerDescriptor.ts +57 -0
- package/src/helpers/createPeerDescriptorSignaturePayload.ts +28 -0
- package/src/helpers/offering.ts +15 -0
- package/src/helpers/protoClasses.ts +4 -6
- package/src/helpers/version.ts +32 -0
- package/src/identifiers.ts +29 -0
- package/src/proto/google/protobuf/any.ts +4 -4
- package/src/proto/google/protobuf/empty.ts +2 -4
- package/src/proto/google/protobuf/timestamp.ts +4 -4
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +65 -68
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +27 -30
- package/src/proto/packages/dht/protos/DhtRpc.ts +297 -313
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
- package/src/rpc-protocol/DhtCallContext.ts +2 -2
- package/src/rpc-protocol/DhtRpcOptions.ts +2 -1
- package/src/transport/ITransport.ts +11 -2
- package/src/transport/ListeningRpcCommunicator.ts +1 -1
- package/src/transport/RoutingRpcCommunicator.ts +21 -14
- package/test/RandomGraphSimulation.ts +3 -2
- package/test/benchmark/Find.test.ts +13 -28
- package/test/benchmark/KademliaCorrectness.test.ts +24 -28
- package/test/benchmark/RingCorrectness.test.ts +157 -0
- package/test/benchmark/SortedContactListBenchmark.test.ts +151 -0
- package/test/benchmark/WebsocketServerMemoryLeak.test.ts +41 -0
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +72 -0
- package/test/benchmark/kademlia-simulation/Contact.ts +9 -9
- package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +11 -11
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +29 -25
- package/test/data/generateGroundTruthData.ts +7 -6
- package/test/end-to-end/Layer0-Layer1.test.ts +11 -15
- package/test/end-to-end/Layer0.test.ts +19 -22
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +19 -21
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +26 -28
- package/test/end-to-end/Layer0Webrtc.test.ts +19 -19
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +10 -18
- package/test/end-to-end/Layer1-Scale-Webrtc.test.ts +8 -15
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +2 -2
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +8 -9
- package/test/end-to-end/memory-leak.test.ts +19 -24
- package/test/integration/ConnectionLocking.test.ts +66 -60
- package/test/integration/ConnectionManager.test.ts +43 -63
- package/test/integration/ConnectivityChecking.test.ts +52 -0
- package/test/integration/DhtJoinPeerDiscovery.test.ts +8 -12
- package/test/integration/DhtNodeExternalAPI.test.ts +17 -21
- package/test/integration/DhtNodeRpcRemote.test.ts +19 -26
- package/test/integration/DhtRpc.test.ts +20 -24
- package/test/integration/Find.test.ts +10 -12
- package/test/integration/Layer1-scale.test.ts +25 -37
- package/test/integration/Mock-Layer1-Layer0.test.ts +39 -59
- package/test/integration/MultipleEntryPointJoining.test.ts +14 -14
- package/test/integration/ReplicateData.test.ts +106 -0
- package/test/integration/RouteMessage.test.ts +42 -68
- package/test/integration/RouterRpcRemote.test.ts +19 -24
- package/test/integration/ScaleDownDht.test.ts +14 -12
- package/test/integration/SimultaneousConnections.test.ts +112 -111
- package/test/integration/Store.test.ts +43 -27
- package/test/integration/StoreAndDelete.test.ts +36 -48
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +59 -0
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +17 -37
- package/test/integration/StoreRpcRemote.test.ts +20 -32
- package/test/integration/WebrtcConnectionManagement.test.ts +39 -25
- package/test/integration/WebrtcConnectorRpc.test.ts +6 -11
- package/test/integration/WebsocketConnectionManagement.test.ts +87 -22
- package/test/integration/WebsocketConnectorRpc.test.ts +14 -24
- package/test/integration/{RpcErrors.test.ts → rpc-connections-over-webrpc.test.ts} +15 -26
- package/test/unit/AddressTools.test.ts +4 -0
- package/test/unit/ConnectivityHelpers.test.ts +9 -17
- package/test/unit/DuplicateDetector.test.ts +8 -5
- package/test/unit/LocalDataStore.test.ts +78 -75
- package/test/unit/PeerManager.test.ts +33 -0
- package/test/unit/RandomContactList.test.ts +12 -9
- package/test/unit/RecursiveOperationManager.test.ts +157 -0
- package/test/unit/RecursiveOperationSession.test.ts +68 -0
- package/test/unit/Router.test.ts +52 -35
- package/test/unit/RoutingSession.test.ts +79 -0
- package/test/unit/SortedContactList.test.ts +61 -30
- package/test/unit/StoreManager.test.ts +138 -0
- package/test/unit/WebsocketConnector.test.ts +27 -35
- package/test/unit/connectivityRequestHandler.test.ts +104 -0
- package/test/unit/createPeerDescriptor.test.ts +69 -0
- package/test/unit/customMatchers.test.ts +16 -0
- package/test/unit/version.test.ts +18 -0
- package/test/utils/FakeTransport.ts +47 -0
- package/test/utils/customMatchers.ts +71 -0
- package/test/utils/mock/MockRpcCommunicator.ts +7 -0
- package/test/utils/mock/Router.ts +13 -3
- package/test/utils/mock/Transport.ts +1 -1
- package/test/utils/mock/mockDataEntry.ts +38 -0
- package/test/utils/utils.ts +104 -107
- package/tsconfig.browser.json +2 -1
- package/tsconfig.jest.json +4 -2
- package/tsconfig.node.json +4 -2
- package/dist/src/connection/ConnectivityChecker.d.ts +0 -17
- package/dist/src/connection/ConnectivityChecker.js +0 -208
- package/dist/src/connection/ConnectivityChecker.js.map +0 -1
- package/dist/src/connection/websocket/ServerWebsocket.js +0 -100
- package/dist/src/connection/websocket/ServerWebsocket.js.map +0 -1
- package/dist/src/dht/contact/Remote.js.map +0 -1
- package/dist/src/dht/find/FindRpcLocal.d.ts +0 -14
- package/dist/src/dht/find/FindRpcLocal.js +0 -25
- package/dist/src/dht/find/FindRpcLocal.js.map +0 -1
- package/dist/src/dht/find/FindSession.d.ts +0 -44
- package/dist/src/dht/find/FindSession.js +0 -145
- package/dist/src/dht/find/FindSession.js.map +0 -1
- package/dist/src/dht/find/FindSessionRpcLocal.d.ts +0 -12
- package/dist/src/dht/find/FindSessionRpcLocal.js +0 -17
- package/dist/src/dht/find/FindSessionRpcLocal.js.map +0 -1
- package/dist/src/dht/find/FindSessionRpcRemote.d.ts +0 -6
- package/dist/src/dht/find/FindSessionRpcRemote.js +0 -21
- package/dist/src/dht/find/FindSessionRpcRemote.js.map +0 -1
- package/dist/src/dht/find/Finder.d.ts +0 -49
- package/dist/src/dht/find/Finder.js +0 -184
- package/dist/src/dht/find/Finder.js.map +0 -1
- package/dist/src/dht/routing/FindRpcRemote.d.ts +0 -6
- package/dist/src/dht/routing/FindRpcRemote.js +0 -41
- package/dist/src/dht/routing/FindRpcRemote.js.map +0 -1
- package/dist/src/helpers/PeerID.d.ts +0 -24
- package/dist/src/helpers/PeerID.js +0 -78
- package/dist/src/helpers/PeerID.js.map +0 -1
- package/dist/src/helpers/UUID.d.ts +0 -8
- package/dist/src/helpers/UUID.js +0 -36
- package/dist/src/helpers/UUID.js.map +0 -1
- package/dist/src/helpers/kademliaId.d.ts +0 -1
- package/dist/src/helpers/kademliaId.js +0 -14
- package/dist/src/helpers/kademliaId.js.map +0 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +0 -6
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +0 -23
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +0 -1
- package/src/connection/ConnectivityChecker.ts +0 -199
- package/src/connection/websocket/ServerWebsocket.ts +0 -114
- package/src/dht/find/FindRpcLocal.ts +0 -35
- package/src/dht/find/FindSession.ts +0 -178
- package/src/dht/find/FindSessionRpcLocal.ts +0 -25
- package/src/dht/find/FindSessionRpcRemote.ts +0 -30
- package/src/dht/find/Finder.ts +0 -275
- package/src/dht/routing/FindRpcRemote.ts +0 -40
- package/src/helpers/PeerID.ts +0 -88
- package/src/helpers/UUID.ts +0 -35
- package/src/helpers/kademliaId.ts +0 -8
- package/src/helpers/peerIdFromPeerDescriptor.ts +0 -20
- package/test/integration/MigrateData.test.ts +0 -204
- package/test/unit/Finder.test.ts +0 -110
- package/test/unit/PeerID.test.ts +0 -22
- package/test/unit/UUID.test.ts +0 -55
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
import { binaryToHex } from '@streamr/utils'
|
|
2
1
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import {
|
|
2
|
+
import { createRandomDhtAddress, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
3
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
4
4
|
|
|
5
5
|
describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type: NodeType.NODEJS,
|
|
6
|
+
|
|
7
|
+
const entrypointDescriptor = createMockPeerDescriptor({
|
|
9
8
|
websocket: {
|
|
10
9
|
host: '127.0.0.1',
|
|
11
10
|
port: 23232,
|
|
12
11
|
tls: false
|
|
13
12
|
}
|
|
14
|
-
}
|
|
15
|
-
|
|
13
|
+
})
|
|
16
14
|
let layer0EntryPoint: DhtNode
|
|
17
15
|
let layer1Node1: DhtNode
|
|
18
|
-
|
|
19
16
|
let layer0Node1: DhtNode
|
|
20
17
|
let layer1EntryPoint: DhtNode
|
|
21
|
-
|
|
22
18
|
let layer0Node2: DhtNode
|
|
23
19
|
let layer1Node2: DhtNode
|
|
24
|
-
|
|
25
20
|
let layer0Node3: DhtNode
|
|
26
21
|
let layer1Node3: DhtNode
|
|
27
|
-
|
|
28
22
|
let layer0Node4: DhtNode
|
|
29
23
|
let layer1Node4: DhtNode
|
|
30
24
|
|
|
@@ -32,52 +26,56 @@ describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
|
32
26
|
|
|
33
27
|
layer0EntryPoint = new DhtNode({ peerDescriptor: entrypointDescriptor, websocketServerEnableTls: false })
|
|
34
28
|
|
|
35
|
-
const layer0Node1Id =
|
|
29
|
+
const layer0Node1Id = createRandomDhtAddress()
|
|
36
30
|
layer0Node1 = new DhtNode({
|
|
37
|
-
|
|
31
|
+
nodeId: layer0Node1Id,
|
|
32
|
+
entryPoints: [entrypointDescriptor]
|
|
38
33
|
})
|
|
39
34
|
|
|
40
|
-
const layer0Node2Id =
|
|
35
|
+
const layer0Node2Id = createRandomDhtAddress()
|
|
41
36
|
layer0Node2 = new DhtNode({
|
|
42
|
-
|
|
37
|
+
nodeId: layer0Node2Id,
|
|
38
|
+
entryPoints: [entrypointDescriptor]
|
|
43
39
|
})
|
|
44
40
|
|
|
45
|
-
const layer0Node3Id =
|
|
41
|
+
const layer0Node3Id = createRandomDhtAddress()
|
|
46
42
|
layer0Node3 = new DhtNode({
|
|
47
|
-
|
|
43
|
+
nodeId: layer0Node3Id,
|
|
44
|
+
entryPoints: [entrypointDescriptor]
|
|
48
45
|
})
|
|
49
46
|
|
|
50
|
-
const layer0Node4Id =
|
|
47
|
+
const layer0Node4Id = createRandomDhtAddress()
|
|
51
48
|
layer0Node4 = new DhtNode({
|
|
52
|
-
|
|
49
|
+
nodeId: layer0Node4Id,
|
|
50
|
+
entryPoints: [entrypointDescriptor]
|
|
53
51
|
})
|
|
54
52
|
|
|
55
53
|
layer1EntryPoint = new DhtNode({
|
|
56
|
-
|
|
54
|
+
nodeId: getNodeIdFromPeerDescriptor(entrypointDescriptor),
|
|
57
55
|
transport: layer0EntryPoint,
|
|
58
56
|
serviceId: 'layer1'
|
|
59
57
|
})
|
|
60
58
|
|
|
61
59
|
layer1Node1 = new DhtNode({
|
|
62
|
-
|
|
60
|
+
nodeId: layer0Node1Id,
|
|
63
61
|
transport: layer0Node1,
|
|
64
62
|
serviceId: 'layer1'
|
|
65
63
|
})
|
|
66
64
|
|
|
67
65
|
layer1Node2 = new DhtNode({
|
|
68
|
-
|
|
66
|
+
nodeId: layer0Node2Id,
|
|
69
67
|
transport: layer0Node2,
|
|
70
68
|
serviceId: 'layer1'
|
|
71
69
|
})
|
|
72
70
|
|
|
73
71
|
layer1Node3 = new DhtNode({
|
|
74
|
-
|
|
72
|
+
nodeId: layer0Node3Id,
|
|
75
73
|
transport: layer0Node3,
|
|
76
74
|
serviceId: 'layer1'
|
|
77
75
|
})
|
|
78
76
|
|
|
79
77
|
layer1Node4 = new DhtNode({
|
|
80
|
-
|
|
78
|
+
nodeId: layer0Node4Id,
|
|
81
79
|
transport: layer0Node4,
|
|
82
80
|
serviceId: 'layer1'
|
|
83
81
|
})
|
|
@@ -125,9 +123,9 @@ describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
|
125
123
|
await layer1Node3.joinDht([entrypointDescriptor])
|
|
126
124
|
await layer1Node4.joinDht([entrypointDescriptor])
|
|
127
125
|
|
|
128
|
-
expect(layer1Node1.
|
|
129
|
-
expect(layer1Node2.
|
|
130
|
-
expect(layer1Node3.
|
|
131
|
-
expect(layer1Node4.
|
|
126
|
+
expect(layer1Node1.getNeighborCount()).toBeGreaterThanOrEqual(2)
|
|
127
|
+
expect(layer1Node2.getNeighborCount()).toBeGreaterThanOrEqual(2)
|
|
128
|
+
expect(layer1Node3.getNeighborCount()).toBeGreaterThanOrEqual(2)
|
|
129
|
+
expect(layer1Node4.getNeighborCount()).toBeGreaterThanOrEqual(2)
|
|
132
130
|
}, 60000)
|
|
133
131
|
})
|
|
@@ -2,15 +2,15 @@ import { areEqualBinaries, waitForEvent3 } from '@streamr/utils'
|
|
|
2
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
3
3
|
import { ConnectionType } from '../../src/connection/IConnection'
|
|
4
4
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
6
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
7
|
+
import { getNodeIdFromPeerDescriptor } from '../../src/exports'
|
|
7
8
|
|
|
8
9
|
describe('Layer0 with WebRTC connections', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type: NodeType.NODEJS,
|
|
10
|
+
|
|
11
|
+
const epPeerDescriptor = createMockPeerDescriptor({
|
|
12
12
|
websocket: { host: '127.0.0.1', port: 10029, tls: false }
|
|
13
|
-
}
|
|
13
|
+
})
|
|
14
14
|
let epDhtNode: DhtNode
|
|
15
15
|
let node1: DhtNode
|
|
16
16
|
let node2: DhtNode
|
|
@@ -39,8 +39,6 @@ describe('Layer0 with WebRTC connections', () => {
|
|
|
39
39
|
node3.start(),
|
|
40
40
|
node4.start()
|
|
41
41
|
])
|
|
42
|
-
|
|
43
|
-
await epDhtNode.joinDht([epPeerDescriptor])
|
|
44
42
|
})
|
|
45
43
|
|
|
46
44
|
afterEach(async () => {
|
|
@@ -61,18 +59,19 @@ describe('Layer0 with WebRTC connections', () => {
|
|
|
61
59
|
'connected',
|
|
62
60
|
20000,
|
|
63
61
|
(peerDescriptor: PeerDescriptor) => {
|
|
64
|
-
return areEqualBinaries(peerDescriptor.
|
|
62
|
+
return areEqualBinaries(peerDescriptor.nodeId, node1.getLocalPeerDescriptor().nodeId)
|
|
65
63
|
}
|
|
66
64
|
),
|
|
67
65
|
node2.joinDht([epPeerDescriptor]),
|
|
68
66
|
node1.joinDht([epPeerDescriptor])
|
|
69
67
|
])
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
expect((
|
|
73
|
-
expect((
|
|
68
|
+
const nodeId1 = getNodeIdFromPeerDescriptor(node1.getLocalPeerDescriptor())
|
|
69
|
+
const nodeId2 = getNodeIdFromPeerDescriptor(node2.getLocalPeerDescriptor())
|
|
70
|
+
expect((node1.getTransport() as ConnectionManager).hasConnection(nodeId2)).toEqual(true)
|
|
71
|
+
expect((node2.getTransport() as ConnectionManager).hasConnection(nodeId1)).toEqual(true)
|
|
72
|
+
expect((node1.getTransport() as ConnectionManager).getConnection(nodeId2)!.connectionType)
|
|
74
73
|
.toEqual(ConnectionType.WEBRTC)
|
|
75
|
-
expect((node2.getTransport() as ConnectionManager).getConnection(
|
|
74
|
+
expect((node2.getTransport() as ConnectionManager).getConnection(nodeId1)!.connectionType)
|
|
76
75
|
.toEqual(ConnectionType.WEBRTC)
|
|
77
76
|
|
|
78
77
|
}, 60000)
|
|
@@ -84,12 +83,13 @@ describe('Layer0 with WebRTC connections', () => {
|
|
|
84
83
|
node3.joinDht([epPeerDescriptor]),
|
|
85
84
|
node4.joinDht([epPeerDescriptor])
|
|
86
85
|
])
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
expect((
|
|
90
|
-
expect((
|
|
86
|
+
const nodeId1 = getNodeIdFromPeerDescriptor(node1.getLocalPeerDescriptor())
|
|
87
|
+
const nodeId2 = getNodeIdFromPeerDescriptor(node2.getLocalPeerDescriptor())
|
|
88
|
+
expect((node1.getTransport() as ConnectionManager).hasConnection(nodeId2)).toEqual(true)
|
|
89
|
+
expect((node2.getTransport() as ConnectionManager).hasConnection(nodeId1)).toEqual(true)
|
|
90
|
+
expect((node1.getTransport() as ConnectionManager).getConnection(nodeId2)!.connectionType)
|
|
91
91
|
.toEqual(ConnectionType.WEBRTC)
|
|
92
|
-
expect((node2.getTransport() as ConnectionManager).getConnection(
|
|
92
|
+
expect((node2.getTransport() as ConnectionManager).getConnection(nodeId1)!.connectionType)
|
|
93
93
|
.toEqual(ConnectionType.WEBRTC)
|
|
94
94
|
})
|
|
95
95
|
})
|
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
2
|
-
import {
|
|
3
|
-
import { PeerID } from '../../src/helpers/PeerID'
|
|
2
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
4
3
|
|
|
4
|
+
const STREAM_ID = 'stream'
|
|
5
|
+
const NUM_OF_NODES = 16
|
|
5
6
|
const NUM_OF_NODES_PER_KBUCKET = 8
|
|
7
|
+
const WEBSOCKET_PORT_RANGE = { min: 62200, max: 62200 + NUM_OF_NODES }
|
|
6
8
|
|
|
7
9
|
describe('Layer1 Scale', () => {
|
|
8
|
-
const epPeerDescriptor: PeerDescriptor = {
|
|
9
|
-
kademliaId: PeerID.fromString('entrypoint').value,
|
|
10
|
-
type: NodeType.NODEJS,
|
|
11
|
-
websocket: { host: '127.0.0.1', port: 43225, tls: false }
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const STREAM_ID = 'stream'
|
|
15
|
-
|
|
16
|
-
const NUM_OF_NODES = 16
|
|
17
10
|
|
|
11
|
+
const epPeerDescriptor = createMockPeerDescriptor({
|
|
12
|
+
websocket: { host: '127.0.0.1', port: 43225, tls: false }
|
|
13
|
+
})
|
|
18
14
|
let layer0Nodes: DhtNode[]
|
|
19
|
-
|
|
20
15
|
let layer1Nodes: DhtNode[]
|
|
21
|
-
|
|
22
16
|
let epLayer0Node: DhtNode
|
|
23
17
|
let epLayer1Node: DhtNode
|
|
24
18
|
|
|
25
|
-
const websocketPortRange = { min: 62200, max: 62200 + NUM_OF_NODES }
|
|
26
|
-
|
|
27
19
|
beforeEach(async () => {
|
|
28
20
|
epLayer0Node = new DhtNode({
|
|
29
21
|
peerDescriptor: epPeerDescriptor,
|
|
@@ -41,7 +33,7 @@ describe('Layer1 Scale', () => {
|
|
|
41
33
|
|
|
42
34
|
for (let i = 0; i < NUM_OF_NODES; i++) {
|
|
43
35
|
const node = new DhtNode({
|
|
44
|
-
websocketPortRange,
|
|
36
|
+
websocketPortRange: WEBSOCKET_PORT_RANGE,
|
|
45
37
|
entryPoints: [epPeerDescriptor],
|
|
46
38
|
websocketServerEnableTls: false,
|
|
47
39
|
numberOfNodesPerKBucket: NUM_OF_NODES_PER_KBUCKET
|
|
@@ -75,10 +67,10 @@ describe('Layer1 Scale', () => {
|
|
|
75
67
|
// TODO: fix flaky test in NET-1021
|
|
76
68
|
it('bucket sizes', async () => {
|
|
77
69
|
layer0Nodes.forEach((node) => {
|
|
78
|
-
expect(node.
|
|
70
|
+
expect(node.getNeighborCount()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET - 1)
|
|
79
71
|
})
|
|
80
72
|
layer1Nodes.forEach((node ) => {
|
|
81
|
-
expect(node.
|
|
73
|
+
expect(node.getNeighborCount()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET / 2)
|
|
82
74
|
})
|
|
83
75
|
})
|
|
84
76
|
})
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
2
|
-
import {
|
|
3
|
-
import { PeerID } from '../../src/helpers/PeerID'
|
|
2
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
4
3
|
|
|
4
|
+
const STREAM_ID = 'stream'
|
|
5
|
+
const NUM_OF_NODES = 16
|
|
5
6
|
const NUM_OF_NODES_PER_KBUCKET = 8
|
|
6
7
|
|
|
7
8
|
describe('Layer1 Scale', () => {
|
|
8
|
-
const epPeerDescriptor: PeerDescriptor = {
|
|
9
|
-
kademliaId: PeerID.fromString('0').value,
|
|
10
|
-
type: NodeType.NODEJS,
|
|
11
|
-
websocket: { host: '127.0.0.1', port: 43228, tls: false }
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const STREAM_ID = 'stream'
|
|
15
|
-
|
|
16
|
-
const NUM_OF_NODES = 16
|
|
17
9
|
|
|
10
|
+
const epPeerDescriptor = createMockPeerDescriptor({
|
|
11
|
+
websocket: { host: '127.0.0.1', port: 43228, tls: false }
|
|
12
|
+
})
|
|
18
13
|
let layer0Nodes: DhtNode[]
|
|
19
|
-
|
|
20
14
|
let layer1Nodes: DhtNode[]
|
|
21
|
-
|
|
22
15
|
let epLayer0Node: DhtNode
|
|
23
16
|
let epLayer1Node: DhtNode
|
|
24
17
|
|
|
@@ -65,10 +58,10 @@ describe('Layer1 Scale', () => {
|
|
|
65
58
|
|
|
66
59
|
it('bucket sizes', async () => {
|
|
67
60
|
layer0Nodes.forEach((node) => {
|
|
68
|
-
expect(node.
|
|
61
|
+
expect(node.getNeighborCount()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET - 1)
|
|
69
62
|
})
|
|
70
63
|
layer1Nodes.forEach((node) => {
|
|
71
|
-
expect(node.
|
|
64
|
+
expect(node.getNeighborCount()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET / 2)
|
|
72
65
|
})
|
|
73
66
|
})
|
|
74
67
|
})
|
|
@@ -21,7 +21,7 @@ describe('Failed autocertification', () => {
|
|
|
21
21
|
entryPoints: [entryPointPeerDescriptor],
|
|
22
22
|
websocketServerEnableTls: true,
|
|
23
23
|
autoCertifierConfigFile: os.tmpdir() + '/failedAutoCertificationConfigFile.json',
|
|
24
|
-
autoCertifierUrl: 'http://
|
|
24
|
+
autoCertifierUrl: 'http://127.0.0.1:44444'
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
node = new DhtNode({
|
|
@@ -46,7 +46,7 @@ describe('Failed autocertification', () => {
|
|
|
46
46
|
const failedAutocertificationPeerDescriptor = failedAutocertificationNode.getLocalPeerDescriptor()
|
|
47
47
|
expect(failedAutocertificationPeerDescriptor.websocket!.tls).toBe(false)
|
|
48
48
|
await failedAutocertificationNode.joinDht([entryPointPeerDescriptor])
|
|
49
|
-
expect(failedAutocertificationNode.
|
|
49
|
+
expect(failedAutocertificationNode.getNeighborCount()).toEqual(2)
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
})
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
4
|
-
import { PeerID } from '../../src/helpers/PeerID'
|
|
5
4
|
import { waitForCondition } from '@streamr/utils'
|
|
6
|
-
import {
|
|
5
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
|
+
import { areEqualPeerDescriptors } from '../../src/identifiers'
|
|
7
7
|
|
|
8
8
|
describe('Websocket IConnection Requests', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type: NodeType.NODEJS,
|
|
9
|
+
|
|
10
|
+
const epPeerDescriptor = createMockPeerDescriptor({
|
|
12
11
|
websocket: { host: '127.0.0.1', port: 10021, tls: false }
|
|
13
|
-
}
|
|
12
|
+
})
|
|
14
13
|
let epDhtNode: DhtNode
|
|
15
14
|
let node1: DhtNode
|
|
16
15
|
let node2: DhtNode
|
|
@@ -63,8 +62,8 @@ describe('Websocket IConnection Requests', () => {
|
|
|
63
62
|
|
|
64
63
|
await waitForCondition(() => { return (connected1 && connected2) })
|
|
65
64
|
|
|
66
|
-
expect((node1.getTransport() as ConnectionManager).hasConnection(node2.
|
|
67
|
-
expect((node2.getTransport() as ConnectionManager).hasConnection(node1.
|
|
65
|
+
expect((node1.getTransport() as ConnectionManager).hasConnection(node2.getNodeId())).toEqual(true)
|
|
66
|
+
expect((node2.getTransport() as ConnectionManager).hasConnection(node1.getNodeId())).toEqual(true)
|
|
68
67
|
|
|
69
68
|
}, 10000)
|
|
70
69
|
})
|
|
@@ -1,59 +1,53 @@
|
|
|
1
1
|
import LeakDetector from 'jest-leak-detector'
|
|
2
|
-
import {
|
|
3
|
-
import { randomBytes } from 'crypto'
|
|
2
|
+
import { waitForCondition } from '@streamr/utils'
|
|
4
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
5
|
-
import { Message
|
|
4
|
+
import { Message } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
6
5
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
6
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
7
|
+
import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
7
8
|
|
|
8
9
|
const MESSAGE_ID = 'mock-message-id'
|
|
9
10
|
|
|
10
11
|
describe('memory leak', () => {
|
|
11
12
|
|
|
12
13
|
it('send message', async () => {
|
|
13
|
-
const entryPointDescriptor = {
|
|
14
|
-
kademliaId: randomBytes(10),
|
|
15
|
-
type: NodeType.NODEJS,
|
|
14
|
+
const entryPointDescriptor = createMockPeerDescriptor({
|
|
16
15
|
websocket: {
|
|
17
16
|
host: '127.0.0.1',
|
|
18
17
|
port: 11224,
|
|
19
18
|
tls: false
|
|
20
19
|
}
|
|
21
|
-
}
|
|
20
|
+
})
|
|
22
21
|
let entryPoint: DhtNode | undefined = new DhtNode({
|
|
23
|
-
|
|
22
|
+
nodeId: getNodeIdFromPeerDescriptor(entryPointDescriptor),
|
|
24
23
|
websocketHost: entryPointDescriptor.websocket!.host,
|
|
25
24
|
websocketPortRange: {
|
|
26
|
-
min: entryPointDescriptor.websocket
|
|
27
|
-
max: entryPointDescriptor.websocket
|
|
25
|
+
min: entryPointDescriptor.websocket!.port,
|
|
26
|
+
max: entryPointDescriptor.websocket!.port
|
|
28
27
|
},
|
|
29
28
|
entryPoints: [entryPointDescriptor],
|
|
30
29
|
websocketServerEnableTls: false
|
|
31
30
|
})
|
|
32
31
|
await entryPoint.start()
|
|
33
32
|
await entryPoint.joinDht([entryPointDescriptor])
|
|
34
|
-
let sender: DhtNode | undefined = new DhtNode({})
|
|
35
|
-
let receiver: DhtNode | undefined = new DhtNode({})
|
|
36
|
-
|
|
37
|
-
async () => {
|
|
33
|
+
let sender: DhtNode | undefined = new DhtNode({ entryPoints: [entryPointDescriptor] })
|
|
34
|
+
let receiver: DhtNode | undefined = new DhtNode({ entryPoints: [entryPointDescriptor] })
|
|
35
|
+
await Promise.all([
|
|
36
|
+
(async () => {
|
|
38
37
|
await sender.start()
|
|
39
38
|
await sender.joinDht([entryPointDescriptor])
|
|
40
|
-
},
|
|
41
|
-
async () => {
|
|
39
|
+
})(),
|
|
40
|
+
(async () => {
|
|
42
41
|
await receiver.start()
|
|
43
42
|
await receiver.joinDht([entryPointDescriptor])
|
|
44
|
-
}
|
|
45
|
-
])
|
|
46
|
-
await sender.start()
|
|
47
|
-
await sender.joinDht([entryPointDescriptor])
|
|
48
|
-
await receiver.start()
|
|
49
|
-
await receiver.joinDht([entryPointDescriptor])
|
|
43
|
+
})()
|
|
44
|
+
])
|
|
50
45
|
|
|
51
46
|
let receivedMessage: Message | undefined = undefined
|
|
52
47
|
receiver.on('message', (msg: Message) => receivedMessage = msg)
|
|
53
48
|
const msg: Message = {
|
|
54
49
|
serviceId: 'mock-service-id',
|
|
55
50
|
targetDescriptor: receiver.getLocalPeerDescriptor(),
|
|
56
|
-
messageType: MessageType.RPC,
|
|
57
51
|
messageId: 'mock-message-id',
|
|
58
52
|
body: {
|
|
59
53
|
oneofKind: 'rpcMessage',
|
|
@@ -72,6 +66,7 @@ describe('memory leak', () => {
|
|
|
72
66
|
|
|
73
67
|
const detector1 = new LeakDetector(entryPoint)
|
|
74
68
|
entryPoint = undefined
|
|
69
|
+
await detector1.isLeaking()
|
|
75
70
|
expect(await detector1.isLeaking()).toBe(false)
|
|
76
71
|
|
|
77
72
|
const detector2 = new LeakDetector(sender)
|
|
@@ -81,5 +76,5 @@ describe('memory leak', () => {
|
|
|
81
76
|
const detector3 = new LeakDetector(receiver)
|
|
82
77
|
receiver = undefined
|
|
83
78
|
expect(await detector3.isLeaking()).toBe(false)
|
|
84
|
-
})
|
|
79
|
+
}, 10000)
|
|
85
80
|
})
|