@streamr/trackerless-network 101.1.2 → 102.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{src/proto → generated}/google/protobuf/any.d.ts +11 -4
- package/dist/generated/google/protobuf/any.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/empty.d.ts +0 -1
- package/dist/generated/google/protobuf/empty.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/timestamp.d.ts +9 -3
- package/dist/generated/google/protobuf/timestamp.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.d.ts +9 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.js +7 -0
- package/dist/generated/packages/dht/protos/DhtRpc.client.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.d.ts +32 -8
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.js +23 -7
- package/dist/generated/packages/dht/protos/DhtRpc.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.d.ts +5 -0
- package/dist/generated/packages/dht/protos/DhtRpc.server.js.map +1 -0
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js.map +1 -0
- package/dist/generated/packages/trackerless-network/protos/NetworkRpc.client.js.map +1 -0
- package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.d.ts +29 -5
- package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.js +17 -3
- package/dist/generated/packages/trackerless-network/protos/NetworkRpc.js.map +1 -0
- package/dist/generated/packages/trackerless-network/protos/NetworkRpc.server.js.map +1 -0
- package/dist/package.json +10 -11
- package/dist/src/NetworkNode.d.ts +8 -7
- package/dist/src/NetworkNode.js +5 -3
- package/dist/src/NetworkNode.js.map +1 -1
- package/dist/src/NetworkStack.d.ts +2 -2
- package/dist/src/NetworkStack.js +7 -6
- package/dist/src/NetworkStack.js.map +1 -1
- package/dist/src/exports.d.ts +3 -2
- package/dist/src/exports.js +3 -2
- package/dist/src/exports.js.map +1 -1
- package/dist/src/logic/ContentDeliveryLayerNode.d.ts +5 -1
- package/dist/src/logic/ContentDeliveryLayerNode.js +30 -10
- package/dist/src/logic/ContentDeliveryLayerNode.js.map +1 -1
- package/dist/src/logic/ContentDeliveryManager.d.ts +8 -3
- package/dist/src/logic/ContentDeliveryManager.js +28 -7
- package/dist/src/logic/ContentDeliveryManager.js.map +1 -1
- package/dist/src/logic/ContentDeliveryRpcLocal.d.ts +3 -3
- package/dist/src/logic/ContentDeliveryRpcLocal.js +3 -3
- package/dist/src/logic/ContentDeliveryRpcLocal.js.map +1 -1
- package/dist/src/logic/ContentDeliveryRpcRemote.d.ts +5 -2
- package/dist/src/logic/ContentDeliveryRpcRemote.js +7 -0
- package/dist/src/logic/ContentDeliveryRpcRemote.js.map +1 -1
- package/dist/src/logic/ControlLayerNode.d.ts +1 -1
- package/dist/src/logic/DiscoveryLayerNode.d.ts +3 -3
- package/dist/src/logic/DuplicateMessageDetector.js +3 -3
- package/dist/src/logic/DuplicateMessageDetector.js.map +1 -1
- package/dist/src/logic/ExternalNetworkRpc.js.map +1 -1
- package/dist/src/logic/NodeList.js +2 -2
- package/dist/src/logic/NodeList.js.map +1 -1
- package/dist/src/logic/PeerDescriptorStoreManager.d.ts +1 -1
- package/dist/src/logic/PeerDescriptorStoreManager.js +1 -2
- package/dist/src/logic/PeerDescriptorStoreManager.js.map +1 -1
- package/dist/src/logic/StreamPartNetworkSplitAvoidance.js +4 -3
- package/dist/src/logic/StreamPartNetworkSplitAvoidance.js.map +1 -1
- package/dist/src/logic/createContentDeliveryLayerNode.js +1 -1
- package/dist/src/logic/createContentDeliveryLayerNode.js.map +1 -1
- package/dist/src/logic/inspect/InspectSession.d.ts +2 -2
- package/dist/src/logic/inspect/InspectSession.js +2 -2
- package/dist/src/logic/inspect/InspectSession.js.map +1 -1
- package/dist/src/logic/inspect/Inspector.d.ts +1 -1
- package/dist/src/logic/inspect/Inspector.js +4 -4
- package/dist/src/logic/inspect/Inspector.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js +9 -9
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js +5 -5
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/Handshaker.js +14 -14
- package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js +5 -0
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +5 -3
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js +4 -4
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.d.ts +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js.map +1 -1
- package/dist/src/logic/node-info/NodeInfoClient.d.ts +1 -1
- package/dist/src/logic/node-info/NodeInfoClient.js +1 -1
- package/dist/src/logic/node-info/NodeInfoClient.js.map +1 -1
- package/dist/src/logic/node-info/NodeInfoRpcLocal.d.ts +2 -2
- package/dist/src/logic/node-info/NodeInfoRpcLocal.js +1 -1
- package/dist/src/logic/node-info/NodeInfoRpcLocal.js.map +1 -1
- package/dist/src/logic/node-info/NodeInfoRpcRemote.d.ts +2 -2
- package/dist/src/logic/propagation/Propagation.d.ts +1 -1
- package/dist/src/logic/propagation/Propagation.js +0 -1
- package/dist/src/logic/propagation/Propagation.js.map +1 -1
- package/dist/src/logic/propagation/PropagationTaskStore.d.ts +1 -1
- package/dist/src/logic/proxy/ProxyClient.d.ts +4 -4
- package/dist/src/logic/proxy/ProxyClient.js +11 -7
- package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.d.ts +4 -4
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js +5 -5
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.d.ts +4 -4
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.js +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.js.map +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.d.ts +4 -4
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +4 -4
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.d.ts +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js +2 -2
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js.map +1 -1
- package/dist/src/logic/utils.d.ts +1 -1
- package/dist/src/logic/utils.js +2 -2
- package/dist/src/logic/utils.js.map +1 -1
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/test/benchmark/first-message.js +3 -4
- package/dist/test/benchmark/first-message.js.map +1 -1
- package/dist/test/utils/utils.d.ts +4 -4
- package/dist/test/utils/utils.js +6 -5
- package/dist/test/utils/utils.js.map +1 -1
- package/jest.config.ts +13 -0
- package/karma-setup.js +7 -0
- package/karma.config.js +1 -1
- package/package.json +10 -11
- package/proto.sh +2 -2
- package/protos/NetworkRpc.proto +9 -4
- package/src/NetworkNode.ts +12 -9
- package/src/NetworkStack.ts +10 -10
- package/src/exports.ts +5 -3
- package/src/logic/ContentDeliveryLayerNode.ts +35 -11
- package/src/logic/ContentDeliveryManager.ts +41 -13
- package/src/logic/ContentDeliveryRpcLocal.ts +6 -6
- package/src/logic/ContentDeliveryRpcRemote.ts +12 -2
- package/src/logic/ControlLayerNode.ts +1 -1
- package/src/logic/DiscoveryLayerNode.ts +3 -3
- package/src/logic/DuplicateMessageDetector.ts +4 -4
- package/src/logic/ExternalNetworkRpc.ts +0 -1
- package/src/logic/NodeList.ts +4 -3
- package/src/logic/PeerDescriptorStoreManager.ts +1 -2
- package/src/logic/StreamPartNetworkSplitAvoidance.ts +5 -4
- package/src/logic/createContentDeliveryLayerNode.ts +3 -3
- package/src/logic/inspect/InspectSession.ts +5 -4
- package/src/logic/inspect/Inspector.ts +6 -6
- package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +13 -13
- package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +8 -8
- package/src/logic/neighbor-discovery/Handshaker.ts +15 -15
- package/src/logic/neighbor-discovery/NeighborFinder.ts +6 -1
- package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +6 -4
- package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +7 -7
- package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +4 -4
- package/src/logic/node-info/NodeInfoClient.ts +2 -2
- package/src/logic/node-info/NodeInfoRpcLocal.ts +2 -2
- package/src/logic/node-info/NodeInfoRpcRemote.ts +2 -2
- package/src/logic/propagation/Propagation.ts +1 -2
- package/src/logic/propagation/PropagationTaskStore.ts +1 -1
- package/src/logic/proxy/ProxyClient.ts +17 -12
- package/src/logic/proxy/ProxyConnectionRpcLocal.ts +10 -10
- package/src/logic/proxy/ProxyConnectionRpcRemote.ts +5 -5
- package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +9 -9
- package/src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts +4 -4
- package/src/logic/utils.ts +4 -4
- package/src/types.ts +13 -0
- package/test/benchmark/first-message.ts +6 -5
- package/test/end-to-end/content-delivery-layer-node-with-real-connections.test.ts +11 -6
- package/test/end-to-end/external-network-rpc.test.ts +2 -2
- package/test/end-to-end/inspect.test.ts +5 -5
- package/test/end-to-end/proxy-and-full-node.test.ts +6 -6
- package/test/end-to-end/proxy-connections.test.ts +12 -14
- package/test/end-to-end/proxy-key-exchange.test.ts +11 -9
- package/test/end-to-end/webrtc-full-node-network.test.ts +7 -9
- package/test/end-to-end/websocket-full-node-network.test.ts +8 -10
- package/test/integration/ContentDeliveryLayerNode-Layer1Node-Latencies.test.ts +11 -11
- package/test/integration/ContentDeliveryLayerNode-Layer1Node.test.ts +10 -10
- package/test/integration/ContentDeliveryManager.test.ts +49 -25
- package/test/integration/ContentDeliveryRpcRemote.test.ts +8 -8
- package/test/integration/HandshakeRpcRemote.test.ts +2 -2
- package/test/integration/Handshakes.test.ts +21 -56
- package/test/integration/Inspect.test.ts +2 -2
- package/test/integration/NeighborUpdateRpcRemote.test.ts +2 -2
- package/test/integration/NetworkNode.test.ts +5 -4
- package/test/integration/NetworkRpc.test.ts +10 -10
- package/test/integration/NetworkStack.test.ts +4 -4
- package/test/integration/NodeInfoRpc.test.ts +9 -5
- package/test/integration/Propagation.test.ts +6 -6
- package/test/integration/joining-streams-on-offline-peers.test.ts +5 -5
- package/test/integration/stream-without-default-entrypoints.test.ts +8 -7
- package/test/integration/streamEntryPointReplacing.test.ts +5 -5
- package/test/types/global.d.ts +1 -0
- package/test/unit/ContentDeliveryLayerNode.test.ts +26 -14
- package/test/unit/ContentDeliveryManager.test.ts +10 -9
- package/test/unit/ContentDeliveryRpcLocal.test.ts +3 -3
- package/test/unit/DuplicateMessageDetector.test.ts +10 -10
- package/test/unit/ExternalNetworkRpc.test.ts +3 -3
- package/test/unit/HandshakeRpcLocal.test.ts +8 -21
- package/test/unit/Handshaker.test.ts +2 -2
- package/test/unit/InspectSession.test.ts +7 -4
- package/test/unit/Inspector.test.ts +5 -5
- package/test/unit/NeighborFinder.test.ts +5 -5
- package/test/unit/NeighborUpdateRpcLocal.test.ts +6 -6
- package/test/unit/NetworkNode.test.ts +5 -5
- package/test/unit/NodeList.test.ts +23 -23
- package/test/unit/PeerDescriptorStoreManager.test.ts +4 -4
- package/test/unit/Propagation.test.ts +8 -7
- package/test/unit/ProxyConnectionRpcRemote.test.ts +5 -5
- package/test/unit/StreamPartReconnect.test.ts +2 -2
- package/test/unit/TemporaryConnectionRpcLocal.test.ts +3 -3
- package/test/utils/mock/MockControlLayerNode.ts +5 -0
- package/test/utils/mock/MockNeighborUpdateManager.ts +1 -1
- package/test/utils/mock/MockTransport.ts +11 -0
- package/test/utils/utils.ts +10 -9
- package/tsconfig.browser.json +1 -0
- package/tsconfig.jest.json +2 -1
- package/tsconfig.json +3 -0
- package/tsconfig.node.json +1 -0
- package/.eslintignore +0 -7
- package/.eslintrc +0 -3
- package/dist/src/proto/google/protobuf/any.js.map +0 -1
- package/dist/src/proto/google/protobuf/empty.js.map +0 -1
- package/dist/src/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +0 -1
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js.map +0 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js.map +0 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.server.js.map +0 -1
- package/jest.config.js +0 -5
- package/src/proto/google/protobuf/any.ts +0 -319
- package/src/proto/google/protobuf/empty.ts +0 -82
- package/src/proto/google/protobuf/timestamp.ts +0 -281
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +0 -407
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +0 -160
- package/src/proto/packages/dht/protos/DhtRpc.ts +0 -1244
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +0 -108
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.client.ts +0 -218
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.server.ts +0 -85
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.ts +0 -752
- /package/dist/{src/proto → generated}/google/protobuf/any.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/empty.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/timestamp.js +0 -0
- /package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.js +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.js +0 -0
- /package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.client.d.ts +0 -0
- /package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.client.js +0 -0
- /package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.server.d.ts +0 -0
- /package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.server.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RpcRemote,
|
|
1
|
+
import { RpcRemote, toNodeId } from '@streamr/dht'
|
|
2
2
|
import { Logger } from '@streamr/utils'
|
|
3
|
-
import { TemporaryConnectionRpcClient } from '
|
|
3
|
+
import { TemporaryConnectionRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
4
4
|
|
|
5
5
|
const logger = new Logger(module)
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ export class TemporaryConnectionRpcRemote extends RpcRemote<TemporaryConnectionR
|
|
|
11
11
|
const response = await this.getClient().openConnection({}, this.formDhtRpcOptions())
|
|
12
12
|
return response.accepted
|
|
13
13
|
} catch (err: any) {
|
|
14
|
-
logger.debug(`temporaryConnection to ${
|
|
14
|
+
logger.debug(`temporaryConnection to ${toNodeId(this.getPeerDescriptor())} failed`, { err })
|
|
15
15
|
return false
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -23,7 +23,7 @@ export class TemporaryConnectionRpcRemote extends RpcRemote<TemporaryConnectionR
|
|
|
23
23
|
notification: true
|
|
24
24
|
}))
|
|
25
25
|
} catch (err) {
|
|
26
|
-
logger.trace(`closeConnection to ${
|
|
26
|
+
logger.trace(`closeConnection to ${toNodeId(this.getPeerDescriptor())} failed`, { err })
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/logic/utils.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MessageID, MessageRef } from '
|
|
3
|
-
import {
|
|
1
|
+
import { toUserId } from '@streamr/utils'
|
|
2
|
+
import { MessageID, MessageRef } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
3
|
+
import { DuplicateMessageDetector, NumberPair } from './DuplicateMessageDetector'
|
|
4
4
|
|
|
5
5
|
export const markAndCheckDuplicate = (
|
|
6
6
|
duplicateDetectors: Map<string, DuplicateMessageDetector>,
|
|
7
7
|
currentMessage: MessageID,
|
|
8
8
|
previousMessageRef?: MessageRef
|
|
9
9
|
): boolean => {
|
|
10
|
-
const detectorKey = `${
|
|
10
|
+
const detectorKey = `${toUserId(currentMessage.publisherId)}-${currentMessage.messageChainId}`
|
|
11
11
|
const previousNumberPair = previousMessageRef ?
|
|
12
12
|
new NumberPair(Number(previousMessageRef.timestamp), previousMessageRef.sequenceNumber) : null
|
|
13
13
|
const currentNumberPair = new NumberPair(Number(currentMessage.timestamp), currentMessage.sequenceNumber)
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChangeFieldType } from '@streamr/utils'
|
|
2
|
+
import { MarkRequired } from 'ts-essentials'
|
|
3
|
+
import {
|
|
4
|
+
ContentDeliveryLayerNeighborInfo as ContentDeliveryLayerNeighborInfo_,
|
|
5
|
+
NodeInfoResponse,
|
|
6
|
+
StreamPartitionInfo as StreamPartitionInfo_
|
|
7
|
+
} from '../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
8
|
+
|
|
9
|
+
// These types are part of trackerless-network's public API. Therefore removing optionality from fields which are
|
|
10
|
+
// actually required. TODO: could do the same thing for other generated interfaces which are part of the public API.
|
|
11
|
+
export type ContentDeliveryLayerNeighborInfo = MarkRequired<ContentDeliveryLayerNeighborInfo_, 'peerDescriptor'>
|
|
12
|
+
export type StreamPartitionInfo = ChangeFieldType<Required<StreamPartitionInfo_>, 'contentDeliveryLayerNeighbors', ContentDeliveryLayerNeighborInfo[]>
|
|
13
|
+
export type NodeInfo = ChangeFieldType<Required<NodeInfoResponse>, 'streamPartitions', StreamPartitionInfo[]>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
DhtNode,
|
|
5
|
-
|
|
5
|
+
toNodeId,
|
|
6
6
|
getRandomRegion,
|
|
7
7
|
LatencyType,
|
|
8
8
|
PeerDescriptor,
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
StreamPartIDUtils,
|
|
15
15
|
toStreamID,
|
|
16
16
|
toStreamPartID,
|
|
17
|
+
toUserId,
|
|
18
|
+
toUserIdRaw,
|
|
17
19
|
utf8ToBinary, waitForEvent3
|
|
18
20
|
} from '@streamr/utils'
|
|
19
21
|
import fs from 'fs'
|
|
@@ -21,7 +23,7 @@ import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNo
|
|
|
21
23
|
import { streamPartIdToDataKey } from '../../src/logic/ContentDeliveryManager'
|
|
22
24
|
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
|
|
23
25
|
import { NetworkNode } from '../../src/NetworkNode'
|
|
24
|
-
import { ContentType, EncryptionType, SignatureType } from '../../
|
|
26
|
+
import { ContentType, EncryptionType, SignatureType } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
25
27
|
import { createMockPeerDescriptor, createNetworkNodeWithSimulator } from '../utils/utils'
|
|
26
28
|
|
|
27
29
|
const numNodes = 10000
|
|
@@ -75,7 +77,7 @@ const measureJoiningTime = async () => {
|
|
|
75
77
|
const peerDescriptor = createMockPeerDescriptor({
|
|
76
78
|
region: getRandomRegion()
|
|
77
79
|
})
|
|
78
|
-
console.log('starting node with id ',
|
|
80
|
+
console.log('starting node with id ', toNodeId(peerDescriptor))
|
|
79
81
|
|
|
80
82
|
// start publishing ons stream
|
|
81
83
|
const stream = Array.from(streamParts.keys())[Math.floor(Math.random() * streamParts.size)]
|
|
@@ -88,7 +90,7 @@ const measureJoiningTime = async () => {
|
|
|
88
90
|
streamPartition: 0,
|
|
89
91
|
timestamp: i,
|
|
90
92
|
sequenceNumber: Math.floor(Math.random() * 20000),
|
|
91
|
-
publisherId:
|
|
93
|
+
publisherId: toUserIdRaw(toUserId('0x2222')),
|
|
92
94
|
messageChainId: 'msgChainId'
|
|
93
95
|
},
|
|
94
96
|
body: {
|
|
@@ -147,7 +149,6 @@ const run = async () => {
|
|
|
147
149
|
await shutdownNetwork()
|
|
148
150
|
}
|
|
149
151
|
|
|
150
|
-
// eslint-disable-next-line promise/catch-or-return
|
|
151
152
|
run().then(() => {
|
|
152
153
|
console.log('done')
|
|
153
154
|
}).catch((err) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ConnectionManager, DhtNode, PeerDescriptor } from '@streamr/dht'
|
|
2
|
-
import {
|
|
3
|
-
import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
|
|
2
|
+
import { StreamPartIDUtils, until } from '@streamr/utils'
|
|
4
3
|
import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
|
|
5
4
|
import { ControlLayerNode } from '../../src/logic/ControlLayerNode'
|
|
6
5
|
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
|
|
7
6
|
import { createContentDeliveryLayerNode } from '../../src/logic/createContentDeliveryLayerNode'
|
|
8
7
|
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
8
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
9
9
|
|
|
10
10
|
describe('content delivery layer node with real connections', () => {
|
|
11
11
|
|
|
@@ -106,10 +106,15 @@ describe('content delivery layer node with real connections', () => {
|
|
|
106
106
|
dhtNode2.stop(),
|
|
107
107
|
dhtNode3.stop(),
|
|
108
108
|
dhtNode4.stop(),
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
109
110
|
contentDeliveryLayerNode1.stop(),
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
110
112
|
contentDeliveryLayerNode2.stop(),
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
111
114
|
contentDeliveryLayerNode3.stop(),
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
112
116
|
contentDeliveryLayerNode4.stop(),
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
113
118
|
contentDeliveryLayerNode5.stop(),
|
|
114
119
|
(epDhtNode.getTransport() as ConnectionManager).stop(),
|
|
115
120
|
(dhtNode1.getTransport() as ConnectionManager).stop(),
|
|
@@ -120,7 +125,7 @@ describe('content delivery layer node with real connections', () => {
|
|
|
120
125
|
})
|
|
121
126
|
|
|
122
127
|
it('can fully connected topologies ', async () => {
|
|
123
|
-
await
|
|
128
|
+
await until(() => {
|
|
124
129
|
return contentDeliveryLayerNode1.getNeighbors().length >= 3
|
|
125
130
|
&& contentDeliveryLayerNode2.getNeighbors().length >= 3
|
|
126
131
|
&& contentDeliveryLayerNode3.getNeighbors().length >= 3
|
|
@@ -141,7 +146,7 @@ describe('content delivery layer node with real connections', () => {
|
|
|
141
146
|
contentDeliveryLayerNode4.on('message', () => receivedMessageCount += 1)
|
|
142
147
|
contentDeliveryLayerNode5.on('message', () => receivedMessageCount += 1)
|
|
143
148
|
|
|
144
|
-
await
|
|
149
|
+
await until(() => {
|
|
145
150
|
return contentDeliveryLayerNode1.getNeighbors().length >= 3
|
|
146
151
|
&& contentDeliveryLayerNode2.getNeighbors().length >= 3
|
|
147
152
|
&& contentDeliveryLayerNode3.getNeighbors().length >= 3
|
|
@@ -152,9 +157,9 @@ describe('content delivery layer node with real connections', () => {
|
|
|
152
157
|
const msg = createStreamMessage(
|
|
153
158
|
JSON.stringify({ hello: 'WORLD' }),
|
|
154
159
|
streamPartId,
|
|
155
|
-
|
|
160
|
+
randomUserId()
|
|
156
161
|
)
|
|
157
162
|
contentDeliveryLayerNode1.broadcast(msg)
|
|
158
|
-
await
|
|
163
|
+
await until(() => receivedMessageCount >= 4)
|
|
159
164
|
})
|
|
160
165
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NetworkNode } from '../../src/NetworkNode'
|
|
2
2
|
import { NetworkStack } from '../../src/NetworkStack'
|
|
3
|
-
import { StreamPartHandshakeRequest, StreamPartHandshakeResponse } from '../../
|
|
4
|
-
import { HandshakeRpcClient } from '../../
|
|
3
|
+
import { StreamPartHandshakeRequest, StreamPartHandshakeResponse } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
4
|
+
import { HandshakeRpcClient } from '../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
5
5
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
6
|
|
|
7
7
|
describe('ExternalNetworkRpc', () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StreamPartIDUtils, hexToBinary, utf8ToBinary,
|
|
1
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
2
|
+
import { StreamPartIDUtils, hexToBinary, toUserIdRaw, utf8ToBinary, until } from '@streamr/utils'
|
|
3
3
|
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
4
|
-
import { ContentType, EncryptionType, SignatureType, StreamMessage } from '../../
|
|
4
|
+
import { ContentType, EncryptionType, SignatureType, StreamMessage } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
5
5
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
6
|
|
|
7
7
|
const STREAM_PART_ID = StreamPartIDUtils.parse('stream#0')
|
|
@@ -44,7 +44,7 @@ describe('inspect', () => {
|
|
|
44
44
|
streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
45
45
|
timestamp: 666,
|
|
46
46
|
sequenceNumber: 0,
|
|
47
|
-
publisherId:
|
|
47
|
+
publisherId: toUserIdRaw(randomUserId()),
|
|
48
48
|
messageChainId: 'msgChainId'
|
|
49
49
|
},
|
|
50
50
|
previousMessageRef: {
|
|
@@ -98,7 +98,7 @@ describe('inspect', () => {
|
|
|
98
98
|
inspectedNode.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
99
99
|
inspectorNode.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
100
100
|
|
|
101
|
-
await
|
|
101
|
+
await until(() =>
|
|
102
102
|
publisherNode.stack.getContentDeliveryManager().getNeighbors(STREAM_PART_ID).length === 2
|
|
103
103
|
&& inspectedNode.stack.getContentDeliveryManager().getNeighbors(STREAM_PART_ID).length === 2
|
|
104
104
|
&& inspectorNode.stack.getContentDeliveryManager().getNeighbors(STREAM_PART_ID).length === 2
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StreamPartID, StreamPartIDUtils, hexToBinary, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
|
|
1
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
2
|
+
import { StreamPartID, StreamPartIDUtils, hexToBinary, toUserIdRaw, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
|
|
3
3
|
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
4
4
|
import {
|
|
5
5
|
ContentType,
|
|
@@ -7,19 +7,19 @@ import {
|
|
|
7
7
|
ProxyDirection,
|
|
8
8
|
SignatureType,
|
|
9
9
|
StreamMessage
|
|
10
|
-
} from '../../
|
|
10
|
+
} from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
11
11
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
12
12
|
|
|
13
|
-
const PROXIED_NODE_USER_ID =
|
|
13
|
+
const PROXIED_NODE_USER_ID = randomUserId()
|
|
14
14
|
|
|
15
15
|
const createMessage = (streamPartId: StreamPartID): StreamMessage => {
|
|
16
|
-
return {
|
|
16
|
+
return {
|
|
17
17
|
messageId: {
|
|
18
18
|
streamId: StreamPartIDUtils.getStreamID(streamPartId),
|
|
19
19
|
streamPartition: StreamPartIDUtils.getStreamPartition(streamPartId),
|
|
20
20
|
timestamp: 666,
|
|
21
21
|
sequenceNumber: 0,
|
|
22
|
-
publisherId:
|
|
22
|
+
publisherId: toUserIdRaw(randomUserId()),
|
|
23
23
|
messageChainId: 'msgChainId'
|
|
24
24
|
},
|
|
25
25
|
previousMessageRef: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DhtAddress } from '@streamr/dht'
|
|
2
|
-
import {
|
|
3
|
-
import { StreamPartIDUtils, hexToBinary, utf8ToBinary, wait,
|
|
2
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
3
|
+
import { StreamPartIDUtils, hexToBinary, toUserIdRaw, utf8ToBinary, wait, until, waitForEvent3 } from '@streamr/utils'
|
|
4
4
|
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
5
5
|
import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
|
|
6
6
|
import { ProxyClient } from '../../src/logic/proxy/ProxyClient'
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
ProxyDirection,
|
|
11
11
|
SignatureType,
|
|
12
12
|
StreamMessage
|
|
13
|
-
} from '../../
|
|
13
|
+
} from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
14
14
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
15
15
|
|
|
16
|
-
const PROXIED_NODE_USER_ID =
|
|
16
|
+
const PROXIED_NODE_USER_ID = randomUserId()
|
|
17
17
|
const STREAM_PART_ID = StreamPartIDUtils.parse('proxy-test#0')
|
|
18
18
|
const MESSAGE: StreamMessage = {
|
|
19
19
|
messageId: {
|
|
@@ -21,7 +21,7 @@ const MESSAGE: StreamMessage = {
|
|
|
21
21
|
streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
22
22
|
timestamp: 666,
|
|
23
23
|
sequenceNumber: 0,
|
|
24
|
-
publisherId:
|
|
24
|
+
publisherId: toUserIdRaw(randomUserId()),
|
|
25
25
|
messageChainId: 'msgChainId'
|
|
26
26
|
},
|
|
27
27
|
previousMessageRef: {
|
|
@@ -79,7 +79,6 @@ describe('Proxy connections', () => {
|
|
|
79
79
|
}
|
|
80
80
|
})
|
|
81
81
|
await proxyNode1.start()
|
|
82
|
-
proxyNode1.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor1])
|
|
83
82
|
proxyNode1.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
84
83
|
proxyNode2 = createNetworkNode({
|
|
85
84
|
layer0: {
|
|
@@ -92,7 +91,6 @@ describe('Proxy connections', () => {
|
|
|
92
91
|
}
|
|
93
92
|
})
|
|
94
93
|
await proxyNode2.start()
|
|
95
|
-
proxyNode2.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor1])
|
|
96
94
|
proxyNode2.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
97
95
|
proxiedNode = createNetworkNode({
|
|
98
96
|
layer0: {
|
|
@@ -131,7 +129,7 @@ describe('Proxy connections', () => {
|
|
|
131
129
|
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
132
130
|
await proxiedNode.setProxies(STREAM_PART_ID, [], ProxyDirection.PUBLISH, PROXIED_NODE_USER_ID, 0)
|
|
133
131
|
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(false)
|
|
134
|
-
await
|
|
132
|
+
await until(() => hasConnectionFromProxy(proxyNode1) === false)
|
|
135
133
|
})
|
|
136
134
|
|
|
137
135
|
it('can leave proxy subscribe connection', async () => {
|
|
@@ -140,7 +138,7 @@ describe('Proxy connections', () => {
|
|
|
140
138
|
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
141
139
|
await proxiedNode.setProxies(STREAM_PART_ID, [], ProxyDirection.SUBSCRIBE, PROXIED_NODE_USER_ID, 0)
|
|
142
140
|
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(false)
|
|
143
|
-
await
|
|
141
|
+
await until(() => hasConnectionFromProxy(proxyNode1) === false)
|
|
144
142
|
})
|
|
145
143
|
|
|
146
144
|
it('can open multiple proxy connections', async () => {
|
|
@@ -167,7 +165,7 @@ describe('Proxy connections', () => {
|
|
|
167
165
|
expect(hasConnectionFromProxy(proxyNode2)).toBe(true)
|
|
168
166
|
await proxiedNode.setProxies(STREAM_PART_ID, [proxyNode1.getPeerDescriptor()], ProxyDirection.SUBSCRIBE, PROXIED_NODE_USER_ID)
|
|
169
167
|
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(true)
|
|
170
|
-
await
|
|
168
|
+
await until(() => hasConnectionFromProxy(proxyNode2) === false)
|
|
171
169
|
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
172
170
|
})
|
|
173
171
|
|
|
@@ -184,8 +182,8 @@ describe('Proxy connections', () => {
|
|
|
184
182
|
|
|
185
183
|
await proxiedNode.setProxies(STREAM_PART_ID, [], ProxyDirection.SUBSCRIBE, PROXIED_NODE_USER_ID)
|
|
186
184
|
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(false)
|
|
187
|
-
await
|
|
188
|
-
await
|
|
185
|
+
await until(() => hasConnectionFromProxy(proxyNode1) === false)
|
|
186
|
+
await until(() => hasConnectionFromProxy(proxyNode2) === false)
|
|
189
187
|
})
|
|
190
188
|
|
|
191
189
|
it('will reconnect if proxy node goes offline and comes back online', async () => {
|
|
@@ -197,10 +195,10 @@ describe('Proxy connections', () => {
|
|
|
197
195
|
)
|
|
198
196
|
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(true)
|
|
199
197
|
await proxyNode1.leave(STREAM_PART_ID)
|
|
200
|
-
await
|
|
198
|
+
await until(() => hasConnectionToProxy(proxyNode1.getNodeId(), ProxyDirection.SUBSCRIBE))
|
|
201
199
|
expect(hasConnectionFromProxy(proxyNode1)).toBe(false)
|
|
202
200
|
proxyNode1.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
203
|
-
await
|
|
201
|
+
await until(() => hasConnectionToProxy(proxyNode1.getNodeId(), ProxyDirection.SUBSCRIBE), 25000)
|
|
204
202
|
// TODO why wait is needed?
|
|
205
203
|
await wait(100)
|
|
206
204
|
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
1
2
|
import {
|
|
2
3
|
StreamPartIDUtils,
|
|
3
|
-
hexToBinary,
|
|
4
|
+
hexToBinary,
|
|
5
|
+
toUserIdRaw,
|
|
6
|
+
waitForEvent3
|
|
4
7
|
} from '@streamr/utils'
|
|
5
8
|
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
6
|
-
import { ProxyDirection, SignatureType, StreamMessage } from '../../
|
|
9
|
+
import { ProxyDirection, SignatureType, StreamMessage } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
7
10
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
8
11
|
|
|
9
12
|
const STREAM_PART_ID = StreamPartIDUtils.parse('proxy-test#0')
|
|
@@ -15,8 +18,8 @@ describe('proxy group key exchange', () => {
|
|
|
15
18
|
const publisherDescriptor = createMockPeerDescriptor()
|
|
16
19
|
const subscriberDescriptor = createMockPeerDescriptor()
|
|
17
20
|
|
|
18
|
-
const publisherUserId =
|
|
19
|
-
const subscriberUserId =
|
|
21
|
+
const publisherUserId = randomUserId()
|
|
22
|
+
const subscriberUserId = randomUserId()
|
|
20
23
|
|
|
21
24
|
let proxyNode: NetworkNode
|
|
22
25
|
let publisher: NetworkNode
|
|
@@ -34,7 +37,6 @@ describe('proxy group key exchange', () => {
|
|
|
34
37
|
}
|
|
35
38
|
})
|
|
36
39
|
await proxyNode.start()
|
|
37
|
-
proxyNode.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor])
|
|
38
40
|
proxyNode.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
39
41
|
publisher = createNetworkNode({
|
|
40
42
|
layer0: {
|
|
@@ -69,14 +71,14 @@ describe('proxy group key exchange', () => {
|
|
|
69
71
|
streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
70
72
|
timestamp: Date.now(),
|
|
71
73
|
sequenceNumber: 0,
|
|
72
|
-
publisherId:
|
|
74
|
+
publisherId: toUserIdRaw(subscriberUserId),
|
|
73
75
|
messageChainId: '0'
|
|
74
76
|
},
|
|
75
77
|
body: {
|
|
76
78
|
oneofKind: 'groupKeyRequest' as const,
|
|
77
79
|
groupKeyRequest: {
|
|
78
80
|
requestId: 'requestId',
|
|
79
|
-
recipientId:
|
|
81
|
+
recipientId: toUserIdRaw(publisherUserId),
|
|
80
82
|
rsaPublicKey: new Uint8Array(),
|
|
81
83
|
groupKeyIds: ['mock']
|
|
82
84
|
}
|
|
@@ -101,14 +103,14 @@ describe('proxy group key exchange', () => {
|
|
|
101
103
|
streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
102
104
|
timestamp: Date.now(),
|
|
103
105
|
sequenceNumber: 0,
|
|
104
|
-
publisherId:
|
|
106
|
+
publisherId: toUserIdRaw(publisherUserId),
|
|
105
107
|
messageChainId: '0'
|
|
106
108
|
},
|
|
107
109
|
body: {
|
|
108
110
|
oneofKind: 'groupKeyResponse' as const,
|
|
109
111
|
groupKeyResponse: {
|
|
110
112
|
requestId: 'requestId',
|
|
111
|
-
recipientId:
|
|
113
|
+
recipientId: toUserIdRaw(publisherUserId),
|
|
112
114
|
groupKeys: []
|
|
113
115
|
}
|
|
114
116
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
|
|
1
|
+
import { toNodeId, getRandomRegion } from '@streamr/dht'
|
|
2
|
+
import { StreamPartIDUtils, until } from '@streamr/utils'
|
|
4
3
|
import { range } from 'lodash'
|
|
5
4
|
import { NetworkStack } from '../../src/NetworkStack'
|
|
6
5
|
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
6
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
7
7
|
|
|
8
8
|
describe('Full node network with WebRTC connections', () => {
|
|
9
9
|
|
|
@@ -32,7 +32,6 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
32
32
|
}
|
|
33
33
|
})
|
|
34
34
|
await entryPoint.start()
|
|
35
|
-
entryPoint.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
36
35
|
entryPoint.getContentDeliveryManager().joinStreamPart(streamPartId)
|
|
37
36
|
|
|
38
37
|
await Promise.all(range(NUM_OF_NODES).map(async () => {
|
|
@@ -45,7 +44,6 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
45
44
|
})
|
|
46
45
|
nodes.push(node)
|
|
47
46
|
await node.start()
|
|
48
|
-
node.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
49
47
|
node.getContentDeliveryManager().joinStreamPart(streamPartId)
|
|
50
48
|
}))
|
|
51
49
|
|
|
@@ -60,7 +58,7 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
60
58
|
|
|
61
59
|
it('happy path', async () => {
|
|
62
60
|
await Promise.all(nodes.map((node) =>
|
|
63
|
-
|
|
61
|
+
until(() => {
|
|
64
62
|
return node.getContentDeliveryManager().getNeighbors(streamPartId).length >= 3
|
|
65
63
|
}
|
|
66
64
|
, 30000)
|
|
@@ -69,17 +67,17 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
69
67
|
const successIds: string[] = []
|
|
70
68
|
nodes.forEach((node) => {
|
|
71
69
|
node.getContentDeliveryManager().on('newMessage', () => {
|
|
72
|
-
successIds.push(
|
|
70
|
+
successIds.push(toNodeId(node.getContentDeliveryManager().getPeerDescriptor()))
|
|
73
71
|
receivedMessageCount += 1
|
|
74
72
|
})
|
|
75
73
|
})
|
|
76
74
|
const msg = createStreamMessage(
|
|
77
75
|
JSON.stringify({ hello: 'WORLD' }),
|
|
78
76
|
streamPartId,
|
|
79
|
-
|
|
77
|
+
randomUserId()
|
|
80
78
|
)
|
|
81
79
|
entryPoint.getContentDeliveryManager().broadcast(msg)
|
|
82
|
-
await
|
|
80
|
+
await until(() => receivedMessageCount === NUM_OF_NODES)
|
|
83
81
|
}, 120000)
|
|
84
82
|
|
|
85
83
|
})
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
|
|
1
|
+
import { toNodeId } from '@streamr/dht'
|
|
2
|
+
import { StreamPartIDUtils, until } from '@streamr/utils'
|
|
4
3
|
import { range } from 'lodash'
|
|
5
4
|
import { NetworkStack } from '../../src/NetworkStack'
|
|
6
5
|
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
6
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
7
7
|
|
|
8
8
|
describe('Full node network with WebSocket connections only', () => {
|
|
9
9
|
|
|
10
|
-
const NUM_OF_NODES =
|
|
10
|
+
const NUM_OF_NODES = 12
|
|
11
11
|
const epPeerDescriptor = createMockPeerDescriptor({
|
|
12
12
|
websocket: { host: '127.0.0.1', port: 15555, tls: false }
|
|
13
13
|
})
|
|
@@ -29,7 +29,6 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
29
29
|
}
|
|
30
30
|
})
|
|
31
31
|
await entryPoint.start()
|
|
32
|
-
entryPoint.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
33
32
|
entryPoint.getContentDeliveryManager().joinStreamPart(streamPartId)
|
|
34
33
|
|
|
35
34
|
await Promise.all(range(NUM_OF_NODES).map(async (i) => {
|
|
@@ -43,7 +42,6 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
43
42
|
})
|
|
44
43
|
nodes.push(node)
|
|
45
44
|
await node.start()
|
|
46
|
-
node.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
47
45
|
node.getContentDeliveryManager().joinStreamPart(streamPartId)
|
|
48
46
|
}))
|
|
49
47
|
|
|
@@ -58,7 +56,7 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
58
56
|
|
|
59
57
|
it('happy path', async () => {
|
|
60
58
|
await Promise.all(nodes.map((node) =>
|
|
61
|
-
|
|
59
|
+
until(() => {
|
|
62
60
|
return node.getContentDeliveryManager().getNeighbors(streamPartId).length >= 4
|
|
63
61
|
}
|
|
64
62
|
, 30000)
|
|
@@ -67,7 +65,7 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
67
65
|
const successIds: string[] = []
|
|
68
66
|
nodes.forEach((node) => {
|
|
69
67
|
node.getContentDeliveryManager().on('newMessage', () => {
|
|
70
|
-
successIds.push(
|
|
68
|
+
successIds.push(toNodeId(node.getContentDeliveryManager().getPeerDescriptor()))
|
|
71
69
|
receivedMessageCount += 1
|
|
72
70
|
})
|
|
73
71
|
})
|
|
@@ -75,10 +73,10 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
75
73
|
const msg = createStreamMessage(
|
|
76
74
|
JSON.stringify({ hello: 'WORLD' }),
|
|
77
75
|
streamPartId,
|
|
78
|
-
|
|
76
|
+
randomUserId()
|
|
79
77
|
)
|
|
80
78
|
entryPoint.getContentDeliveryManager().broadcast(msg)
|
|
81
|
-
await
|
|
79
|
+
await until(() => receivedMessageCount === NUM_OF_NODES)
|
|
82
80
|
}, 220000)
|
|
83
81
|
|
|
84
82
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DhtNode, LatencyType, PeerDescriptor, Simulator, SimulatorTransport,
|
|
2
|
-
import { StreamPartIDUtils,
|
|
1
|
+
import { DhtNode, LatencyType, PeerDescriptor, Simulator, SimulatorTransport, toNodeId } from '@streamr/dht'
|
|
2
|
+
import { StreamPartIDUtils, until } from '@streamr/utils'
|
|
3
3
|
import { range } from 'lodash'
|
|
4
4
|
import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
|
|
5
5
|
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
|
|
@@ -72,8 +72,8 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
72
72
|
await otherContentDeliveryLayerNodes[0].start()
|
|
73
73
|
await otherDiscoveryLayerNodes[0].joinDht([entrypointDescriptor])
|
|
74
74
|
await Promise.all([
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
until(() => otherContentDeliveryLayerNodes[0].getNearbyNodeView().getIds().length === 1),
|
|
76
|
+
until(() => otherContentDeliveryLayerNodes[0].getNeighbors().length === 1)
|
|
77
77
|
])
|
|
78
78
|
expect(otherContentDeliveryLayerNodes[0].getNearbyNodeView().getIds().length).toEqual(1)
|
|
79
79
|
expect(otherContentDeliveryLayerNodes[0].getNeighbors().length).toEqual(1)
|
|
@@ -84,7 +84,7 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
84
84
|
await Promise.all(range(4).map(async (i) => {
|
|
85
85
|
await otherDiscoveryLayerNodes[i].joinDht([entrypointDescriptor])
|
|
86
86
|
}))
|
|
87
|
-
await
|
|
87
|
+
await until(() => range(4).every((i) => otherContentDeliveryLayerNodes[i].getNeighbors().length >= 4), 15000, 1000)
|
|
88
88
|
range(4).forEach((i) => {
|
|
89
89
|
expect(otherContentDeliveryLayerNodes[i].getNearbyNodeView().getIds().length).toBeGreaterThanOrEqual(4)
|
|
90
90
|
expect(otherContentDeliveryLayerNodes[i].getNeighbors().length).toBeGreaterThanOrEqual(4)
|
|
@@ -98,7 +98,7 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
98
98
|
const neighbor = allNodes.find((node) => {
|
|
99
99
|
return node.getOwnNodeId() === ownNodeId
|
|
100
100
|
})
|
|
101
|
-
const neighborNodeIds = neighbor!.getNeighbors().map((n) =>
|
|
101
|
+
const neighborNodeIds = neighbor!.getNeighbors().map((n) => toNodeId(n))
|
|
102
102
|
expect(neighborNodeIds).toContain(nodeId)
|
|
103
103
|
})
|
|
104
104
|
})
|
|
@@ -110,22 +110,22 @@ describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
|
|
|
110
110
|
otherDiscoveryLayerNodes[i].joinDht([entrypointDescriptor])
|
|
111
111
|
}))
|
|
112
112
|
await Promise.all(otherContentDeliveryLayerNodes.map((node) =>
|
|
113
|
-
|
|
113
|
+
until(() => node.getNeighbors().length >= 4, 10000)
|
|
114
114
|
))
|
|
115
115
|
|
|
116
116
|
await Promise.all(otherContentDeliveryLayerNodes.map((node) =>
|
|
117
|
-
|
|
117
|
+
until(() => node.getOutgoingHandshakeCount() === 0)
|
|
118
118
|
))
|
|
119
119
|
|
|
120
|
-
await
|
|
120
|
+
await until(() => {
|
|
121
121
|
let mismatchCounter = 0
|
|
122
122
|
otherContentDeliveryLayerNodes.forEach((node) => {
|
|
123
123
|
const nodeId = node.getOwnNodeId()
|
|
124
124
|
node.getNeighbors().forEach((neighbor) => {
|
|
125
|
-
const neighborId =
|
|
125
|
+
const neighborId = toNodeId(neighbor)
|
|
126
126
|
if (neighborId !== entryPointContentDeliveryLayerNode.getOwnNodeId()) {
|
|
127
127
|
const neighbor = otherContentDeliveryLayerNodes.find((n) => n.getOwnNodeId() === neighborId)
|
|
128
|
-
const neighborNodeIds = neighbor!.getNeighbors().map((n) =>
|
|
128
|
+
const neighborNodeIds = neighbor!.getNeighbors().map((n) => toNodeId(n))
|
|
129
129
|
if (!neighborNodeIds.includes(nodeId)) {
|
|
130
130
|
mismatchCounter += 1
|
|
131
131
|
}
|