@streamr/dht 0.0.1-tatum.6 → 0.0.1-tatum.8
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 +1 -1
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +10 -0
- package/dist/src/connection/{RemoteConnectionLocker.js → ConnectionLockRpcRemote.js} +21 -35
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -0
- package/dist/src/connection/ConnectionManager.d.ts +17 -41
- package/dist/src/connection/ConnectionManager.js +148 -212
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.js +16 -13
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +49 -0
- package/dist/src/connection/ConnectorFacade.js +83 -0
- package/dist/src/connection/ConnectorFacade.js.map +1 -0
- package/dist/src/connection/Handshaker.d.ts +1 -2
- package/dist/src/connection/Handshaker.js +1 -4
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +2 -6
- package/dist/src/connection/ManagedConnection.js +27 -36
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebRtcConnection.d.ts +1 -1
- package/dist/src/connection/ManagedWebRtcConnection.js +2 -2
- package/dist/src/connection/ManagedWebRtcConnection.js.map +1 -1
- package/dist/src/connection/Simulator/Simulator.d.ts +0 -2
- package/dist/src/connection/Simulator/Simulator.js +0 -5
- package/dist/src/connection/Simulator/Simulator.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorConnection.js +16 -13
- package/dist/src/connection/Simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorConnector.d.ts +2 -3
- package/dist/src/connection/Simulator/SimulatorConnector.js +12 -14
- package/dist/src/connection/Simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js +6 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js.map +1 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.d.ts +3 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js +12 -12
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +1 -1
- package/dist/src/connection/WebRTC/{WebRtcConnector.d.ts → WebRtcConnectorRpcLocal.d.ts} +13 -13
- package/dist/src/connection/WebRTC/{WebRtcConnector.js → WebRtcConnectorRpcLocal.js} +46 -38
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.d.ts +11 -0
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js +55 -0
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/WebRTC/iceServerAsString.d.ts +1 -1
- package/dist/src/connection/WebSocket/{WebSocketConnector.d.ts → WebSocketConnectorRpcLocal.d.ts} +21 -11
- package/dist/src/connection/WebSocket/{WebSocketConnector.js → WebSocketConnectorRpcLocal.js} +80 -59
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcRemote.d.ts +8 -0
- package/dist/src/connection/WebSocket/{RemoteWebSocketConnector.js → WebSocketConnectorRpcRemote.js} +12 -16
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/WebSocket/WebSocketServer.d.ts +11 -1
- package/dist/src/connection/WebSocket/WebSocketServer.js +15 -10
- package/dist/src/connection/WebSocket/WebSocketServer.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +18 -55
- package/dist/src/dht/DhtNode.js +122 -145
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/{RemoteExternalApi.d.ts → ExternalApiRpcRemote.d.ts} +2 -2
- package/dist/src/dht/{RemoteExternalApi.js → ExternalApiRpcRemote.js} +5 -6
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -0
- package/dist/src/dht/{DhtPeer.d.ts → RemoteDhtNode.d.ts} +2 -3
- package/dist/src/dht/{DhtPeer.js → RemoteDhtNode.js} +21 -19
- package/dist/src/dht/RemoteDhtNode.js.map +1 -0
- package/dist/src/dht/contact/ContactList.d.ts +0 -1
- package/dist/src/dht/contact/ContactList.js +0 -3
- package/dist/src/dht/contact/ContactList.js.map +1 -1
- package/dist/src/dht/contact/RandomContactList.d.ts +0 -1
- package/dist/src/dht/contact/RandomContactList.js +0 -3
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +0 -3
- package/dist/src/dht/contact/SortedContactList.js +0 -9
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +5 -7
- package/dist/src/dht/discovery/DiscoverySession.js +9 -10
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +12 -11
- package/dist/src/dht/discovery/PeerDiscovery.js +33 -37
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/find/RecursiveFindSession.d.ts +9 -10
- package/dist/src/dht/find/RecursiveFindSession.js +13 -13
- package/dist/src/dht/find/RecursiveFindSession.js.map +1 -1
- package/dist/src/dht/find/RecursiveFinder.d.ts +9 -11
- package/dist/src/dht/find/RecursiveFinder.js +35 -36
- package/dist/src/dht/find/RecursiveFinder.js.map +1 -1
- package/dist/src/dht/find/RemoteRecursiveFindSession.d.ts +1 -1
- package/dist/src/dht/find/RemoteRecursiveFindSession.js +4 -4
- package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +1 -1
- package/dist/src/dht/registerExternalApiRpcMethods.d.ts +1 -1
- package/dist/src/dht/registerExternalApiRpcMethods.js +4 -3
- package/dist/src/dht/registerExternalApiRpcMethods.js.map +1 -1
- package/dist/src/dht/routing/DuplicateDetector.d.ts +1 -2
- package/dist/src/dht/routing/DuplicateDetector.js +2 -7
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +12 -15
- package/dist/src/dht/routing/Router.js +30 -33
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/{RemoteRouter.d.ts → RouterRpcRemote.d.ts} +2 -2
- package/dist/src/dht/routing/{RemoteRouter.js → RouterRpcRemote.js} +5 -5
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -0
- package/dist/src/dht/routing/RoutingSession.d.ts +3 -4
- package/dist/src/dht/routing/RoutingSession.js +6 -5
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/{DataStore.d.ts → StoreRpcLocal.d.ts} +6 -6
- package/dist/src/dht/store/{DataStore.js → StoreRpcLocal.js} +34 -34
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -0
- package/dist/src/dht/store/{RemoteStore.d.ts → StoreRpcRemote.d.ts} +2 -2
- package/dist/src/dht/store/{RemoteStore.js → StoreRpcRemote.js} +4 -4
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -0
- package/dist/src/exports.d.ts +2 -8
- package/dist/src/exports.js +2 -14
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/PeerID.d.ts +0 -1
- package/dist/src/helpers/PeerID.js +0 -6
- package/dist/src/helpers/PeerID.js.map +1 -1
- package/dist/src/helpers/browser/isBrowserEnvironment.d.ts +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment.js +6 -0
- package/dist/src/helpers/browser/isBrowserEnvironment.js.map +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.d.ts +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.js +7 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.js.map +1 -0
- package/dist/src/helpers/kademliaId.d.ts +1 -0
- package/dist/src/helpers/kademliaId.js +14 -0
- package/dist/src/helpers/kademliaId.js.map +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +1 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +3 -3
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +2 -2
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +29 -29
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +39 -39
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +49 -162
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +47 -88
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +15 -15
- package/dist/src/transport/RoutingRpcCommunicator.js +1 -0
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/package.json +10 -9
- package/protos/DhtRpc.proto +30 -60
- package/src/connection/ConnectionLockHandler.ts +1 -1
- package/src/connection/ConnectionLockRpcRemote.ts +62 -0
- package/src/connection/ConnectionManager.ts +178 -274
- package/src/connection/ConnectivityChecker.ts +15 -12
- package/src/connection/ConnectorFacade.ts +140 -0
- package/src/connection/Handshaker.ts +0 -5
- package/src/connection/ManagedConnection.ts +26 -40
- package/src/connection/ManagedWebRtcConnection.ts +0 -2
- package/src/connection/Simulator/Simulator.ts +0 -7
- package/src/connection/Simulator/SimulatorConnection.ts +16 -13
- package/src/connection/Simulator/SimulatorConnector.ts +13 -19
- package/src/connection/Simulator/SimulatorTransport.ts +6 -1
- package/src/connection/WebRTC/NodeWebRtcConnection.ts +15 -14
- package/src/connection/WebRTC/{WebRtcConnector.ts → WebRtcConnectorRpcLocal.ts} +68 -56
- package/src/connection/WebRTC/WebRtcConnectorRpcRemote.ts +71 -0
- package/src/connection/WebRTC/iceServerAsString.ts +1 -1
- package/src/connection/WebSocket/{WebSocketConnector.ts → WebSocketConnectorRpcLocal.ts} +102 -79
- package/src/connection/WebSocket/WebSocketConnectorRpcRemote.ts +45 -0
- package/src/connection/WebSocket/WebSocketServer.ts +26 -8
- package/src/dht/DhtNode.ts +176 -203
- package/src/dht/{RemoteExternalApi.ts → ExternalApiRpcRemote.ts} +3 -4
- package/src/dht/{DhtPeer.ts → RemoteDhtNode.ts} +11 -9
- package/src/dht/contact/ContactList.ts +0 -4
- package/src/dht/contact/RandomContactList.ts +0 -4
- package/src/dht/contact/SortedContactList.ts +0 -12
- package/src/dht/discovery/DiscoverySession.ts +20 -23
- package/src/dht/discovery/PeerDiscovery.ts +47 -45
- package/src/dht/find/RecursiveFindSession.ts +21 -22
- package/src/dht/find/RecursiveFinder.ts +45 -49
- package/src/dht/find/RemoteRecursiveFindSession.ts +6 -6
- package/src/dht/registerExternalApiRpcMethods.ts +8 -5
- package/src/dht/routing/DuplicateDetector.ts +3 -10
- package/src/dht/routing/Router.ts +39 -45
- package/src/dht/routing/{RemoteRouter.ts → RouterRpcRemote.ts} +4 -4
- package/src/dht/routing/RoutingSession.ts +15 -15
- package/src/dht/store/{DataStore.ts → StoreRpcLocal.ts} +42 -42
- package/src/dht/store/{RemoteStore.ts → StoreRpcRemote.ts} +2 -2
- package/src/exports.ts +2 -8
- package/src/helpers/PeerID.ts +0 -7
- package/src/helpers/browser/isBrowserEnvironment.ts +1 -0
- package/src/helpers/browser/isBrowserEnvironment_override.ts +3 -0
- package/src/helpers/kademliaId.ts +8 -0
- package/src/helpers/peerIdFromPeerDescriptor.ts +1 -1
- package/src/helpers/protoClasses.ts +4 -4
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +54 -54
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +15 -15
- package/src/proto/packages/dht/protos/DhtRpc.ts +77 -216
- package/src/transport/RoutingRpcCommunicator.ts +1 -0
- package/test/benchmark/KademliaCorrectness.test.ts +4 -2
- package/test/benchmark/RecursiveFind.test.ts +6 -6
- package/test/end-to-end/Layer0-Layer1.test.ts +9 -9
- package/test/end-to-end/Layer0WebRTC-Layer1.test.ts +5 -5
- package/test/end-to-end/Layer0WebRTC.test.ts +5 -6
- package/test/end-to-end/Layer1-Scale-WebRTC.test.ts +13 -8
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +15 -10
- package/test/end-to-end/WebSocketConnectionRequest.test.ts +5 -5
- package/test/integration/ConnectionLocking.test.ts +32 -26
- package/test/integration/ConnectionManager.test.ts +90 -93
- package/test/integration/DhtJoinPeerDiscovery.test.ts +53 -0
- package/test/integration/DhtRpc.test.ts +4 -6
- package/test/integration/Layer1-scale.test.ts +8 -8
- package/test/integration/MigrateData.test.ts +9 -9
- package/test/integration/Mock-Layer1-Layer0.test.ts +1 -2
- package/test/integration/RecursiveFind.test.ts +5 -5
- package/test/integration/{DhtPeer.test.ts → RemoteDhtNode.test.ts} +11 -12
- package/test/integration/RouteMessage.test.ts +7 -9
- package/test/integration/{RemoteRouter.test.ts → RouterRpcRemote.test.ts} +13 -14
- package/test/integration/RpcErrors.test.ts +25 -10
- package/test/integration/ScaleDownDht.test.ts +8 -8
- package/test/integration/SimultaneousConnections.test.ts +35 -36
- package/test/integration/Store.test.ts +8 -9
- package/test/integration/StoreAndDelete.test.ts +11 -11
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +7 -7
- package/test/integration/{RemoteStore.test.ts → StoreRpcRemote.test.ts} +17 -18
- package/test/integration/WebRtcConnectionManagement.test.ts +26 -19
- package/test/integration/WebRtcConnectorRpc.test.ts +17 -32
- package/test/integration/WebSocket.test.ts +4 -2
- package/test/integration/WebSocketConnectionManagement.test.ts +30 -17
- package/test/integration/WebSocketConnectorRpc.test.ts +10 -15
- package/test/unit/DuplicateDetector.test.ts +3 -4
- package/test/unit/LocalDataStore.test.ts +6 -8
- package/test/unit/RandomContactList.test.ts +1 -1
- package/test/unit/RecursiveFinder.test.ts +13 -18
- package/test/unit/Router.test.ts +18 -21
- package/test/unit/WebSocketConnectorRpcLocal.test.ts +64 -0
- package/test/unit/WebSocketServer.test.ts +24 -12
- package/test/unit/{webrtcReplaceInternalIpWithExternalIp.ts → webrtcReplaceInternalIpWithExternalIp.test.ts} +1 -1
- package/test/utils/mock/RecursiveFinder.ts +2 -2
- package/test/utils/mock/Router.ts +9 -11
- package/test/utils/mock/Transport.ts +2 -2
- package/test/utils/utils.ts +55 -74
- package/dist/src/connection/RemoteConnectionLocker.d.ts +0 -13
- package/dist/src/connection/RemoteConnectionLocker.js.map +0 -1
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.d.ts +0 -12
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js +0 -74
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnector.js.map +0 -1
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.d.ts +0 -9
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketConnector.js.map +0 -1
- package/dist/src/dht/DhtPeer.js.map +0 -1
- package/dist/src/dht/RemoteExternalApi.js.map +0 -1
- package/dist/src/dht/routing/RemoteRouter.js.map +0 -1
- package/dist/src/dht/store/DataStore.js.map +0 -1
- package/dist/src/dht/store/RemoteStore.js.map +0 -1
- package/dist/src/helpers/browser/isBrowser.d.ts +0 -1
- package/dist/src/helpers/browser/isBrowser.js +0 -6
- package/dist/src/helpers/browser/isBrowser.js.map +0 -1
- package/dist/src/helpers/browser/isNodeJS.d.ts +0 -1
- package/dist/src/helpers/browser/isNodeJS.js +0 -6
- package/dist/src/helpers/browser/isNodeJS.js.map +0 -1
- package/src/connection/RemoteConnectionLocker.ts +0 -84
- package/src/connection/WebRTC/RemoteWebrtcConnector.ts +0 -93
- package/src/connection/WebSocket/RemoteWebSocketConnector.ts +0 -49
- package/src/helpers/browser/isBrowser.ts +0 -1
- package/src/helpers/browser/isNodeJS.ts +0 -1
- package/test/integration/DhtWithMockConnectionLatencies.test.ts +0 -46
- package/test/integration/DhtWithMockConnections.test.ts +0 -46
- package/test/integration/DhtWithRealConnectionLatencies.test.ts +0 -47
|
@@ -5,7 +5,8 @@ import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/Dh
|
|
|
5
5
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
6
6
|
import { execSync } from 'child_process'
|
|
7
7
|
import fs from 'fs'
|
|
8
|
-
import { PeerID
|
|
8
|
+
import { PeerID } from '../../src/helpers/PeerID'
|
|
9
|
+
import { keyFromPeerDescriptor, peerIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
9
10
|
import { Logger, wait } from '@streamr/utils'
|
|
10
11
|
import { debugVars } from '../../src/helpers/debugHelpers'
|
|
11
12
|
|
|
@@ -31,19 +32,18 @@ describe('Recursive find correctness', () => {
|
|
|
31
32
|
|
|
32
33
|
nodes = []
|
|
33
34
|
const entryPointId = '0'
|
|
34
|
-
entryPoint = await createMockConnectionDhtNode(entryPointId, simulator, Uint8Array.from(dhtIds[0].data), undefined
|
|
35
|
+
entryPoint = await createMockConnectionDhtNode(entryPointId, simulator, Uint8Array.from(dhtIds[0].data), undefined)
|
|
35
36
|
nodes.push(entryPoint)
|
|
36
37
|
nodeIndicesById[entryPoint.getNodeId().toKey()] = 0
|
|
37
38
|
entrypointDescriptor = {
|
|
38
39
|
kademliaId: entryPoint.getNodeId().value,
|
|
39
|
-
type: NodeType.NODEJS
|
|
40
|
-
nodeName: entryPointId
|
|
40
|
+
type: NodeType.NODEJS
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
44
44
|
const nodeId = `${i}`
|
|
45
45
|
|
|
46
|
-
const node = await createMockConnectionDhtNode(nodeId, simulator, Uint8Array.from(dhtIds[i].data), undefined
|
|
46
|
+
const node = await createMockConnectionDhtNode(nodeId, simulator, Uint8Array.from(dhtIds[i].data), undefined)
|
|
47
47
|
nodeIndicesById[node.getNodeId().toKey()] = i
|
|
48
48
|
nodes.push(node)
|
|
49
49
|
}
|
|
@@ -70,7 +70,7 @@ describe('Recursive find correctness', () => {
|
|
|
70
70
|
debugVars['waiting'] = false
|
|
71
71
|
logger.info('waiting over')
|
|
72
72
|
|
|
73
|
-
nodes.forEach((node) => logger.info(node.getPeerDescriptor()
|
|
73
|
+
nodes.forEach((node) => logger.info(keyFromPeerDescriptor(node.getPeerDescriptor()) + ': connections:' +
|
|
74
74
|
node.getNumberOfConnections() + ', kbucket: ' + node.getBucketSize()
|
|
75
75
|
+ ', localLocked: ' + node.getNumberOfLocalLockedConnections()
|
|
76
76
|
+ ', remoteLocked: ' + node.getNumberOfRemoteLockedConnections()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import {
|
|
3
|
+
import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
4
4
|
|
|
5
5
|
describe('Layer0-Layer1', () => {
|
|
6
6
|
const epPeerDescriptor: PeerDescriptor = {
|
|
@@ -35,11 +35,11 @@ describe('Layer0-Layer1', () => {
|
|
|
35
35
|
await node1.start()
|
|
36
36
|
await node2.start()
|
|
37
37
|
|
|
38
|
-
stream1Node1 = new DhtNode({
|
|
39
|
-
stream1Node2 = new DhtNode({
|
|
38
|
+
stream1Node1 = new DhtNode({ transport: epDhtNode, serviceId: STREAM_ID1 })
|
|
39
|
+
stream1Node2 = new DhtNode({ transport: node1, serviceId: STREAM_ID1 })
|
|
40
40
|
|
|
41
|
-
stream2Node1 = new DhtNode({
|
|
42
|
-
stream2Node2 = new DhtNode({
|
|
41
|
+
stream2Node1 = new DhtNode({ transport: epDhtNode, serviceId: STREAM_ID2 })
|
|
42
|
+
stream2Node2 = new DhtNode({ transport: node2, serviceId: STREAM_ID2 })
|
|
43
43
|
|
|
44
44
|
await Promise.all([
|
|
45
45
|
stream1Node1.start(),
|
|
@@ -81,9 +81,9 @@ describe('Layer0-Layer1', () => {
|
|
|
81
81
|
expect(stream2Node1.getClosestContacts()).toHaveLength(1)
|
|
82
82
|
expect(stream2Node2.getClosestContacts()).toHaveLength(1)
|
|
83
83
|
|
|
84
|
-
expect(
|
|
85
|
-
expect(
|
|
86
|
-
expect(
|
|
87
|
-
expect(
|
|
84
|
+
expect(areEqualPeerDescriptors(stream1Node1.getClosestContacts()[0], node1.getPeerDescriptor())).toBe(true)
|
|
85
|
+
expect(areEqualPeerDescriptors(stream1Node2.getClosestContacts()[0], epPeerDescriptor)).toBe(true)
|
|
86
|
+
expect(areEqualPeerDescriptors(stream2Node1.getClosestContacts()[0], node2.getPeerDescriptor())).toBe(true)
|
|
87
|
+
expect(areEqualPeerDescriptors(stream2Node2.getClosestContacts()[0], epPeerDescriptor)).toBe(true)
|
|
88
88
|
})
|
|
89
89
|
})
|
|
@@ -54,31 +54,31 @@ describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
|
54
54
|
|
|
55
55
|
layer1EntryPoint = new DhtNode({
|
|
56
56
|
peerId: binaryToHex(entrypointDescriptor.kademliaId),
|
|
57
|
-
|
|
57
|
+
transport: layer0EntryPoint,
|
|
58
58
|
serviceId: 'layer1'
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
layer1Node1 = new DhtNode({
|
|
62
62
|
peerId: layer0Node1Id,
|
|
63
|
-
|
|
63
|
+
transport: layer0Node1,
|
|
64
64
|
serviceId: 'layer1'
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
layer1Node2 = new DhtNode({
|
|
68
68
|
peerId: layer0Node2Id,
|
|
69
|
-
|
|
69
|
+
transport: layer0Node2,
|
|
70
70
|
serviceId: 'layer1'
|
|
71
71
|
})
|
|
72
72
|
|
|
73
73
|
layer1Node3 = new DhtNode({
|
|
74
74
|
peerId: layer0Node3Id,
|
|
75
|
-
|
|
75
|
+
transport: layer0Node3,
|
|
76
76
|
serviceId: 'layer1'
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
layer1Node4 = new DhtNode({
|
|
80
80
|
peerId: layer0Node4Id,
|
|
81
|
-
|
|
81
|
+
transport: layer0Node4,
|
|
82
82
|
serviceId: 'layer1'
|
|
83
83
|
})
|
|
84
84
|
|
|
@@ -8,7 +8,6 @@ import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/Dh
|
|
|
8
8
|
describe('Layer0 with WebRTC connections', () => {
|
|
9
9
|
const epPeerDescriptor: PeerDescriptor = {
|
|
10
10
|
kademliaId: PeerID.fromString('entrypoint').value,
|
|
11
|
-
nodeName: 'entrypoint',
|
|
12
11
|
type: NodeType.NODEJS,
|
|
13
12
|
websocket: { host: '127.0.0.1', port: 10029, tls: false }
|
|
14
13
|
}
|
|
@@ -20,15 +19,15 @@ describe('Layer0 with WebRTC connections', () => {
|
|
|
20
19
|
|
|
21
20
|
beforeEach(async () => {
|
|
22
21
|
|
|
23
|
-
epDhtNode = new DhtNode({ peerDescriptor: epPeerDescriptor,
|
|
22
|
+
epDhtNode = new DhtNode({ peerDescriptor: epPeerDescriptor, numberOfNodesPerKBucket: 8 })
|
|
24
23
|
await epDhtNode.start()
|
|
25
24
|
|
|
26
25
|
await epDhtNode.joinDht([epPeerDescriptor])
|
|
27
26
|
|
|
28
|
-
node1 = new DhtNode({
|
|
29
|
-
node2 = new DhtNode({
|
|
30
|
-
node3 = new DhtNode({
|
|
31
|
-
node4 = new DhtNode({
|
|
27
|
+
node1 = new DhtNode({ entryPoints: [epPeerDescriptor] })
|
|
28
|
+
node2 = new DhtNode({ entryPoints: [epPeerDescriptor] })
|
|
29
|
+
node3 = new DhtNode({ entryPoints: [epPeerDescriptor] })
|
|
30
|
+
node4 = new DhtNode({ entryPoints: [epPeerDescriptor] })
|
|
32
31
|
|
|
33
32
|
await Promise.all([
|
|
34
33
|
node1.start(),
|
|
@@ -2,12 +2,13 @@ import { DhtNode } from '../../src/dht/DhtNode'
|
|
|
2
2
|
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
3
3
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
4
4
|
|
|
5
|
+
const NUM_OF_NODES_PER_KBUCKET = 8
|
|
6
|
+
|
|
5
7
|
describe('Layer1 Scale', () => {
|
|
6
8
|
const epPeerDescriptor: PeerDescriptor = {
|
|
7
9
|
kademliaId: PeerID.fromString('0').value,
|
|
8
10
|
type: NodeType.NODEJS,
|
|
9
|
-
websocket: { host: '127.0.0.1', port: 43228, tls: false }
|
|
10
|
-
nodeName: 'entrypoint'
|
|
11
|
+
websocket: { host: '127.0.0.1', port: 43228, tls: false }
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const STREAM_ID = 'stream'
|
|
@@ -26,7 +27,7 @@ describe('Layer1 Scale', () => {
|
|
|
26
27
|
await epLayer0Node.start()
|
|
27
28
|
await epLayer0Node.joinDht([epPeerDescriptor])
|
|
28
29
|
|
|
29
|
-
epLayer1Node = new DhtNode({
|
|
30
|
+
epLayer1Node = new DhtNode({ transport: epLayer0Node, peerDescriptor: epPeerDescriptor, serviceId: STREAM_ID })
|
|
30
31
|
await epLayer1Node.start()
|
|
31
32
|
await epLayer1Node.joinDht([epPeerDescriptor])
|
|
32
33
|
|
|
@@ -34,15 +35,19 @@ describe('Layer1 Scale', () => {
|
|
|
34
35
|
layer1Nodes = []
|
|
35
36
|
|
|
36
37
|
for (let i = 1; i < NUM_OF_NODES; i++) {
|
|
37
|
-
const node = new DhtNode({
|
|
38
|
+
const node = new DhtNode({
|
|
39
|
+
entryPoints: [epPeerDescriptor],
|
|
40
|
+
numberOfNodesPerKBucket: NUM_OF_NODES_PER_KBUCKET
|
|
41
|
+
})
|
|
38
42
|
await node.start()
|
|
39
43
|
layer0Nodes.push(node)
|
|
40
44
|
const layer1 = new DhtNode({
|
|
41
|
-
|
|
45
|
+
transport: node,
|
|
42
46
|
entryPoints: [epPeerDescriptor],
|
|
43
47
|
peerDescriptor: node.getPeerDescriptor(),
|
|
44
48
|
serviceId: STREAM_ID,
|
|
45
|
-
rpcRequestTimeout: 5000
|
|
49
|
+
rpcRequestTimeout: 5000,
|
|
50
|
+
numberOfNodesPerKBucket: NUM_OF_NODES_PER_KBUCKET
|
|
46
51
|
})
|
|
47
52
|
await layer1.start()
|
|
48
53
|
layer1Nodes.push(layer1)
|
|
@@ -60,10 +65,10 @@ describe('Layer1 Scale', () => {
|
|
|
60
65
|
|
|
61
66
|
it('bucket sizes', async () => {
|
|
62
67
|
layer0Nodes.forEach((node) => {
|
|
63
|
-
expect(node.getBucketSize()).toBeGreaterThanOrEqual(
|
|
68
|
+
expect(node.getBucketSize()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET - 1)
|
|
64
69
|
})
|
|
65
70
|
layer1Nodes.forEach((node) => {
|
|
66
|
-
expect(node.getBucketSize()).toBeGreaterThanOrEqual(
|
|
71
|
+
expect(node.getBucketSize()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET / 2)
|
|
67
72
|
})
|
|
68
73
|
})
|
|
69
74
|
})
|
|
@@ -2,12 +2,13 @@ import { DhtNode } from '../../src/dht/DhtNode'
|
|
|
2
2
|
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
3
3
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
4
4
|
|
|
5
|
+
const NUM_OF_NODES_PER_KBUCKET = 8
|
|
6
|
+
|
|
5
7
|
describe('Layer1 Scale', () => {
|
|
6
8
|
const epPeerDescriptor: PeerDescriptor = {
|
|
7
9
|
kademliaId: PeerID.fromString('entrypoint').value,
|
|
8
10
|
type: NodeType.NODEJS,
|
|
9
|
-
websocket: { host: '127.0.0.1', port: 43225, tls: false }
|
|
10
|
-
nodeName: 'entrypoint'
|
|
11
|
+
websocket: { host: '127.0.0.1', port: 43225, tls: false }
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const STREAM_ID = 'stream'
|
|
@@ -24,11 +25,11 @@ describe('Layer1 Scale', () => {
|
|
|
24
25
|
const websocketPortRange = { min: 62200, max: 62200 + NUM_OF_NODES }
|
|
25
26
|
|
|
26
27
|
beforeEach(async () => {
|
|
27
|
-
epLayer0Node = new DhtNode({ peerDescriptor: epPeerDescriptor
|
|
28
|
+
epLayer0Node = new DhtNode({ peerDescriptor: epPeerDescriptor })
|
|
28
29
|
await epLayer0Node.start()
|
|
29
30
|
await epLayer0Node.joinDht([epPeerDescriptor])
|
|
30
31
|
|
|
31
|
-
epLayer1Node = new DhtNode({
|
|
32
|
+
epLayer1Node = new DhtNode({ transport: epLayer0Node, peerDescriptor: epPeerDescriptor, serviceId: STREAM_ID })
|
|
32
33
|
await epLayer1Node.start()
|
|
33
34
|
await epLayer1Node.joinDht([epPeerDescriptor])
|
|
34
35
|
|
|
@@ -36,15 +37,19 @@ describe('Layer1 Scale', () => {
|
|
|
36
37
|
layer1Nodes = []
|
|
37
38
|
|
|
38
39
|
for (let i = 0; i < NUM_OF_NODES; i++) {
|
|
39
|
-
const node = new DhtNode({
|
|
40
|
+
const node = new DhtNode({
|
|
41
|
+
websocketPortRange,
|
|
42
|
+
entryPoints: [epPeerDescriptor],
|
|
43
|
+
numberOfNodesPerKBucket: NUM_OF_NODES_PER_KBUCKET
|
|
44
|
+
})
|
|
40
45
|
await node.start()
|
|
41
46
|
layer0Nodes.push(node)
|
|
42
47
|
const layer1 = new DhtNode({
|
|
43
|
-
|
|
44
|
-
transportLayer: node,
|
|
48
|
+
transport: node,
|
|
45
49
|
entryPoints: [epPeerDescriptor],
|
|
46
50
|
peerDescriptor: node.getPeerDescriptor(),
|
|
47
|
-
serviceId: STREAM_ID
|
|
51
|
+
serviceId: STREAM_ID,
|
|
52
|
+
numberOfNodesPerKBucket: NUM_OF_NODES_PER_KBUCKET
|
|
48
53
|
})
|
|
49
54
|
await layer1.start()
|
|
50
55
|
layer1Nodes.push(layer1)
|
|
@@ -66,10 +71,10 @@ describe('Layer1 Scale', () => {
|
|
|
66
71
|
// TODO: fix flaky test in NET-1021
|
|
67
72
|
it('bucket sizes', async () => {
|
|
68
73
|
layer0Nodes.forEach((node) => {
|
|
69
|
-
expect(node.getBucketSize()).toBeGreaterThanOrEqual(
|
|
74
|
+
expect(node.getBucketSize()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET - 1)
|
|
70
75
|
})
|
|
71
76
|
layer1Nodes.forEach((node ) => {
|
|
72
|
-
expect(node.getBucketSize()).toBeGreaterThanOrEqual(
|
|
77
|
+
expect(node.getBucketSize()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET / 2)
|
|
73
78
|
})
|
|
74
79
|
})
|
|
75
80
|
})
|
|
@@ -3,7 +3,7 @@ import { DhtNode } from '../../src/dht/DhtNode'
|
|
|
3
3
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
4
4
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
5
5
|
import { waitForCondition } from '@streamr/utils'
|
|
6
|
-
import {
|
|
6
|
+
import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
7
7
|
|
|
8
8
|
describe('WebSocket IConnection Requests', () => {
|
|
9
9
|
const epPeerDescriptor: PeerDescriptor = {
|
|
@@ -22,8 +22,8 @@ describe('WebSocket IConnection Requests', () => {
|
|
|
22
22
|
|
|
23
23
|
await epDhtNode.joinDht([epPeerDescriptor])
|
|
24
24
|
|
|
25
|
-
node1 = new DhtNode({
|
|
26
|
-
node2 = new DhtNode({
|
|
25
|
+
node1 = new DhtNode({ websocketPortRange: { min: 10022, max: 10022 }, entryPoints: [epPeerDescriptor] })
|
|
26
|
+
node2 = new DhtNode({ entryPoints: [epPeerDescriptor] })
|
|
27
27
|
await node1.start()
|
|
28
28
|
await node2.start()
|
|
29
29
|
})
|
|
@@ -40,12 +40,12 @@ describe('WebSocket IConnection Requests', () => {
|
|
|
40
40
|
let connected2 = false
|
|
41
41
|
|
|
42
42
|
node1.on('connected', (peerDescriptor: PeerDescriptor) => {
|
|
43
|
-
if (
|
|
43
|
+
if (areEqualPeerDescriptors(peerDescriptor, node2.getPeerDescriptor())) {
|
|
44
44
|
connected1 = true
|
|
45
45
|
}
|
|
46
46
|
})
|
|
47
47
|
node2.on('connected', (peerDescriptor: PeerDescriptor) => {
|
|
48
|
-
if (
|
|
48
|
+
if (areEqualPeerDescriptors(peerDescriptor, node1.getPeerDescriptor())) {
|
|
49
49
|
connected2 = true
|
|
50
50
|
}
|
|
51
51
|
})
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MetricsContext, waitForCondition } from '@streamr/utils'
|
|
2
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { DefaultConnectorFacade } from '../../src/connection/ConnectorFacade'
|
|
4
|
+
import { Simulator } from '../../src/connection/Simulator/Simulator'
|
|
5
|
+
import { SimulatorTransport } from '../../src/connection/Simulator/SimulatorTransport'
|
|
6
|
+
import { ITransport } from '../../src/exports'
|
|
5
7
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
6
|
-
import {
|
|
8
|
+
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
9
|
+
|
|
10
|
+
const createConnectionManager = (ownPeerDescriptor: PeerDescriptor, transport: ITransport) => {
|
|
11
|
+
return new ConnectionManager({
|
|
12
|
+
createConnectorFacade: () => new DefaultConnectorFacade({
|
|
13
|
+
transport,
|
|
14
|
+
createOwnPeerDescriptor: () => ownPeerDescriptor
|
|
15
|
+
}),
|
|
16
|
+
metricsContext: new MetricsContext()
|
|
17
|
+
})
|
|
18
|
+
}
|
|
7
19
|
|
|
8
20
|
describe('Connection Locking', () => {
|
|
9
21
|
|
|
10
22
|
const mockPeerDescriptor1: PeerDescriptor = {
|
|
11
23
|
kademliaId: PeerID.fromString('mock1').value,
|
|
12
|
-
nodeName: 'mock1',
|
|
13
24
|
type: NodeType.NODEJS
|
|
14
25
|
}
|
|
15
26
|
const mockPeerDescriptor2: PeerDescriptor = {
|
|
16
27
|
kademliaId: PeerID.fromString('mock2').value,
|
|
17
|
-
nodeName: 'mock2',
|
|
18
28
|
type: NodeType.NODEJS
|
|
19
29
|
}
|
|
20
30
|
|
|
@@ -29,17 +39,13 @@ describe('Connection Locking', () => {
|
|
|
29
39
|
beforeEach(async () => {
|
|
30
40
|
simulator = new Simulator()
|
|
31
41
|
mockConnectorTransport1 = new SimulatorTransport(mockPeerDescriptor1, simulator)
|
|
42
|
+
await mockConnectorTransport1.start()
|
|
32
43
|
mockConnectorTransport2 = new SimulatorTransport(mockPeerDescriptor2, simulator)
|
|
33
|
-
|
|
34
|
-
connectionManager1 =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
connectionManager2 = new ConnectionManager({
|
|
39
|
-
transportLayer: mockConnectorTransport2
|
|
40
|
-
})
|
|
41
|
-
await connectionManager1.start(() => mockPeerDescriptor1)
|
|
42
|
-
await connectionManager2.start(() => mockPeerDescriptor2)
|
|
44
|
+
await mockConnectorTransport2.start()
|
|
45
|
+
connectionManager1 = createConnectionManager(mockPeerDescriptor1, mockConnectorTransport1)
|
|
46
|
+
connectionManager2 = createConnectionManager(mockPeerDescriptor2, mockConnectorTransport2)
|
|
47
|
+
await connectionManager1.start()
|
|
48
|
+
await connectionManager2.start()
|
|
43
49
|
})
|
|
44
50
|
|
|
45
51
|
afterEach(async () => {
|
|
@@ -68,7 +74,7 @@ describe('Connection Locking', () => {
|
|
|
68
74
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock1')
|
|
69
75
|
])
|
|
70
76
|
await Promise.all([
|
|
71
|
-
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(mockPeerDescriptor1
|
|
77
|
+
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(mockPeerDescriptor1)),
|
|
72
78
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock2')
|
|
73
79
|
])
|
|
74
80
|
expect(connectionManager1.hasConnection(mockPeerDescriptor2)).toEqual(true)
|
|
@@ -97,7 +103,7 @@ describe('Connection Locking', () => {
|
|
|
97
103
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock1')
|
|
98
104
|
])
|
|
99
105
|
await Promise.all([
|
|
100
|
-
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(mockPeerDescriptor1
|
|
106
|
+
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(mockPeerDescriptor1)),
|
|
101
107
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock2')
|
|
102
108
|
])
|
|
103
109
|
|
|
@@ -125,10 +131,10 @@ describe('Connection Locking', () => {
|
|
|
125
131
|
|
|
126
132
|
connectionManager1.unlockConnection(mockPeerDescriptor2, 'testLock1')
|
|
127
133
|
await waitForCondition(() =>
|
|
128
|
-
connectionManager1.hasRemoteLockedConnection(mockPeerDescriptor2
|
|
129
|
-
&& !connectionManager1.hasLocalLockedConnection(mockPeerDescriptor2
|
|
130
|
-
&& !connectionManager2.hasRemoteLockedConnection(mockPeerDescriptor1
|
|
131
|
-
&& connectionManager2.hasLocalLockedConnection(mockPeerDescriptor1
|
|
134
|
+
connectionManager1.hasRemoteLockedConnection(mockPeerDescriptor2)
|
|
135
|
+
&& !connectionManager1.hasLocalLockedConnection(mockPeerDescriptor2)
|
|
136
|
+
&& !connectionManager2.hasRemoteLockedConnection(mockPeerDescriptor1)
|
|
137
|
+
&& connectionManager2.hasLocalLockedConnection(mockPeerDescriptor1)
|
|
132
138
|
)
|
|
133
139
|
|
|
134
140
|
expect(connectionManager2.hasConnection(mockPeerDescriptor1)).toEqual(true)
|
|
@@ -150,12 +156,12 @@ describe('Connection Locking', () => {
|
|
|
150
156
|
await connectionManager1.gracefullyDisconnectAsync(mockPeerDescriptor2)
|
|
151
157
|
|
|
152
158
|
await waitForCondition(() =>
|
|
153
|
-
!connectionManager1.hasRemoteLockedConnection(mockPeerDescriptor2
|
|
154
|
-
&& !connectionManager1.hasLocalLockedConnection(mockPeerDescriptor2
|
|
159
|
+
!connectionManager1.hasRemoteLockedConnection(mockPeerDescriptor2)
|
|
160
|
+
&& !connectionManager1.hasLocalLockedConnection(mockPeerDescriptor2)
|
|
155
161
|
)
|
|
156
162
|
await waitForCondition(() =>
|
|
157
|
-
!connectionManager2.hasRemoteLockedConnection(mockPeerDescriptor1
|
|
158
|
-
&& !connectionManager2.hasLocalLockedConnection(mockPeerDescriptor1
|
|
163
|
+
!connectionManager2.hasRemoteLockedConnection(mockPeerDescriptor1)
|
|
164
|
+
&& !connectionManager2.hasLocalLockedConnection(mockPeerDescriptor1)
|
|
159
165
|
)
|
|
160
166
|
await waitForCondition(() => !connectionManager2.hasConnection(mockPeerDescriptor1))
|
|
161
167
|
await waitForCondition(() => !connectionManager1.hasConnection(mockPeerDescriptor2))
|