@streamr/trackerless-network 100.2.5-beta.1 → 101.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +6 -6
- package/dist/src/NetworkNode.js +1 -1
- package/dist/src/NetworkNode.js.map +1 -1
- package/dist/src/NetworkStack.d.ts +5 -5
- package/dist/src/NetworkStack.js +21 -21
- package/dist/src/NetworkStack.js.map +1 -1
- package/dist/src/exports.d.ts +2 -2
- package/dist/src/exports.js +2 -2
- package/dist/src/exports.js.map +1 -1
- package/dist/src/logic/ContentDeliveryLayerNode.d.ts +5 -5
- package/dist/src/logic/ContentDeliveryLayerNode.js +85 -85
- package/dist/src/logic/ContentDeliveryLayerNode.js.map +1 -1
- package/dist/src/logic/ContentDeliveryManager.d.ts +11 -12
- package/dist/src/logic/ContentDeliveryManager.js +65 -61
- package/dist/src/logic/ContentDeliveryManager.js.map +1 -1
- package/dist/src/logic/ContentDeliveryRpcLocal.d.ts +5 -5
- package/dist/src/logic/ContentDeliveryRpcLocal.js +9 -9
- package/dist/src/logic/ContentDeliveryRpcLocal.js.map +1 -1
- package/dist/src/logic/{Layer0Node.d.ts → ControlLayerNode.d.ts} +1 -1
- package/dist/src/logic/{Layer0Node.js → ControlLayerNode.js} +1 -1
- package/dist/src/logic/ControlLayerNode.js.map +1 -0
- package/dist/src/logic/{Layer1Node.d.ts → DiscoveryLayerNode.d.ts} +8 -8
- package/dist/src/logic/{Layer1Node.js → DiscoveryLayerNode.js} +1 -1
- package/dist/src/logic/DiscoveryLayerNode.js.map +1 -0
- package/dist/src/logic/PeerDescriptorStoreManager.d.ts +28 -0
- package/dist/src/logic/PeerDescriptorStoreManager.js +79 -0
- package/dist/src/logic/PeerDescriptorStoreManager.js.map +1 -0
- package/dist/src/logic/StreamPartNetworkSplitAvoidance.d.ts +5 -5
- package/dist/src/logic/StreamPartNetworkSplitAvoidance.js +8 -8
- package/dist/src/logic/StreamPartNetworkSplitAvoidance.js.map +1 -1
- package/dist/src/logic/StreamPartReconnect.d.ts +5 -5
- package/dist/src/logic/StreamPartReconnect.js +10 -10
- package/dist/src/logic/StreamPartReconnect.js.map +1 -1
- package/dist/src/logic/createContentDeliveryLayerNode.d.ts +3 -3
- package/dist/src/logic/createContentDeliveryLayerNode.js +34 -34
- package/dist/src/logic/createContentDeliveryLayerNode.js.map +1 -1
- package/dist/src/logic/inspect/InspectSession.d.ts +3 -3
- package/dist/src/logic/inspect/InspectSession.js +5 -5
- package/dist/src/logic/inspect/InspectSession.js.map +1 -1
- package/dist/src/logic/inspect/Inspector.d.ts +2 -2
- package/dist/src/logic/inspect/Inspector.js +8 -8
- package/dist/src/logic/inspect/Inspector.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.d.ts +4 -4
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js +24 -24
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.d.ts +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js +4 -4
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/Handshaker.d.ts +3 -3
- package/dist/src/logic/neighbor-discovery/Handshaker.js +37 -37
- package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.d.ts +3 -3
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js +9 -9
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.d.ts +3 -3
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +12 -12
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.d.ts +3 -3
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js +14 -14
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +1 -1
- package/dist/src/logic/proxy/ProxyClient.d.ts +3 -3
- package/dist/src/logic/proxy/ProxyClient.js +25 -25
- package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.d.ts +3 -3
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js +10 -10
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.d.ts +3 -3
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +11 -11
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +4 -4
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +8 -8
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +11 -3
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +7 -5
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +2 -2
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js +1 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.d.ts +6 -23
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js +5 -23
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js.map +1 -1
- package/dist/test/benchmark/first-message.js +7 -7
- package/dist/test/benchmark/first-message.js.map +1 -1
- package/dist/test/utils/utils.d.ts +2 -2
- package/dist/test/utils/utils.js +3 -3
- package/dist/test/utils/utils.js.map +1 -1
- package/package.json +6 -6
- package/protos/NetworkRpc.proto +3 -9
- package/src/NetworkNode.ts +1 -1
- package/src/NetworkStack.ts +24 -24
- package/src/exports.ts +2 -2
- package/src/logic/ContentDeliveryLayerNode.ts +112 -112
- package/src/logic/ContentDeliveryManager.ts +71 -67
- package/src/logic/ContentDeliveryRpcLocal.ts +12 -12
- package/src/logic/{Layer0Node.ts → ControlLayerNode.ts} +1 -1
- package/src/logic/{Layer1Node.ts → DiscoveryLayerNode.ts} +8 -8
- package/src/logic/PeerDescriptorStoreManager.ts +97 -0
- package/src/logic/StreamPartNetworkSplitAvoidance.ts +11 -11
- package/src/logic/StreamPartReconnect.ts +12 -12
- package/src/logic/createContentDeliveryLayerNode.ts +38 -38
- package/src/logic/inspect/InspectSession.ts +6 -6
- package/src/logic/inspect/Inspector.ts +9 -9
- package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +26 -26
- package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +6 -6
- package/src/logic/neighbor-discovery/Handshaker.ts +45 -45
- package/src/logic/neighbor-discovery/NeighborFinder.ts +10 -10
- package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +14 -14
- package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +17 -17
- package/src/logic/proxy/ProxyClient.ts +26 -26
- package/src/logic/proxy/ProxyConnectionRpcLocal.ts +12 -12
- package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +13 -13
- package/src/proto/google/protobuf/any.ts +1 -1
- package/src/proto/google/protobuf/empty.ts +1 -1
- package/src/proto/google/protobuf/timestamp.ts +1 -1
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +9 -9
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +3 -3
- package/src/proto/packages/dht/protos/DhtRpc.ts +15 -5
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.client.ts +1 -1
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.server.ts +1 -1
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.ts +10 -27
- package/test/benchmark/StreamPartIdDataKeyDistribution.test.ts +1 -1
- package/test/benchmark/first-message.ts +9 -9
- package/test/end-to-end/content-delivery-layer-node-with-real-connections.test.ts +12 -12
- package/test/end-to-end/proxy-and-full-node.test.ts +4 -4
- package/test/integration/ContentDeliveryLayerNode-Layer1Node-Latencies.test.ts +19 -19
- package/test/integration/ContentDeliveryLayerNode-Layer1Node.test.ts +19 -19
- package/test/integration/ContentDeliveryManager.test.ts +11 -11
- package/test/integration/Inspect.test.ts +1 -1
- package/test/integration/Propagation.test.ts +6 -6
- package/test/integration/joining-streams-on-offline-peers.test.ts +3 -3
- package/test/integration/stream-without-default-entrypoints.test.ts +2 -2
- package/test/integration/streamEntryPointReplacing.test.ts +2 -2
- package/test/unit/ContentDeliveryLayerNode.test.ts +11 -11
- package/test/unit/ContentDeliveryManager.test.ts +2 -2
- package/test/unit/{EntrypointDiscovery.test.ts → PeerDescriptorStoreManager.test.ts} +28 -29
- package/test/unit/StreamPartIDDataKey.test.ts +1 -1
- package/test/unit/StreamPartNetworkSplitAvoidance.test.ts +8 -8
- package/test/unit/StreamPartReconnect.test.ts +9 -9
- package/test/utils/fake/FakePeerDescriptorStoreManager.ts +29 -0
- package/test/utils/mock/{MockLayer0Node.ts → MockControlLayerNode.ts} +2 -2
- package/test/utils/mock/{MockLayer1Node.ts → MockDiscoveryLayerNode.ts} +2 -2
- package/test/utils/utils.ts +5 -5
- package/dist/src/logic/EntryPointDiscovery.d.ts +0 -27
- package/dist/src/logic/EntryPointDiscovery.js +0 -80
- package/dist/src/logic/EntryPointDiscovery.js.map +0 -1
- package/dist/src/logic/Layer0Node.js.map +0 -1
- package/dist/src/logic/Layer1Node.js.map +0 -1
- package/src/logic/EntryPointDiscovery.ts +0 -100
- package/test/utils/fake/FakeEntryPointDiscovery.ts +0 -29
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.9.
|
|
1
|
+
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
|
|
2
2
|
// @generated from protobuf file "packages/trackerless-network/protos/NetworkRpc.proto" (syntax proto3)
|
|
3
3
|
// tslint:disable
|
|
4
4
|
import { Empty } from "../../../google/protobuf/empty";
|
|
@@ -183,17 +183,17 @@ export interface StreamPartHandshakeRequest {
|
|
|
183
183
|
*/
|
|
184
184
|
requestId: string;
|
|
185
185
|
/**
|
|
186
|
-
* @generated from protobuf field: optional bytes
|
|
186
|
+
* @generated from protobuf field: optional bytes concurrentHandshakeNodeId = 3;
|
|
187
187
|
*/
|
|
188
|
-
|
|
188
|
+
concurrentHandshakeNodeId?: Uint8Array;
|
|
189
189
|
/**
|
|
190
|
-
* @generated from protobuf field: repeated bytes
|
|
190
|
+
* @generated from protobuf field: repeated bytes neighborNodeIds = 4;
|
|
191
191
|
*/
|
|
192
|
-
|
|
192
|
+
neighborNodeIds: Uint8Array[];
|
|
193
193
|
/**
|
|
194
|
-
* @generated from protobuf field: optional bytes
|
|
194
|
+
* @generated from protobuf field: optional bytes interleaveNodeId = 5;
|
|
195
195
|
*/
|
|
196
|
-
|
|
196
|
+
interleaveNodeId?: Uint8Array;
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
199
|
* @generated from protobuf message StreamPartHandshakeResponse
|
|
@@ -359,23 +359,6 @@ export interface NodeInfoResponse {
|
|
|
359
359
|
*/
|
|
360
360
|
version: string;
|
|
361
361
|
}
|
|
362
|
-
/**
|
|
363
|
-
* @generated from protobuf enum StreamMessageType
|
|
364
|
-
*/
|
|
365
|
-
export enum StreamMessageType {
|
|
366
|
-
/**
|
|
367
|
-
* @generated from protobuf enum value: MESSAGE = 0;
|
|
368
|
-
*/
|
|
369
|
-
MESSAGE = 0,
|
|
370
|
-
/**
|
|
371
|
-
* @generated from protobuf enum value: GROUP_KEY_REQUEST = 1;
|
|
372
|
-
*/
|
|
373
|
-
GROUP_KEY_REQUEST = 1,
|
|
374
|
-
/**
|
|
375
|
-
* @generated from protobuf enum value: GROUP_KEY_RESPONSE = 2;
|
|
376
|
-
*/
|
|
377
|
-
GROUP_KEY_RESPONSE = 2
|
|
378
|
-
}
|
|
379
362
|
/**
|
|
380
363
|
* @generated from protobuf enum ContentType
|
|
381
364
|
*/
|
|
@@ -544,9 +527,9 @@ class StreamPartHandshakeRequest$Type extends MessageType<StreamPartHandshakeReq
|
|
|
544
527
|
super("StreamPartHandshakeRequest", [
|
|
545
528
|
{ no: 1, name: "streamPartId", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
546
529
|
{ no: 2, name: "requestId", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
547
|
-
{ no: 3, name: "
|
|
548
|
-
{ no: 4, name: "
|
|
549
|
-
{ no: 5, name: "
|
|
530
|
+
{ no: 3, name: "concurrentHandshakeNodeId", kind: "scalar", opt: true, T: 12 /*ScalarType.BYTES*/ },
|
|
531
|
+
{ no: 4, name: "neighborNodeIds", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 12 /*ScalarType.BYTES*/ },
|
|
532
|
+
{ no: 5, name: "interleaveNodeId", kind: "scalar", opt: true, T: 12 /*ScalarType.BYTES*/ }
|
|
550
533
|
]);
|
|
551
534
|
}
|
|
552
535
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
|
|
3
3
|
import { groupBy, range } from 'lodash'
|
|
4
|
-
import { streamPartIdToDataKey } from '../../src/logic/
|
|
4
|
+
import { streamPartIdToDataKey } from '../../src/logic/ContentDeliveryManager'
|
|
5
5
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
6
6
|
import { DhtAddress } from '@streamr/dht'
|
|
7
7
|
|
|
@@ -23,9 +23,9 @@ import {
|
|
|
23
23
|
import { hexToBinary, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
|
|
24
24
|
import fs from 'fs'
|
|
25
25
|
import { NetworkNode } from '../../src/NetworkNode'
|
|
26
|
-
import { streamPartIdToDataKey } from '../../src/logic/
|
|
26
|
+
import { streamPartIdToDataKey } from '../../src/logic/ContentDeliveryManager'
|
|
27
27
|
import { createMockPeerDescriptor, createNetworkNodeWithSimulator } from '../utils/utils'
|
|
28
|
-
import {
|
|
28
|
+
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
|
|
29
29
|
import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
|
|
30
30
|
|
|
31
31
|
const numNodes = 10000
|
|
@@ -112,7 +112,7 @@ const measureJoiningTime = async () => {
|
|
|
112
112
|
const streamSubscriber = await createNetworkNodeWithSimulator(
|
|
113
113
|
peerDescriptor,
|
|
114
114
|
simulator,
|
|
115
|
-
[randomNode.stack.
|
|
115
|
+
[randomNode.stack.getControlLayerNode().getLocalPeerDescriptor()]
|
|
116
116
|
)
|
|
117
117
|
currentNode = streamSubscriber
|
|
118
118
|
const start = performance.now()
|
|
@@ -155,14 +155,14 @@ run().then(() => {
|
|
|
155
155
|
console.error(err)
|
|
156
156
|
const contentDeliveryManager = currentNode.stack.getContentDeliveryManager()
|
|
157
157
|
const streamParts = contentDeliveryManager.getStreamParts()
|
|
158
|
-
const foundData = nodes[0].stack.
|
|
158
|
+
const foundData = nodes[0].stack.getControlLayerNode().fetchDataFromDht(streamPartIdToDataKey(streamParts[0]))
|
|
159
159
|
console.log(foundData)
|
|
160
|
-
const
|
|
161
|
-
console.log(
|
|
162
|
-
console.log(
|
|
160
|
+
const controlLayerNode = currentNode.stack.getControlLayerNode() as DhtNode
|
|
161
|
+
console.log(controlLayerNode.getNeighbors().length)
|
|
162
|
+
console.log(controlLayerNode.getConnectionsView().getConnectionCount())
|
|
163
163
|
const streamPartDelivery = contentDeliveryManager
|
|
164
|
-
.getStreamPartDelivery(streamParts[0])! as {
|
|
165
|
-
console.log(streamPartDelivery.
|
|
164
|
+
.getStreamPartDelivery(streamParts[0])! as { discoveryLayerNode: DiscoveryLayerNode, node: ContentDeliveryLayerNode }
|
|
165
|
+
console.log(streamPartDelivery.discoveryLayerNode.getNeighbors())
|
|
166
166
|
console.log(streamPartDelivery.node.getNeighbors())
|
|
167
167
|
console.log(nodes[nodes.length - 1])
|
|
168
168
|
if (publishInterval) {
|
|
@@ -5,8 +5,8 @@ import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
|
5
5
|
import { createContentDeliveryLayerNode } from '../../src/logic/createContentDeliveryLayerNode'
|
|
6
6
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
7
7
|
import { randomEthereumAddress } from '@streamr/test-utils'
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { ControlLayerNode } from '../../src/logic/ControlLayerNode'
|
|
9
|
+
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
|
|
10
10
|
|
|
11
11
|
describe('content delivery layer node with real connections', () => {
|
|
12
12
|
|
|
@@ -18,11 +18,11 @@ describe('content delivery layer node with real connections', () => {
|
|
|
18
18
|
// Currently the nodes here are practically layer0 nodes acting as layer1 nodes, for the purpose of this test
|
|
19
19
|
// they are layer1 nodes as the DHT is per stream
|
|
20
20
|
// TODO refactor the test to use normal layering style (i.e. have separate objects for layer0 and layer1 nodes)
|
|
21
|
-
let epDhtNode:
|
|
22
|
-
let dhtNode1:
|
|
23
|
-
let dhtNode2:
|
|
24
|
-
let dhtNode3:
|
|
25
|
-
let dhtNode4:
|
|
21
|
+
let epDhtNode: ControlLayerNode & DiscoveryLayerNode
|
|
22
|
+
let dhtNode1: ControlLayerNode & DiscoveryLayerNode
|
|
23
|
+
let dhtNode2: ControlLayerNode & DiscoveryLayerNode
|
|
24
|
+
let dhtNode3: ControlLayerNode & DiscoveryLayerNode
|
|
25
|
+
let dhtNode4: ControlLayerNode & DiscoveryLayerNode
|
|
26
26
|
let contentDeliveryLayerNode1: ContentDeliveryLayerNode
|
|
27
27
|
let contentDeliveryLayerNode2: ContentDeliveryLayerNode
|
|
28
28
|
let contentDeliveryLayerNode3: ContentDeliveryLayerNode
|
|
@@ -45,7 +45,7 @@ describe('content delivery layer node with real connections', () => {
|
|
|
45
45
|
contentDeliveryLayerNode1 = createContentDeliveryLayerNode(
|
|
46
46
|
{
|
|
47
47
|
streamPartId,
|
|
48
|
-
|
|
48
|
+
discoveryLayerNode: epDhtNode,
|
|
49
49
|
transport: epDhtNode.getTransport(),
|
|
50
50
|
connectionLocker: epDhtNode.getTransport() as ConnectionManager,
|
|
51
51
|
localPeerDescriptor: epPeerDescriptor,
|
|
@@ -54,7 +54,7 @@ describe('content delivery layer node with real connections', () => {
|
|
|
54
54
|
)
|
|
55
55
|
contentDeliveryLayerNode2 = createContentDeliveryLayerNode({
|
|
56
56
|
streamPartId,
|
|
57
|
-
|
|
57
|
+
discoveryLayerNode: dhtNode1,
|
|
58
58
|
transport: dhtNode1.getTransport(),
|
|
59
59
|
connectionLocker: dhtNode1.getTransport() as ConnectionManager,
|
|
60
60
|
localPeerDescriptor: dhtNode1.getLocalPeerDescriptor(),
|
|
@@ -62,7 +62,7 @@ describe('content delivery layer node with real connections', () => {
|
|
|
62
62
|
})
|
|
63
63
|
contentDeliveryLayerNode3 = createContentDeliveryLayerNode({
|
|
64
64
|
streamPartId,
|
|
65
|
-
|
|
65
|
+
discoveryLayerNode: dhtNode2,
|
|
66
66
|
transport: dhtNode2.getTransport(),
|
|
67
67
|
connectionLocker: dhtNode2.getTransport() as ConnectionManager,
|
|
68
68
|
localPeerDescriptor: dhtNode2.getLocalPeerDescriptor(),
|
|
@@ -70,7 +70,7 @@ describe('content delivery layer node with real connections', () => {
|
|
|
70
70
|
})
|
|
71
71
|
contentDeliveryLayerNode4 = createContentDeliveryLayerNode({
|
|
72
72
|
streamPartId,
|
|
73
|
-
|
|
73
|
+
discoveryLayerNode: dhtNode3,
|
|
74
74
|
transport: dhtNode3.getTransport(),
|
|
75
75
|
connectionLocker: dhtNode3.getTransport() as ConnectionManager,
|
|
76
76
|
localPeerDescriptor: dhtNode3.getLocalPeerDescriptor(),
|
|
@@ -78,7 +78,7 @@ describe('content delivery layer node with real connections', () => {
|
|
|
78
78
|
})
|
|
79
79
|
contentDeliveryLayerNode5 = createContentDeliveryLayerNode({
|
|
80
80
|
streamPartId,
|
|
81
|
-
|
|
81
|
+
discoveryLayerNode: dhtNode4,
|
|
82
82
|
transport: dhtNode4.getTransport(),
|
|
83
83
|
connectionLocker: dhtNode4.getTransport() as ConnectionManager,
|
|
84
84
|
localPeerDescriptor: dhtNode4.getLocalPeerDescriptor(),
|
|
@@ -87,14 +87,14 @@ describe('proxy and full node', () => {
|
|
|
87
87
|
|
|
88
88
|
it('proxied node can act as full node on another stream part', async () => {
|
|
89
89
|
await proxiedNode.setProxies(proxiedStreamPart, [proxyNodeDescriptor], ProxyDirection.PUBLISH, PROXIED_NODE_USER_ID, 1)
|
|
90
|
-
expect(proxiedNode.stack.
|
|
90
|
+
expect(proxiedNode.stack.getControlLayerNode().hasJoined()).toBe(false)
|
|
91
91
|
|
|
92
92
|
await Promise.all([
|
|
93
93
|
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage'),
|
|
94
94
|
proxiedNode.broadcast(createMessage(regularStreamPart1))
|
|
95
95
|
])
|
|
96
96
|
|
|
97
|
-
expect(proxiedNode.stack.
|
|
97
|
+
expect(proxiedNode.stack.getControlLayerNode().hasJoined()).toBe(true)
|
|
98
98
|
|
|
99
99
|
await Promise.all([
|
|
100
100
|
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage'),
|
|
@@ -107,7 +107,7 @@ describe('proxy and full node', () => {
|
|
|
107
107
|
|
|
108
108
|
it('proxied node can act as full node on multiple stream parts', async () => {
|
|
109
109
|
await proxiedNode.setProxies(proxiedStreamPart, [proxyNodeDescriptor], ProxyDirection.PUBLISH, PROXIED_NODE_USER_ID, 1)
|
|
110
|
-
expect(proxiedNode.stack.
|
|
110
|
+
expect(proxiedNode.stack.getControlLayerNode().hasJoined()).toBe(false)
|
|
111
111
|
|
|
112
112
|
await Promise.all([
|
|
113
113
|
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
|
|
@@ -124,7 +124,7 @@ describe('proxy and full node', () => {
|
|
|
124
124
|
proxiedNode.broadcast(createMessage(regularStreamPart4))
|
|
125
125
|
])
|
|
126
126
|
|
|
127
|
-
expect(proxiedNode.stack.
|
|
127
|
+
expect(proxiedNode.stack.getControlLayerNode().hasJoined()).toBe(true)
|
|
128
128
|
|
|
129
129
|
await Promise.all([
|
|
130
130
|
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage'),
|
|
@@ -5,12 +5,12 @@ import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNo
|
|
|
5
5
|
import { createContentDeliveryLayerNode } from '../../src/logic/createContentDeliveryLayerNode'
|
|
6
6
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
7
7
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
8
|
-
import {
|
|
8
|
+
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
|
|
9
9
|
|
|
10
10
|
describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
11
11
|
const otherNodeCount = 64
|
|
12
|
-
let
|
|
13
|
-
let
|
|
12
|
+
let otherDiscoveryLayerNodes: DiscoveryLayerNode[]
|
|
13
|
+
let entryPointDiscoveryLayerNode: DiscoveryLayerNode
|
|
14
14
|
let entryPointContentDeliveryLayerNode: ContentDeliveryLayerNode
|
|
15
15
|
let otherContentDeliveryLayerNodes: ContentDeliveryLayerNode[]
|
|
16
16
|
|
|
@@ -27,13 +27,13 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
27
27
|
await entrypointCm.start()
|
|
28
28
|
await Promise.all(cms.map((cm) => cm.start()))
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
entryPointDiscoveryLayerNode = new DhtNode({
|
|
31
31
|
transport: entrypointCm,
|
|
32
32
|
connectionsView: entrypointCm,
|
|
33
33
|
peerDescriptor: entrypointDescriptor,
|
|
34
34
|
serviceId: streamPartId
|
|
35
35
|
})
|
|
36
|
-
|
|
36
|
+
otherDiscoveryLayerNodes = range(otherNodeCount).map((i) => new DhtNode({
|
|
37
37
|
transport: cms[i],
|
|
38
38
|
connectionsView: cms[i],
|
|
39
39
|
peerDescriptor: peerDescriptors[i],
|
|
@@ -41,7 +41,7 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
41
41
|
}))
|
|
42
42
|
otherContentDeliveryLayerNodes = range(otherNodeCount).map((i) => createContentDeliveryLayerNode({
|
|
43
43
|
streamPartId,
|
|
44
|
-
|
|
44
|
+
discoveryLayerNode: otherDiscoveryLayerNodes[i],
|
|
45
45
|
transport: cms[i],
|
|
46
46
|
connectionLocker: cms[i],
|
|
47
47
|
localPeerDescriptor: peerDescriptors[i],
|
|
@@ -49,29 +49,29 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
49
49
|
}))
|
|
50
50
|
entryPointContentDeliveryLayerNode = createContentDeliveryLayerNode({
|
|
51
51
|
streamPartId,
|
|
52
|
-
|
|
52
|
+
discoveryLayerNode: entryPointDiscoveryLayerNode,
|
|
53
53
|
transport: entrypointCm,
|
|
54
54
|
connectionLocker: entrypointCm,
|
|
55
55
|
localPeerDescriptor: entrypointDescriptor,
|
|
56
56
|
isLocalNodeEntryPoint: () => false
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
-
await
|
|
59
|
+
await entryPointDiscoveryLayerNode.start()
|
|
60
60
|
entryPointContentDeliveryLayerNode.start()
|
|
61
|
-
await
|
|
62
|
-
await Promise.all(
|
|
61
|
+
await entryPointDiscoveryLayerNode.joinDht([entrypointDescriptor])
|
|
62
|
+
await Promise.all(otherDiscoveryLayerNodes.map((node) => node.start()))
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
afterEach(async () => {
|
|
66
|
-
|
|
66
|
+
entryPointDiscoveryLayerNode.stop()
|
|
67
67
|
entryPointContentDeliveryLayerNode.stop()
|
|
68
|
-
await Promise.all(
|
|
68
|
+
await Promise.all(otherDiscoveryLayerNodes.map((node) => node.stop()))
|
|
69
69
|
await Promise.all(otherContentDeliveryLayerNodes.map((node) => node.stop()))
|
|
70
70
|
})
|
|
71
71
|
|
|
72
72
|
it('happy path single node', async () => {
|
|
73
73
|
await otherContentDeliveryLayerNodes[0].start()
|
|
74
|
-
await
|
|
74
|
+
await otherDiscoveryLayerNodes[0].joinDht([entrypointDescriptor])
|
|
75
75
|
await Promise.all([
|
|
76
76
|
waitForCondition(() => otherContentDeliveryLayerNodes[0].getNearbyNodeView().getIds().length === 1),
|
|
77
77
|
waitForCondition(() => otherContentDeliveryLayerNodes[0].getNeighbors().length === 1)
|
|
@@ -83,7 +83,7 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
83
83
|
it('happy path 5 nodes', async () => {
|
|
84
84
|
range(4).forEach((i) => otherContentDeliveryLayerNodes[i].start())
|
|
85
85
|
await Promise.all(range(4).map(async (i) => {
|
|
86
|
-
await
|
|
86
|
+
await otherDiscoveryLayerNodes[i].joinDht([entrypointDescriptor])
|
|
87
87
|
}))
|
|
88
88
|
await waitForCondition(() => range(4).every((i) => otherContentDeliveryLayerNodes[i].getNeighbors().length >= 4), 15000, 1000)
|
|
89
89
|
range(4).forEach((i) => {
|
|
@@ -99,8 +99,8 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
99
99
|
const neighbor = allNodes.find((node) => {
|
|
100
100
|
return node.getOwnNodeId() === ownNodeId
|
|
101
101
|
})
|
|
102
|
-
const
|
|
103
|
-
expect(
|
|
102
|
+
const neighborNodeIds = neighbor!.getNeighbors().map((n) => getNodeIdFromPeerDescriptor(n))
|
|
103
|
+
expect(neighborNodeIds).toContain(nodeId)
|
|
104
104
|
})
|
|
105
105
|
})
|
|
106
106
|
}, 60000)
|
|
@@ -108,7 +108,7 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
108
108
|
it('happy path 64 nodes', async () => {
|
|
109
109
|
await Promise.all(range(otherNodeCount).map((i) => otherContentDeliveryLayerNodes[i].start()))
|
|
110
110
|
await Promise.all(range(otherNodeCount).map((i) => {
|
|
111
|
-
|
|
111
|
+
otherDiscoveryLayerNodes[i].joinDht([entrypointDescriptor])
|
|
112
112
|
}))
|
|
113
113
|
await Promise.all(otherContentDeliveryLayerNodes.map((node) =>
|
|
114
114
|
waitForCondition(() => node.getNeighbors().length >= 4, 10000)
|
|
@@ -126,8 +126,8 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
126
126
|
const neighborId = getNodeIdFromPeerDescriptor(neighbor)
|
|
127
127
|
if (neighborId !== entryPointContentDeliveryLayerNode.getOwnNodeId()) {
|
|
128
128
|
const neighbor = otherContentDeliveryLayerNodes.find((n) => n.getOwnNodeId() === neighborId)
|
|
129
|
-
const
|
|
130
|
-
if (!
|
|
129
|
+
const neighborNodeIds = neighbor!.getNeighbors().map((n) => getNodeIdFromPeerDescriptor(n))
|
|
130
|
+
if (!neighborNodeIds.includes(nodeId)) {
|
|
131
131
|
mismatchCounter += 1
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -5,14 +5,14 @@ import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNo
|
|
|
5
5
|
import { createContentDeliveryLayerNode } from '../../src/logic/createContentDeliveryLayerNode'
|
|
6
6
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
7
7
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
8
|
-
import {
|
|
8
|
+
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
|
|
9
9
|
|
|
10
10
|
const logger = new Logger(module)
|
|
11
11
|
|
|
12
12
|
describe('ContentDeliveryLayerNode-DhtNode', () => {
|
|
13
13
|
const otherNodeCount = 64
|
|
14
|
-
let
|
|
15
|
-
let
|
|
14
|
+
let entryPointDiscoveryLayerNode: DiscoveryLayerNode
|
|
15
|
+
let otherDiscoveryLayerNodes: DiscoveryLayerNode[]
|
|
16
16
|
let entryPointContentDeliveryLayerNode: ContentDeliveryLayerNode
|
|
17
17
|
let otherContentDeliveryLayerNodes: ContentDeliveryLayerNode[]
|
|
18
18
|
|
|
@@ -42,14 +42,14 @@ describe('ContentDeliveryLayerNode-DhtNode', () => {
|
|
|
42
42
|
)
|
|
43
43
|
await Promise.all(cms.map((cm) => cm.start()))
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
entryPointDiscoveryLayerNode = new DhtNode({
|
|
46
46
|
transport: entrypointCm,
|
|
47
47
|
connectionsView: entrypointCm,
|
|
48
48
|
peerDescriptor: entrypointDescriptor,
|
|
49
49
|
serviceId: streamPartId
|
|
50
50
|
})
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
otherDiscoveryLayerNodes = range(otherNodeCount).map((i) => new DhtNode({
|
|
53
53
|
transport: cms[i],
|
|
54
54
|
connectionsView: cms[i],
|
|
55
55
|
peerDescriptor: peerDescriptors[i],
|
|
@@ -58,7 +58,7 @@ describe('ContentDeliveryLayerNode-DhtNode', () => {
|
|
|
58
58
|
|
|
59
59
|
otherContentDeliveryLayerNodes = range(otherNodeCount).map((i) => createContentDeliveryLayerNode({
|
|
60
60
|
streamPartId,
|
|
61
|
-
|
|
61
|
+
discoveryLayerNode: otherDiscoveryLayerNodes[i],
|
|
62
62
|
transport: cms[i],
|
|
63
63
|
connectionLocker: cms[i],
|
|
64
64
|
localPeerDescriptor: peerDescriptors[i],
|
|
@@ -68,7 +68,7 @@ describe('ContentDeliveryLayerNode-DhtNode', () => {
|
|
|
68
68
|
|
|
69
69
|
entryPointContentDeliveryLayerNode = createContentDeliveryLayerNode({
|
|
70
70
|
streamPartId,
|
|
71
|
-
|
|
71
|
+
discoveryLayerNode: entryPointDiscoveryLayerNode,
|
|
72
72
|
transport: entrypointCm,
|
|
73
73
|
connectionLocker: entrypointCm,
|
|
74
74
|
localPeerDescriptor: entrypointDescriptor,
|
|
@@ -76,22 +76,22 @@ describe('ContentDeliveryLayerNode-DhtNode', () => {
|
|
|
76
76
|
isLocalNodeEntryPoint: () => false
|
|
77
77
|
})
|
|
78
78
|
|
|
79
|
-
await
|
|
79
|
+
await entryPointDiscoveryLayerNode.start()
|
|
80
80
|
await entryPointContentDeliveryLayerNode.start()
|
|
81
|
-
await
|
|
82
|
-
await Promise.all(
|
|
81
|
+
await entryPointDiscoveryLayerNode.joinDht([entrypointDescriptor])
|
|
82
|
+
await Promise.all(otherDiscoveryLayerNodes.map((node) => node.start()))
|
|
83
83
|
})
|
|
84
84
|
|
|
85
85
|
afterEach(async () => {
|
|
86
|
-
await
|
|
86
|
+
await entryPointDiscoveryLayerNode.stop()
|
|
87
87
|
entryPointContentDeliveryLayerNode.stop()
|
|
88
|
-
await Promise.all(
|
|
88
|
+
await Promise.all(otherDiscoveryLayerNodes.map((node) => node.stop()))
|
|
89
89
|
await Promise.all(otherContentDeliveryLayerNodes.map((node) => node.stop()))
|
|
90
90
|
})
|
|
91
91
|
|
|
92
92
|
it('happy path single node ', async () => {
|
|
93
93
|
await otherContentDeliveryLayerNodes[0].start()
|
|
94
|
-
await
|
|
94
|
+
await otherDiscoveryLayerNodes[0].joinDht([entrypointDescriptor])
|
|
95
95
|
|
|
96
96
|
await waitForCondition(() => otherContentDeliveryLayerNodes[0].getNeighbors().length === 1)
|
|
97
97
|
expect(otherContentDeliveryLayerNodes[0].getNearbyNodeView().getIds().length).toEqual(1)
|
|
@@ -101,7 +101,7 @@ describe('ContentDeliveryLayerNode-DhtNode', () => {
|
|
|
101
101
|
it('happy path 4 nodes', async () => {
|
|
102
102
|
range(4).forEach((i) => otherContentDeliveryLayerNodes[i].start())
|
|
103
103
|
await Promise.all(range(4).map(async (i) => {
|
|
104
|
-
await
|
|
104
|
+
await otherDiscoveryLayerNodes[i].joinDht([entrypointDescriptor])
|
|
105
105
|
}))
|
|
106
106
|
|
|
107
107
|
await waitForCondition(() => range(4).every((i) => otherContentDeliveryLayerNodes[i].getNeighbors().length === 4))
|
|
@@ -118,8 +118,8 @@ describe('ContentDeliveryLayerNode-DhtNode', () => {
|
|
|
118
118
|
const neighbor = allNodes.find((node) => {
|
|
119
119
|
return node.getOwnNodeId() === nodeId
|
|
120
120
|
})
|
|
121
|
-
const
|
|
122
|
-
expect(
|
|
121
|
+
const neighborNodeIds = neighbor!.getNeighbors().map((n) => getNodeIdFromPeerDescriptor(n))
|
|
122
|
+
expect(neighborNodeIds.includes(allNodes[i].getOwnNodeId())).toEqual(true)
|
|
123
123
|
})
|
|
124
124
|
})
|
|
125
125
|
}, 10000)
|
|
@@ -127,7 +127,7 @@ describe('ContentDeliveryLayerNode-DhtNode', () => {
|
|
|
127
127
|
it('happy path 64 nodes', async () => {
|
|
128
128
|
await Promise.all(range(otherNodeCount).map((i) => otherContentDeliveryLayerNodes[i].start()))
|
|
129
129
|
await Promise.all(range(otherNodeCount).map((i) => {
|
|
130
|
-
|
|
130
|
+
otherDiscoveryLayerNodes[i].joinDht([entrypointDescriptor])
|
|
131
131
|
}))
|
|
132
132
|
await Promise.all(otherContentDeliveryLayerNodes.map((node) =>
|
|
133
133
|
waitForCondition(() => node.getNeighbors().length >= 4, 10000)
|
|
@@ -149,8 +149,8 @@ describe('ContentDeliveryLayerNode-DhtNode', () => {
|
|
|
149
149
|
const neighborId = getNodeIdFromPeerDescriptor(neighbor)
|
|
150
150
|
if (neighborId !== entryPointContentDeliveryLayerNode.getOwnNodeId()) {
|
|
151
151
|
const neighbor = otherContentDeliveryLayerNodes.find((n) => n.getOwnNodeId() === neighborId)
|
|
152
|
-
const
|
|
153
|
-
if (!
|
|
152
|
+
const neighborNodeIds = neighbor!.getNeighbors().map((n) => getNodeIdFromPeerDescriptor(n))
|
|
153
|
+
if (!neighborNodeIds.includes(nodeId)) {
|
|
154
154
|
mismatchCounter += 1
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -8,12 +8,12 @@ import { waitForEvent3, waitForCondition } from '@streamr/utils'
|
|
|
8
8
|
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
9
9
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
10
10
|
import { randomEthereumAddress } from '@streamr/test-utils'
|
|
11
|
-
import {
|
|
11
|
+
import { ControlLayerNode } from '../../src/logic/ControlLayerNode'
|
|
12
12
|
|
|
13
13
|
describe('ContentDeliveryManager', () => {
|
|
14
14
|
|
|
15
|
-
let
|
|
16
|
-
let
|
|
15
|
+
let controlLayerNode1: ControlLayerNode
|
|
16
|
+
let controlLayerNode2: ControlLayerNode
|
|
17
17
|
let transport1: SimulatorTransport
|
|
18
18
|
let transport2: SimulatorTransport
|
|
19
19
|
let manager1: ContentDeliveryManager
|
|
@@ -42,32 +42,32 @@ describe('ContentDeliveryManager', () => {
|
|
|
42
42
|
await transport1.start()
|
|
43
43
|
transport2 = new SimulatorTransport(peerDescriptor2, simulator)
|
|
44
44
|
await transport2.start()
|
|
45
|
-
|
|
45
|
+
controlLayerNode1 = new DhtNode({
|
|
46
46
|
transport: transport1,
|
|
47
47
|
connectionsView: transport1,
|
|
48
48
|
peerDescriptor: peerDescriptor1,
|
|
49
49
|
entryPoints: [peerDescriptor1]
|
|
50
50
|
})
|
|
51
|
-
|
|
51
|
+
controlLayerNode2 = new DhtNode({
|
|
52
52
|
transport: transport2,
|
|
53
53
|
connectionsView: transport2,
|
|
54
54
|
peerDescriptor: peerDescriptor2,
|
|
55
55
|
entryPoints: [peerDescriptor1]
|
|
56
56
|
})
|
|
57
57
|
await Promise.all([
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
controlLayerNode1.start(),
|
|
59
|
+
controlLayerNode2.start()
|
|
60
60
|
])
|
|
61
61
|
await Promise.all([
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
controlLayerNode1.joinDht([peerDescriptor1]),
|
|
63
|
+
controlLayerNode2.joinDht([peerDescriptor1])
|
|
64
64
|
])
|
|
65
65
|
|
|
66
66
|
manager1 = new ContentDeliveryManager({})
|
|
67
67
|
manager2 = new ContentDeliveryManager({})
|
|
68
|
-
await manager1.start(
|
|
68
|
+
await manager1.start(controlLayerNode1, transport1, transport1)
|
|
69
69
|
manager1.setStreamPartEntryPoints(STREAM_PART_ID, [peerDescriptor1])
|
|
70
|
-
await manager2.start(
|
|
70
|
+
await manager2.start(controlLayerNode2, transport2, transport2)
|
|
71
71
|
manager2.setStreamPartEntryPoints(STREAM_PART_ID, [peerDescriptor1])
|
|
72
72
|
})
|
|
73
73
|
|
|
@@ -81,7 +81,7 @@ describe('inspect', () => {
|
|
|
81
81
|
}, 200)
|
|
82
82
|
|
|
83
83
|
for (const node of inspectedNodes) {
|
|
84
|
-
const result = await inspectorNode.getContentDeliveryManager().inspect(node.
|
|
84
|
+
const result = await inspectorNode.getContentDeliveryManager().inspect(node.getControlLayerNode().getLocalPeerDescriptor(), streamPartId)
|
|
85
85
|
expect(result).toEqual(true)
|
|
86
86
|
}
|
|
87
87
|
}, 25000)
|
|
@@ -5,11 +5,11 @@ import { waitForCondition } from '@streamr/utils'
|
|
|
5
5
|
import { range } from 'lodash'
|
|
6
6
|
import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
|
|
7
7
|
import { createMockPeerDescriptor, createMockContentDeliveryLayerNodeAndDhtNode, createStreamMessage } from '../utils/utils'
|
|
8
|
-
import {
|
|
8
|
+
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
|
|
9
9
|
|
|
10
10
|
describe('Propagation', () => {
|
|
11
11
|
const entryPointDescriptor = createMockPeerDescriptor()
|
|
12
|
-
let
|
|
12
|
+
let discoveryLayerNodes: DiscoveryLayerNode[]
|
|
13
13
|
let contentDeliveryLayerNodes: ContentDeliveryLayerNode[]
|
|
14
14
|
const STREAM_PART_ID = StreamPartIDUtils.parse('testingtesting#0')
|
|
15
15
|
let totalReceived: number
|
|
@@ -18,7 +18,7 @@ describe('Propagation', () => {
|
|
|
18
18
|
beforeEach(async () => {
|
|
19
19
|
const simulator = new Simulator()
|
|
20
20
|
totalReceived = 0
|
|
21
|
-
|
|
21
|
+
discoveryLayerNodes = []
|
|
22
22
|
contentDeliveryLayerNodes = []
|
|
23
23
|
const [entryPoint, node1] = await createMockContentDeliveryLayerNodeAndDhtNode(
|
|
24
24
|
entryPointDescriptor,
|
|
@@ -30,7 +30,7 @@ describe('Propagation', () => {
|
|
|
30
30
|
await entryPoint.joinDht([entryPointDescriptor])
|
|
31
31
|
await node1.start()
|
|
32
32
|
node1.on('message', () => {totalReceived += 1})
|
|
33
|
-
|
|
33
|
+
discoveryLayerNodes.push(entryPoint)
|
|
34
34
|
contentDeliveryLayerNodes.push(node1)
|
|
35
35
|
|
|
36
36
|
await Promise.all(range(NUM_OF_NODES).map(async (_i) => {
|
|
@@ -45,7 +45,7 @@ describe('Propagation', () => {
|
|
|
45
45
|
await contentDeliveryLayerNode.start()
|
|
46
46
|
await layer1.joinDht([entryPointDescriptor]).then(() => {
|
|
47
47
|
contentDeliveryLayerNode.on('message', () => { totalReceived += 1 })
|
|
48
|
-
|
|
48
|
+
discoveryLayerNodes.push(layer1)
|
|
49
49
|
contentDeliveryLayerNodes.push(contentDeliveryLayerNode)
|
|
50
50
|
})
|
|
51
51
|
}))
|
|
@@ -53,7 +53,7 @@ describe('Propagation', () => {
|
|
|
53
53
|
|
|
54
54
|
afterEach(async () => {
|
|
55
55
|
await Promise.all(contentDeliveryLayerNodes.map((node) => node.stop()))
|
|
56
|
-
await Promise.all(
|
|
56
|
+
await Promise.all(discoveryLayerNodes.map((node) => node.stop()))
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
it('All nodes receive messages', async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PeerDescriptor, Simulator, SimulatorTransport, LatencyType } from '@streamr/dht'
|
|
2
2
|
import { NetworkStack } from '../../src/NetworkStack'
|
|
3
|
-
import { streamPartIdToDataKey } from '../../src/logic/
|
|
3
|
+
import { streamPartIdToDataKey } from '../../src/logic/ContentDeliveryManager'
|
|
4
4
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
5
5
|
import { Any } from '../../src/proto/google/protobuf/any'
|
|
6
6
|
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
@@ -70,8 +70,8 @@ describe('Joining stream parts on offline nodes', () => {
|
|
|
70
70
|
let messageReceived = false
|
|
71
71
|
|
|
72
72
|
// store offline peer descriptors to DHT
|
|
73
|
-
await entryPoint.
|
|
74
|
-
await entryPoint.
|
|
73
|
+
await entryPoint.getControlLayerNode().storeDataToDht(streamPartIdToDataKey(STREAM_PART_ID), Any.pack(offlineDescriptor1, PeerDescriptor))
|
|
74
|
+
await entryPoint.getControlLayerNode().storeDataToDht(streamPartIdToDataKey(STREAM_PART_ID), Any.pack(offlineDescriptor2, PeerDescriptor))
|
|
75
75
|
|
|
76
76
|
node1.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
77
77
|
node1.getContentDeliveryManager().on('newMessage', () => { messageReceived = true })
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { EthereumAddress, hexToBinary, utf8ToBinary, waitForCondition } from '@streamr/utils'
|
|
13
13
|
import { range } from 'lodash'
|
|
14
14
|
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
15
|
-
import { streamPartIdToDataKey } from '../../src/logic/
|
|
15
|
+
import { streamPartIdToDataKey } from '../../src/logic/ContentDeliveryManager'
|
|
16
16
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
17
17
|
|
|
18
18
|
const STREAM_PART_ID = StreamPartIDUtils.parse('test#0')
|
|
@@ -121,7 +121,7 @@ describe('stream without default entrypoints', () => {
|
|
|
121
121
|
await nodes[i].join(STREAM_PART_ID, { minCount: (i > 0) ? 1 : 0, timeout: 15000 })
|
|
122
122
|
}
|
|
123
123
|
await waitForCondition(async () => {
|
|
124
|
-
const entryPointData = await nodes[15].stack.
|
|
124
|
+
const entryPointData = await nodes[15].stack.getControlLayerNode().fetchDataFromDht(streamPartIdToDataKey(STREAM_PART_ID))
|
|
125
125
|
return entryPointData.length >= 7
|
|
126
126
|
}, 15000)
|
|
127
127
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Simulator, SimulatorTransport, LatencyType } from '@streamr/dht'
|
|
2
2
|
import { NetworkStack } from '../../src/NetworkStack'
|
|
3
3
|
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
4
|
-
import {
|
|
4
|
+
import { MAX_NODE_COUNT } from '../../src/logic/PeerDescriptorStoreManager'
|
|
5
5
|
import { range } from 'lodash'
|
|
6
6
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
7
7
|
import { waitForCondition } from '@streamr/utils'
|
|
@@ -50,7 +50,7 @@ describe('Stream Entry Points are replaced when known entry points leave streams
|
|
|
50
50
|
await entryPointTransport.start()
|
|
51
51
|
await layer0EntryPoint.start()
|
|
52
52
|
|
|
53
|
-
initialNodesOnStream = await Promise.all(range(
|
|
53
|
+
initialNodesOnStream = await Promise.all(range(MAX_NODE_COUNT).map(async () => {
|
|
54
54
|
return await startNode()
|
|
55
55
|
}))
|
|
56
56
|
|