@streamr/dht 100.0.0-testnet-one.4 → 100.0.0-testnet-two.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/dist/src/connection/ConnectionLockHandler.d.ts +11 -11
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +4 -4
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +3 -5
- package/dist/src/connection/ConnectionLockRpcRemote.js +4 -7
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +4 -6
- package/dist/src/connection/ConnectionManager.js +48 -46
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +2 -2
- package/dist/src/connection/ConnectorFacade.js +2 -1
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +3 -6
- package/dist/src/connection/ManagedConnection.js +6 -10
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/connectivityChecker.js +1 -0
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.d.ts +0 -3
- package/dist/src/connection/simulator/Simulator.js +3 -51
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +5 -5
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +2 -2
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +0 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +7 -9
- 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 +11 -12
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +2 -5
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js +1 -4
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +1 -2
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +3 -4
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +2 -7
- package/dist/src/connection/websocket/WebsocketConnector.js +32 -38
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +3 -2
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +8 -10
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +3 -6
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js +0 -3
- 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 +11 -12
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +10 -13
- package/dist/src/dht/DhtNode.js +39 -52
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +0 -1
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +7 -7
- package/dist/src/dht/DhtNodeRpcRemote.js +8 -7
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +5 -4
- package/dist/src/dht/ExternalApiRpcLocal.js +3 -2
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -0
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +13 -14
- package/dist/src/dht/PeerManager.js +45 -60
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/Contact.d.ts +2 -2
- package/dist/src/dht/contact/Contact.js +2 -2
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/ContactList.d.ts +7 -7
- package/dist/src/dht/contact/ContactList.js +3 -3
- 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 +12 -11
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/RpcRemote.d.ts +7 -4
- package/dist/src/dht/contact/RpcRemote.js +5 -2
- package/dist/src/dht/contact/RpcRemote.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +13 -13
- package/dist/src/dht/contact/SortedContactList.js +33 -29
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +2 -4
- package/dist/src/dht/discovery/DiscoverySession.js +19 -20
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +2 -5
- package/dist/src/dht/discovery/PeerDiscovery.js +12 -20
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +36 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +165 -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/{find/FindRpcLocal.js → recursive-operation/RecursiveOperationRpcLocal.js} +7 -7
- 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/{routing/FindRpcRemote.js → recursive-operation/RecursiveOperationRpcRemote.js} +11 -11
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +42 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +182 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +12 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +17 -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/Router.d.ts +4 -19
- package/dist/src/dht/routing/Router.js +41 -33
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.js +6 -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 +20 -16
- package/dist/src/dht/routing/RoutingSession.js +37 -45
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +11 -13
- package/dist/src/dht/store/LocalDataStore.js +36 -56
- 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 +186 -0
- package/dist/src/dht/store/StoreManager.js.map +1 -0
- package/dist/src/dht/store/StoreRpcLocal.d.ts +8 -40
- package/dist/src/dht/store/StoreRpcLocal.js +13 -229
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +5 -5
- package/dist/src/dht/store/StoreRpcRemote.js +4 -5
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +2 -0
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/MapWithTtl.d.ts +14 -0
- package/dist/src/helpers/MapWithTtl.js +59 -0
- package/dist/src/helpers/MapWithTtl.js.map +1 -0
- package/dist/src/helpers/PeerID.d.ts +2 -0
- package/dist/src/helpers/PeerID.js +4 -0
- package/dist/src/helpers/PeerID.js.map +1 -1
- package/dist/src/helpers/nodeId.d.ts +5 -0
- package/dist/src/helpers/nodeId.js +18 -1
- package/dist/src/helpers/nodeId.js.map +1 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +2 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +2 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +2 -3
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +21 -22
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +18 -18
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +36 -60
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +34 -53
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +11 -12
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +2 -1
- 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 +9 -1
- package/dist/src/transport/ITransport.js +5 -0
- package/dist/src/transport/ITransport.js.map +1 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +1 -1
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/RoutingRpcCommunicator.js +16 -11
- 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 +11 -7
- package/package.json +6 -7
- package/protos/DhtRpc.proto +17 -23
- package/src/connection/ConnectionLockHandler.ts +15 -15
- package/src/connection/ConnectionLockRpcLocal.ts +8 -9
- package/src/connection/ConnectionLockRpcRemote.ts +7 -16
- package/src/connection/ConnectionManager.ts +58 -55
- package/src/connection/ConnectorFacade.ts +3 -0
- package/src/connection/ManagedConnection.ts +12 -30
- package/src/connection/connectivityChecker.ts +1 -0
- package/src/connection/simulator/Simulator.ts +5 -36
- package/src/connection/simulator/SimulatorConnector.ts +8 -8
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +0 -3
- package/src/connection/webrtc/NodeWebrtcConnection.ts +3 -4
- package/src/connection/webrtc/WebrtcConnector.ts +11 -13
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +16 -16
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +3 -13
- package/src/connection/websocket/AutoCertifierClientFacade.ts +4 -6
- package/src/connection/websocket/ClientWebsocket.ts +1 -0
- package/src/connection/websocket/WebsocketConnector.ts +43 -56
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +11 -13
- package/src/connection/websocket/WebsocketConnectorRpcRemote.ts +4 -15
- package/src/connection/websocket/WebsocketServer.ts +14 -17
- package/src/dht/DhtNode.ts +67 -69
- package/src/dht/DhtNodeRpcLocal.ts +0 -1
- package/src/dht/DhtNodeRpcRemote.ts +13 -13
- package/src/dht/ExternalApiRpcLocal.ts +16 -6
- package/src/dht/ExternalApiRpcRemote.ts +5 -3
- package/src/dht/PeerManager.ts +73 -90
- package/src/dht/contact/Contact.ts +5 -4
- package/src/dht/contact/ContactList.ts +9 -9
- package/src/dht/contact/RandomContactList.ts +14 -14
- package/src/dht/contact/RpcRemote.ts +10 -7
- package/src/dht/contact/SortedContactList.ts +48 -45
- package/src/dht/discovery/DiscoverySession.ts +25 -25
- package/src/dht/discovery/PeerDiscovery.ts +16 -37
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +240 -0
- package/src/dht/{find/FindRpcLocal.ts → recursive-operation/RecursiveOperationRpcLocal.ts} +9 -9
- package/src/dht/{routing/FindRpcRemote.ts → recursive-operation/RecursiveOperationRpcRemote.ts} +10 -10
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +224 -0
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +25 -0
- package/src/dht/{find/FindSessionRpcRemote.ts → recursive-operation/RecursiveOperationSessionRpcRemote.ts} +8 -8
- package/src/dht/routing/Router.ts +45 -64
- package/src/dht/routing/RouterRpcLocal.ts +7 -6
- package/src/dht/routing/RouterRpcRemote.ts +9 -10
- package/src/dht/routing/RoutingSession.ts +59 -68
- package/src/dht/store/LocalDataStore.ts +47 -66
- package/src/dht/store/StoreManager.ts +217 -0
- package/src/dht/store/StoreRpcLocal.ts +26 -302
- package/src/dht/store/StoreRpcRemote.ts +9 -11
- package/src/exports.ts +2 -0
- package/src/helpers/MapWithTtl.ts +71 -0
- package/src/helpers/PeerID.ts +5 -0
- package/src/helpers/nodeId.ts +20 -0
- package/src/helpers/peerIdFromPeerDescriptor.ts +5 -3
- package/src/helpers/protoClasses.ts +4 -6
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +31 -32
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +11 -12
- package/src/proto/packages/dht/protos/DhtRpc.ts +49 -80
- package/src/rpc-protocol/DhtCallContext.ts +2 -1
- package/src/rpc-protocol/DhtRpcOptions.ts +2 -1
- package/src/transport/ITransport.ts +10 -1
- package/src/transport/ListeningRpcCommunicator.ts +1 -1
- package/src/transport/RoutingRpcCommunicator.ts +18 -12
- package/test/benchmark/Find.test.ts +8 -21
- package/test/benchmark/KademliaCorrectness.test.ts +11 -20
- package/test/benchmark/SortedContactListBenchmark.test.ts +9 -9
- package/test/benchmark/kademlia-simulation/Contact.ts +9 -8
- package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +2 -2
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +17 -17
- package/test/end-to-end/Layer0-Layer1.test.ts +10 -14
- package/test/end-to-end/Layer0.test.ts +15 -18
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +7 -9
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +4 -10
- package/test/end-to-end/Layer0Webrtc.test.ts +5 -6
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +8 -16
- package/test/end-to-end/Layer1-Scale-Webrtc.test.ts +6 -13
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +5 -6
- package/test/end-to-end/memory-leak.test.ts +6 -8
- package/test/integration/ConnectionLocking.test.ts +6 -13
- package/test/integration/ConnectionManager.test.ts +26 -43
- package/test/integration/DhtJoinPeerDiscovery.test.ts +5 -10
- package/test/integration/DhtNodeExternalAPI.test.ts +16 -22
- package/test/integration/DhtNodeRpcRemote.test.ts +13 -22
- package/test/integration/DhtRpc.test.ts +13 -18
- package/test/integration/Find.test.ts +10 -10
- package/test/integration/Layer1-scale.test.ts +17 -28
- package/test/integration/Mock-Layer1-Layer0.test.ts +25 -43
- package/test/integration/MultipleEntryPointJoining.test.ts +7 -7
- package/test/integration/ReplicateData.test.ts +28 -30
- package/test/integration/RouteMessage.test.ts +30 -27
- package/test/integration/RouterRpcRemote.test.ts +12 -18
- package/test/integration/RpcErrors.test.ts +8 -21
- package/test/integration/ScaleDownDht.test.ts +11 -10
- package/test/integration/SimultaneousConnections.test.ts +43 -67
- package/test/integration/Store.test.ts +23 -36
- package/test/integration/StoreAndDelete.test.ts +30 -50
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +16 -37
- package/test/integration/StoreRpcRemote.test.ts +20 -30
- package/test/integration/WebrtcConnectionManagement.test.ts +3 -13
- package/test/integration/WebrtcConnectorRpc.test.ts +3 -9
- package/test/integration/WebsocketConnectionManagement.test.ts +7 -10
- package/test/integration/WebsocketConnectorRpc.test.ts +8 -17
- package/test/unit/ConnectivityHelpers.test.ts +9 -17
- package/test/unit/DuplicateDetector.test.ts +7 -4
- package/test/unit/LocalDataStore.test.ts +66 -77
- package/test/unit/PeerManager.test.ts +31 -0
- package/test/unit/RandomContactList.test.ts +13 -8
- package/test/unit/{Finder.test.ts → RecursiveOperationManager.test.ts} +38 -43
- package/test/unit/RecursiveOperationSession.test.ts +68 -0
- package/test/unit/Router.test.ts +15 -22
- package/test/unit/RoutingSession.test.ts +23 -25
- package/test/unit/SortedContactList.test.ts +41 -26
- package/test/unit/StoreManager.test.ts +132 -0
- package/test/unit/WebsocketConnector.test.ts +27 -35
- package/test/unit/customMatchers.test.ts +16 -0
- package/test/utils/FakeTransport.ts +44 -0
- package/test/utils/customMatchers.ts +70 -0
- package/test/utils/mock/MockRpcCommunicator.ts +7 -0
- package/test/utils/mock/Router.ts +3 -2
- package/test/utils/mock/mockDataEntry.ts +36 -0
- package/test/utils/utils.ts +49 -87
- package/dist/src/dht/find/FindRpcLocal.d.ts +0 -14
- 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 -150
- 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 -197
- 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.map +0 -1
- package/src/dht/find/FindSession.ts +0 -183
- package/src/dht/find/FindSessionRpcLocal.ts +0 -25
- package/src/dht/find/Finder.ts +0 -295
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
|
-
import {
|
|
4
|
+
import { RecursiveOperation } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
6
6
|
import { execSync } from 'child_process'
|
|
7
7
|
import fs from 'fs'
|
|
@@ -15,12 +15,9 @@ const logger = new Logger(module)
|
|
|
15
15
|
describe('Find correctness', () => {
|
|
16
16
|
let entryPoint: DhtNode
|
|
17
17
|
let nodes: DhtNode[]
|
|
18
|
-
let entrypointDescriptor: PeerDescriptor
|
|
19
18
|
const simulator = new Simulator(LatencyType.NONE)
|
|
20
19
|
const NUM_NODES = 1000
|
|
21
20
|
|
|
22
|
-
const nodeIndicesById: Record<string, number> = {}
|
|
23
|
-
|
|
24
21
|
if (!fs.existsSync('test/data/nodeids.json')) {
|
|
25
22
|
console.log('ground truth data does not exist yet, generating..')
|
|
26
23
|
execSync('npm run prepare-kademlia-simulation')
|
|
@@ -31,20 +28,10 @@ describe('Find correctness', () => {
|
|
|
31
28
|
beforeEach(async () => {
|
|
32
29
|
|
|
33
30
|
nodes = []
|
|
34
|
-
|
|
35
|
-
entryPoint = await createMockConnectionDhtNode(entryPointId, simulator, Uint8Array.from(dhtIds[0].data), undefined)
|
|
36
|
-
nodes.push(entryPoint)
|
|
37
|
-
nodeIndicesById[entryPoint.getNodeId().toKey()] = 0
|
|
38
|
-
entrypointDescriptor = {
|
|
39
|
-
nodeId: entryPoint.getNodeId().value,
|
|
40
|
-
type: NodeType.NODEJS
|
|
41
|
-
}
|
|
31
|
+
entryPoint = await createMockConnectionDhtNode(simulator, Uint8Array.from(dhtIds[0].data), undefined)
|
|
42
32
|
|
|
43
33
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const node = await createMockConnectionDhtNode(nodeId, simulator, Uint8Array.from(dhtIds[i].data), undefined)
|
|
47
|
-
nodeIndicesById[node.getNodeId().toKey()] = i
|
|
34
|
+
const node = await createMockConnectionDhtNode(simulator, Uint8Array.from(dhtIds[i].data), undefined)
|
|
48
35
|
nodes.push(node)
|
|
49
36
|
}
|
|
50
37
|
})
|
|
@@ -57,10 +44,10 @@ describe('Find correctness', () => {
|
|
|
57
44
|
})
|
|
58
45
|
|
|
59
46
|
it('Entrypoint can find a node from the network (exact match)', async () => {
|
|
60
|
-
await entryPoint.joinDht([
|
|
47
|
+
await entryPoint.joinDht([entryPoint.getLocalPeerDescriptor()])
|
|
61
48
|
|
|
62
49
|
await Promise.all(
|
|
63
|
-
nodes.map((node) => node.joinDht([
|
|
50
|
+
nodes.map((node) => node.joinDht([entryPoint.getLocalPeerDescriptor()]))
|
|
64
51
|
)
|
|
65
52
|
|
|
66
53
|
logger.info('waiting 120s')
|
|
@@ -77,11 +64,11 @@ describe('Find correctness', () => {
|
|
|
77
64
|
+ ', weakLocked: ' + node.getNumberOfWeakLockedConnections()))
|
|
78
65
|
|
|
79
66
|
logger.info('starting find')
|
|
80
|
-
const
|
|
81
|
-
const results = await nodes[159].
|
|
67
|
+
const targetId = Uint8Array.from(dhtIds[9].data)
|
|
68
|
+
const results = await nodes[159].executeRecursiveOperation(targetId, RecursiveOperation.FIND_NODE)
|
|
82
69
|
logger.info('find over')
|
|
83
70
|
expect(results.closestNodes).toBeGreaterThanOrEqual(5)
|
|
84
|
-
expect(PeerID.fromValue(
|
|
71
|
+
expect(PeerID.fromValue(targetId).equals(peerIdFromPeerDescriptor(results.closestNodes[0])))
|
|
85
72
|
|
|
86
73
|
}, 180000)
|
|
87
74
|
})
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
|
-
import { PeerID } from '../../src/helpers/PeerID'
|
|
5
4
|
import { getNodeIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
6
|
-
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
7
5
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
8
6
|
import { execSync } from 'child_process'
|
|
9
7
|
import fs from 'fs'
|
|
8
|
+
import { NodeID } from '../../src/helpers/nodeId'
|
|
10
9
|
|
|
11
10
|
describe('Kademlia correctness', () => {
|
|
12
11
|
let entryPoint: DhtNode
|
|
13
12
|
let nodes: DhtNode[]
|
|
14
|
-
let entrypointDescriptor: PeerDescriptor
|
|
15
13
|
const simulator = new Simulator()
|
|
16
14
|
const NUM_NODES = 1000
|
|
17
15
|
|
|
18
|
-
const nodeIndicesById: Record<
|
|
16
|
+
const nodeIndicesById: Record<NodeID, number> = {}
|
|
19
17
|
|
|
20
18
|
if (!fs.existsSync('test/data/nodeids.json')) {
|
|
21
19
|
console.log('gound truth data does not exist yet, generating..')
|
|
@@ -29,20 +27,13 @@ describe('Kademlia correctness', () => {
|
|
|
29
27
|
beforeEach(async () => {
|
|
30
28
|
|
|
31
29
|
nodes = []
|
|
32
|
-
|
|
33
|
-
entryPoint = await createMockConnectionDhtNode(entryPointId, simulator, Uint8Array.from(dhtIds[0].data), 8)
|
|
30
|
+
entryPoint = await createMockConnectionDhtNode(simulator, Uint8Array.from(dhtIds[0].data), 8)
|
|
34
31
|
nodes.push(entryPoint)
|
|
35
|
-
nodeIndicesById[entryPoint.getNodeId()
|
|
36
|
-
entrypointDescriptor = {
|
|
37
|
-
nodeId: entryPoint.getNodeId().value,
|
|
38
|
-
type: NodeType.NODEJS
|
|
39
|
-
}
|
|
32
|
+
nodeIndicesById[entryPoint.getNodeId()] = 0
|
|
40
33
|
|
|
41
34
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const node = await createMockConnectionDhtNode(nodeId, simulator, Uint8Array.from(dhtIds[i].data))
|
|
45
|
-
nodeIndicesById[node.getNodeId().toKey()] = i
|
|
35
|
+
const node = await createMockConnectionDhtNode(simulator, Uint8Array.from(dhtIds[i].data))
|
|
36
|
+
nodeIndicesById[node.getNodeId()] = i
|
|
46
37
|
nodes.push(node)
|
|
47
38
|
}
|
|
48
39
|
})
|
|
@@ -55,10 +46,10 @@ describe('Kademlia correctness', () => {
|
|
|
55
46
|
})
|
|
56
47
|
|
|
57
48
|
it('Can find correct neighbors', async () => {
|
|
58
|
-
await entryPoint.joinDht([
|
|
49
|
+
await entryPoint.joinDht([entryPoint.getLocalPeerDescriptor()])
|
|
59
50
|
|
|
60
51
|
await Promise.allSettled(
|
|
61
|
-
nodes.map((node) => node.joinDht([
|
|
52
|
+
nodes.map((node) => node.joinDht([entryPoint.getLocalPeerDescriptor()]))
|
|
62
53
|
)
|
|
63
54
|
|
|
64
55
|
let minimumCorrectNeighbors = Number.MAX_SAFE_INTEGER
|
|
@@ -72,17 +63,17 @@ describe('Kademlia correctness', () => {
|
|
|
72
63
|
groundTruthString += groundTruth[i + ''][j].name + ','
|
|
73
64
|
}
|
|
74
65
|
|
|
75
|
-
const kademliaNeighbors = nodes[i].getClosestContacts().map((p) =>
|
|
66
|
+
const kademliaNeighbors = nodes[i].getClosestContacts().map((p) => getNodeIdFromPeerDescriptor(p))
|
|
76
67
|
|
|
77
68
|
let kadString = 'kademliaNeighbors: '
|
|
78
69
|
kademliaNeighbors.forEach((neighbor) => {
|
|
79
|
-
kadString += nodeIndicesById[neighbor
|
|
70
|
+
kadString += nodeIndicesById[neighbor] + ','
|
|
80
71
|
})
|
|
81
72
|
|
|
82
73
|
let correctNeighbors = 0
|
|
83
74
|
try {
|
|
84
75
|
for (let j = 0; j < groundTruth[i + ''].length; j++) {
|
|
85
|
-
if (groundTruth[i + ''][j].name != (nodeIndicesById[kademliaNeighbors[j]
|
|
76
|
+
if (groundTruth[i + ''][j].name != (nodeIndicesById[kademliaNeighbors[j]] + '')) {
|
|
86
77
|
break
|
|
87
78
|
}
|
|
88
79
|
correctNeighbors++
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
import KBucket from 'k-bucket'
|
|
4
4
|
import { SortedContactList } from '../../src/dht/contact/SortedContactList'
|
|
5
|
-
import { PeerID } from '../../src/helpers/PeerID'
|
|
6
5
|
import crypto from 'crypto'
|
|
6
|
+
import { NodeID, getNodeIdFromBinary } from '../../src/helpers/nodeId'
|
|
7
7
|
|
|
8
8
|
const NUM_ADDS = 1000
|
|
9
9
|
interface Item {
|
|
10
10
|
id: Uint8Array
|
|
11
11
|
vectorClock: number
|
|
12
|
-
|
|
12
|
+
getNodeId: () => NodeID
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const createRandomItem = (index: number): Item => {
|
|
16
16
|
const rand = new Uint8Array(crypto.randomBytes(20))
|
|
17
17
|
return {
|
|
18
|
-
|
|
18
|
+
getNodeId: () => getNodeIdFromBinary(rand),
|
|
19
19
|
id: rand,
|
|
20
20
|
vectorClock: index
|
|
21
21
|
}
|
|
@@ -37,7 +37,7 @@ describe('SortedContactListBenchmark', () => {
|
|
|
37
37
|
randomIds.push(createRandomItem(i))
|
|
38
38
|
}
|
|
39
39
|
const list = new SortedContactList({
|
|
40
|
-
referenceId:
|
|
40
|
+
referenceId: getNodeIdFromBinary(crypto.randomBytes(20)),
|
|
41
41
|
allowToContainReferenceId: true,
|
|
42
42
|
emitEvents: true
|
|
43
43
|
})
|
|
@@ -49,7 +49,7 @@ describe('SortedContactListBenchmark', () => {
|
|
|
49
49
|
console.timeEnd('SortedContactList.addContact() with emitEvents=true')
|
|
50
50
|
|
|
51
51
|
const list2 = new SortedContactList({
|
|
52
|
-
referenceId:
|
|
52
|
+
referenceId: getNodeIdFromBinary(crypto.randomBytes(20)),
|
|
53
53
|
allowToContainReferenceId: true,
|
|
54
54
|
emitEvents: false
|
|
55
55
|
})
|
|
@@ -83,7 +83,7 @@ describe('SortedContactListBenchmark', () => {
|
|
|
83
83
|
console.time('SortedContactList.getClosestContacts() with emitEvents=true')
|
|
84
84
|
for (let i = 0; i < NUM_ADDS; i++) {
|
|
85
85
|
const closest = new SortedContactList<Item>({
|
|
86
|
-
referenceId:
|
|
86
|
+
referenceId: getNodeIdFromBinary(crypto.randomBytes(20)),
|
|
87
87
|
allowToContainReferenceId: true,
|
|
88
88
|
emitEvents: true
|
|
89
89
|
})
|
|
@@ -97,7 +97,7 @@ describe('SortedContactListBenchmark', () => {
|
|
|
97
97
|
console.time('SortedContactList.getClosestContacts() with emitEvents=false')
|
|
98
98
|
for (let i = 0; i < NUM_ADDS; i++) {
|
|
99
99
|
const closest = new SortedContactList<Item>({
|
|
100
|
-
referenceId:
|
|
100
|
+
referenceId: getNodeIdFromBinary(crypto.randomBytes(20)),
|
|
101
101
|
allowToContainReferenceId: true,
|
|
102
102
|
emitEvents: false
|
|
103
103
|
})
|
|
@@ -111,7 +111,7 @@ describe('SortedContactListBenchmark', () => {
|
|
|
111
111
|
console.time('SortedContactList.getClosestContacts() with emitEvents=false and lodash')
|
|
112
112
|
for (let i = 0; i < NUM_ADDS; i++) {
|
|
113
113
|
const closest = new SortedContactList<Item>({
|
|
114
|
-
referenceId:
|
|
114
|
+
referenceId: getNodeIdFromBinary(crypto.randomBytes(20)),
|
|
115
115
|
allowToContainReferenceId: true,
|
|
116
116
|
emitEvents: false
|
|
117
117
|
})
|
|
@@ -125,7 +125,7 @@ describe('SortedContactListBenchmark', () => {
|
|
|
125
125
|
console.time('SortedContactList.getClosestContacts() with emitEvents=false and addContacts()')
|
|
126
126
|
for (let i = 0; i < NUM_ADDS; i++) {
|
|
127
127
|
const closest = new SortedContactList<Item>({
|
|
128
|
-
referenceId:
|
|
128
|
+
referenceId: getNodeIdFromBinary(crypto.randomBytes(20)),
|
|
129
129
|
allowToContainReferenceId: true,
|
|
130
130
|
emitEvents: false
|
|
131
131
|
})
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { PeerID } from '../../../src/helpers/PeerID'
|
|
2
1
|
import type { SimulationNode } from './SimulationNode'
|
|
3
2
|
import { NodeType, PeerDescriptor } from '../../../src/proto/packages/dht/protos/DhtRpc'
|
|
3
|
+
import { NodeID } from '../../../src/helpers/nodeId'
|
|
4
|
+
import { hexToBinary } from '@streamr/utils'
|
|
4
5
|
|
|
5
6
|
export class Contact {
|
|
6
7
|
private static counter = 0
|
|
7
8
|
|
|
8
|
-
public
|
|
9
|
+
public ownId: NodeID
|
|
9
10
|
public id: Uint8Array
|
|
10
11
|
public vectorClock = 0
|
|
11
12
|
public dhtNode: SimulationNode | undefined
|
|
12
13
|
|
|
13
|
-
constructor(ownId:
|
|
14
|
-
this.
|
|
14
|
+
constructor(ownId: NodeID, dhtNode?: SimulationNode) {
|
|
15
|
+
this.ownId = ownId
|
|
15
16
|
this.vectorClock = Contact.counter++
|
|
16
17
|
this.dhtNode = dhtNode
|
|
17
|
-
this.id = ownId
|
|
18
|
+
this.id = hexToBinary(ownId)
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
getPeerDescriptor(): PeerDescriptor {
|
|
21
22
|
const peerDescriptor: PeerDescriptor = {
|
|
22
|
-
nodeId: this.
|
|
23
|
+
nodeId: hexToBinary(this.ownId),
|
|
23
24
|
type: NodeType.NODEJS
|
|
24
25
|
}
|
|
25
26
|
return peerDescriptor
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
return this.
|
|
29
|
+
getNodeId(): NodeID {
|
|
30
|
+
return this.ownId
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { SimulationNode } from './SimulationNode'
|
|
4
4
|
import fs from 'fs'
|
|
5
|
-
import {
|
|
5
|
+
import { getNodeIdFromBinary } from '../../../src/helpers/nodeId'
|
|
6
6
|
|
|
7
7
|
export class KademliaSimulation {
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@ export class KademliaSimulation {
|
|
|
25
25
|
|
|
26
26
|
public run(): void {
|
|
27
27
|
for (let i = 0; i < KademliaSimulation.NUM_NODES; i++) {
|
|
28
|
-
const node = new SimulationNode(
|
|
28
|
+
const node = new SimulationNode(getNodeIdFromBinary(Buffer.from(this.dhtIds[i].data.slice(0, KademliaSimulation.ID_LENGTH))))
|
|
29
29
|
this.nodeNamesById[JSON.stringify(node.getContact().id)] = i
|
|
30
30
|
this.nodes.push(node)
|
|
31
31
|
node.joinDht(this.nodes[0])
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import KBucket from 'k-bucket'
|
|
2
2
|
import { Contact } from './Contact'
|
|
3
3
|
import { SortedContactList } from '../../../src/dht/contact/SortedContactList'
|
|
4
|
-
import {
|
|
4
|
+
import { NodeID, areEqualNodeIds } from '../../../src/helpers/nodeId'
|
|
5
|
+
import { hexToBinary } from '@streamr/utils'
|
|
5
6
|
|
|
6
7
|
export class SimulationNode {
|
|
7
8
|
|
|
@@ -16,18 +17,18 @@ export class SimulationNode {
|
|
|
16
17
|
private numberOfOutgoingRpcCalls = 0
|
|
17
18
|
|
|
18
19
|
private neighborList: SortedContactList<Contact>
|
|
19
|
-
private ownId:
|
|
20
|
+
private ownId: NodeID
|
|
20
21
|
|
|
21
|
-
constructor(ownId:
|
|
22
|
+
constructor(ownId: NodeID) {
|
|
22
23
|
this.ownId = ownId
|
|
23
24
|
this.ownContact = new Contact(this.ownId, this)
|
|
24
25
|
this.bucket = new KBucket({
|
|
25
|
-
localNodeId: this.ownId
|
|
26
|
+
localNodeId: hexToBinary(this.ownId),
|
|
26
27
|
numberOfNodesPerKBucket: this.numberOfNodesPerKBucket
|
|
27
28
|
})
|
|
28
29
|
|
|
29
30
|
this.neighborList = new SortedContactList({
|
|
30
|
-
referenceId: this.ownId,
|
|
31
|
+
referenceId: this.ownId,
|
|
31
32
|
maxSize: 1000,
|
|
32
33
|
allowToContainReferenceId: false,
|
|
33
34
|
emitEvents: false
|
|
@@ -57,23 +58,22 @@ export class SimulationNode {
|
|
|
57
58
|
|
|
58
59
|
// RPC call
|
|
59
60
|
|
|
60
|
-
public getClosestNodesTo(id:
|
|
61
|
+
public getClosestNodesTo(id: NodeID, caller: SimulationNode): Contact[] {
|
|
61
62
|
this.numberOfIncomingRpcCalls++
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
if (!this.bucket.get(
|
|
65
|
-
const contact = new Contact(
|
|
63
|
+
const idValue = hexToBinary(id)
|
|
64
|
+
const ret = this.bucket.closest(idValue)
|
|
65
|
+
if (!this.bucket.get(idValue)) {
|
|
66
|
+
const contact = new Contact(id, caller)
|
|
66
67
|
this.bucket.add(contact)
|
|
67
68
|
this.neighborList.addContact(contact)
|
|
68
69
|
}
|
|
69
|
-
|
|
70
70
|
return ret
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
private findMoreContacts(contactList: Contact[], shortlist: SortedContactList<Contact>) {
|
|
74
74
|
contactList.forEach((contact) => {
|
|
75
|
-
shortlist.setContacted(contact.
|
|
76
|
-
shortlist.setActive(contact.
|
|
75
|
+
shortlist.setContacted(contact.getNodeId())
|
|
76
|
+
shortlist.setActive(contact.getNodeId())
|
|
77
77
|
this.numberOfOutgoingRpcCalls++
|
|
78
78
|
const returnedContacts = contact.dhtNode!.getClosestNodesTo(this.ownId, this)
|
|
79
79
|
shortlist.addContacts(returnedContacts)
|
|
@@ -86,12 +86,12 @@ export class SimulationNode {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
public joinDht(entryPoint: SimulationNode): void {
|
|
89
|
-
if (entryPoint.getContact().
|
|
89
|
+
if (areEqualNodeIds(entryPoint.getContact().getNodeId(), this.ownId)) {
|
|
90
90
|
return
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
this.bucket.add(entryPoint.getContact())
|
|
94
|
-
const closest = this.bucket.closest(this.ownId
|
|
94
|
+
const closest = this.bucket.closest(hexToBinary(this.ownId), this.ALPHA)
|
|
95
95
|
|
|
96
96
|
this.neighborList.addContacts(closest)
|
|
97
97
|
|
|
@@ -105,7 +105,7 @@ export class SimulationNode {
|
|
|
105
105
|
|
|
106
106
|
this.findMoreContacts(uncontacted, this.neighborList)
|
|
107
107
|
|
|
108
|
-
if (oldClosestContactId
|
|
108
|
+
if (areEqualNodeIds(oldClosestContactId, this.neighborList.getClosestContactId())) {
|
|
109
109
|
uncontacted = this.neighborList.getUncontactedContacts(this.K)
|
|
110
110
|
if (uncontacted.length === 0) {
|
|
111
111
|
return
|
|
@@ -116,7 +116,7 @@ export class SimulationNode {
|
|
|
116
116
|
this.findMoreContacts(uncontacted, this.neighborList)
|
|
117
117
|
|
|
118
118
|
if (this.neighborList.getActiveContacts().length >= this.K ||
|
|
119
|
-
oldClosestContactId
|
|
119
|
+
areEqualNodeIds(oldClosestContactId, this.neighborList.getClosestContactId())) {
|
|
120
120
|
return
|
|
121
121
|
}
|
|
122
122
|
uncontacted = this.neighborList.getUncontactedContacts(this.ALPHA)
|
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
2
1
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
2
|
import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
3
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type: NodeType.NODEJS,
|
|
9
|
-
websocket: { host: '127.0.0.1', port: 10016, tls: false }
|
|
10
|
-
}
|
|
5
|
+
const STREAM_ID1 = 'stream1'
|
|
6
|
+
const STREAM_ID2 = 'stream2'
|
|
7
|
+
const WEBSOCKET_PORT_RANGE = { min: 10017, max: 10018 }
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
const STREAM_ID2 = 'stream2'
|
|
9
|
+
describe('Layer0-Layer1', () => {
|
|
14
10
|
|
|
11
|
+
const epPeerDescriptor = createMockPeerDescriptor({
|
|
12
|
+
websocket: { host: '127.0.0.1', port: 10016, tls: false }
|
|
13
|
+
})
|
|
15
14
|
let epDhtNode: DhtNode
|
|
16
15
|
let node1: DhtNode
|
|
17
16
|
let node2: DhtNode
|
|
18
|
-
|
|
19
17
|
let stream1Node1: DhtNode
|
|
20
18
|
let stream1Node2: DhtNode
|
|
21
19
|
let stream2Node1: DhtNode
|
|
22
20
|
let stream2Node2: DhtNode
|
|
23
21
|
|
|
24
|
-
const websocketPortRange = { min: 10017, max: 10018 }
|
|
25
|
-
|
|
26
22
|
beforeEach(async () => {
|
|
27
23
|
|
|
28
24
|
epDhtNode = new DhtNode({ peerDescriptor: epPeerDescriptor, websocketServerEnableTls: false })
|
|
@@ -30,12 +26,12 @@ describe('Layer0-Layer1', () => {
|
|
|
30
26
|
await epDhtNode.joinDht([epPeerDescriptor])
|
|
31
27
|
|
|
32
28
|
node1 = new DhtNode({
|
|
33
|
-
websocketPortRange,
|
|
29
|
+
websocketPortRange: WEBSOCKET_PORT_RANGE,
|
|
34
30
|
entryPoints: [epPeerDescriptor],
|
|
35
31
|
websocketServerEnableTls: false
|
|
36
32
|
})
|
|
37
33
|
node2 = new DhtNode({
|
|
38
|
-
websocketPortRange,
|
|
34
|
+
websocketPortRange: WEBSOCKET_PORT_RANGE,
|
|
39
35
|
entryPoints: [epPeerDescriptor],
|
|
40
36
|
websocketServerEnableTls: false
|
|
41
37
|
})
|
|
@@ -1,46 +1,43 @@
|
|
|
1
|
-
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
2
1
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
2
|
|
|
3
|
+
const WEBSOCKET_PORT_RANGE = { min: 10012, max: 10015 }
|
|
4
|
+
|
|
4
5
|
describe('Layer0', () => {
|
|
5
6
|
|
|
6
|
-
let epPeerDescriptor: PeerDescriptor
|
|
7
|
-
|
|
8
7
|
let epDhtNode: DhtNode
|
|
9
8
|
let node1: DhtNode
|
|
10
9
|
let node2: DhtNode
|
|
11
10
|
let node3: DhtNode
|
|
12
11
|
let node4: DhtNode
|
|
13
12
|
|
|
14
|
-
const websocketPortRange = { min: 10012, max: 10015 }
|
|
15
13
|
beforeEach(async () => {
|
|
16
14
|
|
|
17
15
|
epDhtNode = new DhtNode({ websocketHost: '127.0.0.1', websocketPortRange: { min: 10011, max: 10011 }, websocketServerEnableTls: false })
|
|
18
16
|
await epDhtNode.start()
|
|
19
|
-
|
|
20
|
-
await epDhtNode.joinDht([epPeerDescriptor])
|
|
17
|
+
await epDhtNode.joinDht([epDhtNode.getLocalPeerDescriptor()])
|
|
21
18
|
|
|
22
19
|
node1 = new DhtNode({
|
|
23
|
-
websocketPortRange,
|
|
20
|
+
websocketPortRange: WEBSOCKET_PORT_RANGE,
|
|
24
21
|
websocketHost: '127.0.0.1',
|
|
25
|
-
entryPoints: [
|
|
22
|
+
entryPoints: [epDhtNode.getLocalPeerDescriptor()],
|
|
26
23
|
websocketServerEnableTls: false
|
|
27
24
|
})
|
|
28
25
|
node2 = new DhtNode({
|
|
29
|
-
websocketPortRange,
|
|
26
|
+
websocketPortRange: WEBSOCKET_PORT_RANGE,
|
|
30
27
|
websocketHost: '127.0.0.1',
|
|
31
|
-
entryPoints: [
|
|
28
|
+
entryPoints: [epDhtNode.getLocalPeerDescriptor()],
|
|
32
29
|
websocketServerEnableTls: false
|
|
33
30
|
})
|
|
34
31
|
node3 = new DhtNode({
|
|
35
|
-
websocketPortRange,
|
|
32
|
+
websocketPortRange: WEBSOCKET_PORT_RANGE,
|
|
36
33
|
websocketHost: '127.0.0.1',
|
|
37
|
-
entryPoints: [
|
|
34
|
+
entryPoints: [epDhtNode.getLocalPeerDescriptor()],
|
|
38
35
|
websocketServerEnableTls: false
|
|
39
36
|
})
|
|
40
37
|
node4 = new DhtNode({
|
|
41
|
-
websocketPortRange,
|
|
38
|
+
websocketPortRange: WEBSOCKET_PORT_RANGE,
|
|
42
39
|
websocketHost: '127.0.0.1',
|
|
43
|
-
entryPoints: [
|
|
40
|
+
entryPoints: [epDhtNode.getLocalPeerDescriptor()],
|
|
44
41
|
websocketServerEnableTls: false
|
|
45
42
|
})
|
|
46
43
|
|
|
@@ -65,10 +62,10 @@ describe('Layer0', () => {
|
|
|
65
62
|
|
|
66
63
|
it('Happy path', async () => {
|
|
67
64
|
await Promise.all([
|
|
68
|
-
node1.joinDht([
|
|
69
|
-
node2.joinDht([
|
|
70
|
-
node3.joinDht([
|
|
71
|
-
node4.joinDht([
|
|
65
|
+
node1.joinDht([epDhtNode.getLocalPeerDescriptor()]),
|
|
66
|
+
node2.joinDht([epDhtNode.getLocalPeerDescriptor()]),
|
|
67
|
+
node3.joinDht([epDhtNode.getLocalPeerDescriptor()]),
|
|
68
|
+
node4.joinDht([epDhtNode.getLocalPeerDescriptor()])
|
|
72
69
|
])
|
|
73
70
|
|
|
74
71
|
expect(node1.getNumberOfNeighbors()).toBeGreaterThanOrEqual(2)
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
2
1
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
2
|
import { waitForEvent3 } from '@streamr/utils'
|
|
4
3
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
5
4
|
import { TransportEvents } from '../../src/transport/ITransport'
|
|
5
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
|
+
|
|
7
|
+
const WEBSOCKET_PORT_RANGE = { min: 11222, max: 11223 }
|
|
6
8
|
|
|
7
9
|
describe('Layer0MixedConnectionTypes', () => {
|
|
8
10
|
|
|
9
|
-
const epPeerDescriptor
|
|
10
|
-
nodeId: Uint8Array.from([1, 2, 3]),
|
|
11
|
-
type: NodeType.NODEJS,
|
|
11
|
+
const epPeerDescriptor = createMockPeerDescriptor({
|
|
12
12
|
websocket: { host: '127.0.0.1', port: 11221, tls: false }
|
|
13
|
-
}
|
|
14
|
-
|
|
13
|
+
})
|
|
15
14
|
let epDhtNode: DhtNode
|
|
16
15
|
let node1: DhtNode
|
|
17
16
|
let node2: DhtNode
|
|
@@ -19,7 +18,6 @@ describe('Layer0MixedConnectionTypes', () => {
|
|
|
19
18
|
let node4: DhtNode
|
|
20
19
|
let node5: DhtNode
|
|
21
20
|
|
|
22
|
-
const websocketPortRange = { min: 11222, max: 11223 }
|
|
23
21
|
beforeEach(async () => {
|
|
24
22
|
|
|
25
23
|
epDhtNode = new DhtNode({
|
|
@@ -31,12 +29,12 @@ describe('Layer0MixedConnectionTypes', () => {
|
|
|
31
29
|
|
|
32
30
|
await epDhtNode.joinDht([epPeerDescriptor])
|
|
33
31
|
node1 = new DhtNode({
|
|
34
|
-
websocketPortRange,
|
|
32
|
+
websocketPortRange: WEBSOCKET_PORT_RANGE,
|
|
35
33
|
entryPoints: [epPeerDescriptor],
|
|
36
34
|
websocketServerEnableTls: false
|
|
37
35
|
})
|
|
38
36
|
node2 = new DhtNode({
|
|
39
|
-
websocketPortRange,
|
|
37
|
+
websocketPortRange: WEBSOCKET_PORT_RANGE,
|
|
40
38
|
entryPoints: [epPeerDescriptor],
|
|
41
39
|
websocketServerEnableTls: false
|
|
42
40
|
})
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import { binaryToHex } from '@streamr/utils'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import {
|
|
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
|
|
|
@@ -2,15 +2,14 @@ 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
7
|
|
|
8
8
|
describe('Layer0 with WebRTC connections', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type: NodeType.NODEJS,
|
|
9
|
+
|
|
10
|
+
const epPeerDescriptor = createMockPeerDescriptor({
|
|
12
11
|
websocket: { host: '127.0.0.1', port: 10029, tls: false }
|
|
13
|
-
}
|
|
12
|
+
})
|
|
14
13
|
let epDhtNode: DhtNode
|
|
15
14
|
let node1: DhtNode
|
|
16
15
|
let node2: DhtNode
|
|
@@ -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
|
-
nodeId: 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
|