@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,9 +1,10 @@
|
|
|
1
1
|
import { LatencyType, PeerDescriptor, Simulator, SimulatorTransport } from '@streamr/dht'
|
|
2
|
-
import {
|
|
2
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
3
|
+
import { StreamPartIDUtils, hexToBinary, toUserIdRaw, utf8ToBinary, until } from '@streamr/utils'
|
|
3
4
|
import { range } from 'lodash'
|
|
4
5
|
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
5
6
|
import { streamPartIdToDataKey } from '../../src/logic/ContentDeliveryManager'
|
|
6
|
-
import { ContentType, EncryptionType, SignatureType, StreamMessage } from '../../
|
|
7
|
+
import { ContentType, EncryptionType, SignatureType, StreamMessage } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
7
8
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
8
9
|
|
|
9
10
|
const STREAM_PART_ID = StreamPartIDUtils.parse('test#0')
|
|
@@ -21,7 +22,7 @@ describe('stream without default entrypoints', () => {
|
|
|
21
22
|
streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
22
23
|
timestamp: 666,
|
|
23
24
|
sequenceNumber: 0,
|
|
24
|
-
publisherId:
|
|
25
|
+
publisherId: toUserIdRaw(randomUserId()),
|
|
25
26
|
messageChainId: 'msgChainId'
|
|
26
27
|
},
|
|
27
28
|
previousMessageRef: {
|
|
@@ -85,7 +86,7 @@ describe('stream without default entrypoints', () => {
|
|
|
85
86
|
receivedMessageCount += 1
|
|
86
87
|
})
|
|
87
88
|
await Promise.all([
|
|
88
|
-
|
|
89
|
+
until(() => receivedMessageCount === 1, 10000),
|
|
89
90
|
nodes[1].broadcast(streamMessage)
|
|
90
91
|
])
|
|
91
92
|
})
|
|
@@ -95,7 +96,7 @@ describe('stream without default entrypoints', () => {
|
|
|
95
96
|
receivedMessageCount += 1
|
|
96
97
|
})
|
|
97
98
|
await Promise.all([
|
|
98
|
-
|
|
99
|
+
until(() => receivedMessageCount === 1, 15000),
|
|
99
100
|
nodes[0].join(STREAM_PART_ID),
|
|
100
101
|
nodes[1].broadcast(streamMessage),
|
|
101
102
|
])
|
|
@@ -111,14 +112,14 @@ describe('stream without default entrypoints', () => {
|
|
|
111
112
|
}))
|
|
112
113
|
const nonjoinedNode = nodes[subscriberCount]
|
|
113
114
|
await nonjoinedNode.broadcast(streamMessage)
|
|
114
|
-
await
|
|
115
|
+
await until(() => receivedMessageCount === subscriberCount, 15000)
|
|
115
116
|
}, 45000)
|
|
116
117
|
|
|
117
118
|
it('nodes store themselves as entrypoints on streamPart if number of entrypoints is low', async () => {
|
|
118
119
|
for (let i = 0; i < 10; i++) {
|
|
119
120
|
await nodes[i].join(STREAM_PART_ID, { minCount: (i > 0) ? 1 : 0, timeout: 15000 })
|
|
120
121
|
}
|
|
121
|
-
await
|
|
122
|
+
await until(async () => {
|
|
122
123
|
const entryPointData = await nodes[15].stack.getControlLayerNode().fetchDataFromDht(streamPartIdToDataKey(STREAM_PART_ID))
|
|
123
124
|
return entryPointData.length >= 7
|
|
124
125
|
}, 15000)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LatencyType, Simulator, SimulatorTransport } from '@streamr/dht'
|
|
2
|
-
import {
|
|
3
|
-
import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
|
|
2
|
+
import { StreamPartIDUtils, until } from '@streamr/utils'
|
|
4
3
|
import { range } from 'lodash'
|
|
5
4
|
import { NetworkStack } from '../../src/NetworkStack'
|
|
6
5
|
import { MAX_NODE_COUNT } from '../../src/logic/PeerDescriptorStoreManager'
|
|
7
6
|
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
7
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
8
8
|
|
|
9
9
|
describe('Stream Entry Points are replaced when known entry points leave streams', () => {
|
|
10
10
|
|
|
@@ -82,16 +82,16 @@ describe('Stream Entry Points are replaced when known entry points leave streams
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
await Promise.all(initialNodesOnStream.map((node) => node.getContentDeliveryManager().leaveStreamPart(STREAM_PART_ID)))
|
|
85
|
-
await
|
|
85
|
+
await until(() =>
|
|
86
86
|
laterNodesOnStream.every((node) => node.getContentDeliveryManager().getNeighbors(STREAM_PART_ID).length >= 4), 60000, 1000
|
|
87
87
|
)
|
|
88
88
|
|
|
89
89
|
const msg = createStreamMessage(
|
|
90
90
|
JSON.stringify({ hello: 'WORLD' }),
|
|
91
91
|
STREAM_PART_ID,
|
|
92
|
-
|
|
92
|
+
randomUserId()
|
|
93
93
|
)
|
|
94
94
|
newNodeInStream.getContentDeliveryManager().broadcast(msg)
|
|
95
|
-
await
|
|
95
|
+
await until(() => receivedMessages === NUM_OF_LATER_NODES, 30000)
|
|
96
96
|
}, 200000)
|
|
97
97
|
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@streamr/test-utils/customMatcherTypes'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StreamPartIDUtils,
|
|
1
|
+
import { toNodeId } from '@streamr/dht'
|
|
2
|
+
import { StreamPartIDUtils, until } from '@streamr/utils'
|
|
3
3
|
import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
|
|
4
4
|
import { NodeList } from '../../src/logic/NodeList'
|
|
5
5
|
import { createContentDeliveryLayerNode } from '../../src/logic/createContentDeliveryLayerNode'
|
|
@@ -22,7 +22,7 @@ describe('ContentDeliveryLayerNode', () => {
|
|
|
22
22
|
let discoveryLayerNode: MockDiscoveryLayerNode
|
|
23
23
|
|
|
24
24
|
beforeEach(async () => {
|
|
25
|
-
const nodeId =
|
|
25
|
+
const nodeId = toNodeId(peerDescriptor)
|
|
26
26
|
|
|
27
27
|
neighbors = new NodeList(nodeId, 10)
|
|
28
28
|
randomNodeView = new NodeList(nodeId, 10)
|
|
@@ -54,14 +54,14 @@ describe('ContentDeliveryLayerNode', () => {
|
|
|
54
54
|
const mockRemote = createMockContentDeliveryRpcRemote()
|
|
55
55
|
neighbors.add(mockRemote)
|
|
56
56
|
const result = contentDeliveryLayerNode.getNeighbors()
|
|
57
|
-
expect(
|
|
57
|
+
expect(toNodeId(result[0])).toEqual(toNodeId(mockRemote.getPeerDescriptor()))
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
it('getNearbyNodeView', () => {
|
|
61
61
|
const mockRemote = createMockContentDeliveryRpcRemote()
|
|
62
62
|
nearbyNodeView.add(mockRemote)
|
|
63
63
|
const ids = contentDeliveryLayerNode.getNearbyNodeView().getIds()
|
|
64
|
-
expect(ids[0]).toEqual(
|
|
64
|
+
expect(ids[0]).toEqual(toNodeId(mockRemote.getPeerDescriptor()))
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
it('Adds Closest Nodes from layer1 nearbyContactAdded event to nearbyNodeView', async () => {
|
|
@@ -69,9 +69,9 @@ describe('ContentDeliveryLayerNode', () => {
|
|
|
69
69
|
const peerDescriptor2 = createMockPeerDescriptor()
|
|
70
70
|
discoveryLayerNode.setClosestContacts([peerDescriptor1, peerDescriptor2])
|
|
71
71
|
discoveryLayerNode.emit('nearbyContactAdded', peerDescriptor1)
|
|
72
|
-
await
|
|
73
|
-
expect(nearbyNodeView.get(
|
|
74
|
-
expect(nearbyNodeView.get(
|
|
72
|
+
await until(() => nearbyNodeView.size() === 2)
|
|
73
|
+
expect(nearbyNodeView.get(toNodeId(peerDescriptor1))).toBeTruthy()
|
|
74
|
+
expect(nearbyNodeView.get(toNodeId(peerDescriptor2))).toBeTruthy()
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
it('Adds Random Nodes from layer1 randomContactAdded event to randomNodeView', async () => {
|
|
@@ -79,9 +79,9 @@ describe('ContentDeliveryLayerNode', () => {
|
|
|
79
79
|
const peerDescriptor2 = createMockPeerDescriptor()
|
|
80
80
|
discoveryLayerNode.setRandomContacts([peerDescriptor1, peerDescriptor2])
|
|
81
81
|
discoveryLayerNode.emit('randomContactAdded', peerDescriptor1)
|
|
82
|
-
await
|
|
83
|
-
expect(randomNodeView.get(
|
|
84
|
-
expect(randomNodeView.get(
|
|
82
|
+
await until(() => randomNodeView.size() === 2)
|
|
83
|
+
expect(randomNodeView.get(toNodeId(peerDescriptor1))).toBeTruthy()
|
|
84
|
+
expect(randomNodeView.get(toNodeId(peerDescriptor2))).toBeTruthy()
|
|
85
85
|
})
|
|
86
86
|
|
|
87
87
|
it('Adds Nodes from layer1 neighbors to nearbyNodeView if its size is below nodeViewSize', async () => {
|
|
@@ -90,11 +90,23 @@ describe('ContentDeliveryLayerNode', () => {
|
|
|
90
90
|
discoveryLayerNode.addNewRandomPeerToKBucket()
|
|
91
91
|
discoveryLayerNode.setClosestContacts([peerDescriptor1, peerDescriptor2])
|
|
92
92
|
discoveryLayerNode.emit('nearbyContactAdded', peerDescriptor1)
|
|
93
|
-
await
|
|
93
|
+
await until(() => {
|
|
94
94
|
return nearbyNodeView.size() === 3
|
|
95
95
|
}, 20000)
|
|
96
|
-
expect(nearbyNodeView.get(
|
|
97
|
-
expect(nearbyNodeView.get(
|
|
96
|
+
expect(nearbyNodeView.get(toNodeId(peerDescriptor1))).toBeTruthy()
|
|
97
|
+
expect(nearbyNodeView.get(toNodeId(peerDescriptor2))).toBeTruthy()
|
|
98
98
|
}, 25000)
|
|
99
99
|
|
|
100
|
+
it('getInfo', () => {
|
|
101
|
+
const nodeWithRtt = createMockContentDeliveryRpcRemote()
|
|
102
|
+
neighbors.add(nodeWithRtt)
|
|
103
|
+
const nodeWithoutRtt = createMockContentDeliveryRpcRemote()
|
|
104
|
+
neighbors.add(nodeWithoutRtt)
|
|
105
|
+
nodeWithRtt.setRtt(100)
|
|
106
|
+
const info = contentDeliveryLayerNode.getInfos()
|
|
107
|
+
expect(info[0].rtt).toEqual(100)
|
|
108
|
+
expect(info[0].peerDescriptor).toEqual(nodeWithRtt.getPeerDescriptor())
|
|
109
|
+
expect(info[1].rtt).toBeUndefined()
|
|
110
|
+
expect(info[1].peerDescriptor).toEqual(nodeWithoutRtt.getPeerDescriptor())
|
|
111
|
+
})
|
|
100
112
|
})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { areEqualPeerDescriptors } from '@streamr/dht'
|
|
2
|
-
import {
|
|
3
|
-
import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
|
|
2
|
+
import { StreamPartIDUtils, until } from '@streamr/utils'
|
|
4
3
|
import { ContentDeliveryManager } from '../../src/logic/ContentDeliveryManager'
|
|
5
|
-
import { ProxyDirection } from '../../
|
|
4
|
+
import { ProxyDirection } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
6
5
|
import { MockControlLayerNode } from '../utils/mock/MockControlLayerNode'
|
|
7
6
|
import { MockTransport } from '../utils/mock/MockTransport'
|
|
8
7
|
import { createMockPeerDescriptor, createStreamMessage, mockConnectionLocker } from '../utils/utils'
|
|
8
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
9
9
|
|
|
10
10
|
describe('ContentDeliveryManager', () => {
|
|
11
11
|
|
|
@@ -23,7 +23,8 @@ describe('ContentDeliveryManager', () => {
|
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
it('PeerDescriptor is correct', () => {
|
|
26
|
-
|
|
26
|
+
// TODO could use toEqualPeerDescriptor from dht package if we export that custom matcher
|
|
27
|
+
expect(areEqualPeerDescriptors(peerDescriptor, manager.getPeerDescriptor())).toBe(true)
|
|
27
28
|
})
|
|
28
29
|
|
|
29
30
|
describe('join and leave', () => {
|
|
@@ -32,7 +33,7 @@ describe('ContentDeliveryManager', () => {
|
|
|
32
33
|
const message = createStreamMessage(
|
|
33
34
|
JSON.stringify({ hello: 'WORLD' }),
|
|
34
35
|
streamPartId,
|
|
35
|
-
|
|
36
|
+
randomUserId()
|
|
36
37
|
)
|
|
37
38
|
|
|
38
39
|
beforeEach(async () => {
|
|
@@ -53,7 +54,7 @@ describe('ContentDeliveryManager', () => {
|
|
|
53
54
|
|
|
54
55
|
it('broadcast joins stream', async () => {
|
|
55
56
|
manager.broadcast(message)
|
|
56
|
-
await
|
|
57
|
+
await until(() => manager.hasStreamPart(streamPartId))
|
|
57
58
|
})
|
|
58
59
|
})
|
|
59
60
|
|
|
@@ -61,7 +62,7 @@ describe('ContentDeliveryManager', () => {
|
|
|
61
62
|
it('happy path', async () => {
|
|
62
63
|
const streamPartId = StreamPartIDUtils.parse('stream#0')
|
|
63
64
|
const proxy = createMockPeerDescriptor()
|
|
64
|
-
const userId =
|
|
65
|
+
const userId = randomUserId()
|
|
65
66
|
await manager.setProxies(streamPartId, [proxy], ProxyDirection.PUBLISH, userId)
|
|
66
67
|
expect(manager.isProxiedStreamPart(streamPartId)).toBe(true)
|
|
67
68
|
await manager.setProxies(streamPartId, [], ProxyDirection.PUBLISH, userId)
|
|
@@ -71,7 +72,7 @@ describe('ContentDeliveryManager', () => {
|
|
|
71
72
|
it('empty node list', async () => {
|
|
72
73
|
const streamPartId = StreamPartIDUtils.parse('stream#0')
|
|
73
74
|
const proxy = createMockPeerDescriptor()
|
|
74
|
-
const userId =
|
|
75
|
+
const userId = randomUserId()
|
|
75
76
|
await manager.setProxies(streamPartId, [], ProxyDirection.PUBLISH, userId)
|
|
76
77
|
expect(manager.isProxiedStreamPart(streamPartId)).toBe(false)
|
|
77
78
|
await manager.setProxies(streamPartId, [proxy], ProxyDirection.PUBLISH, userId)
|
|
@@ -83,7 +84,7 @@ describe('ContentDeliveryManager', () => {
|
|
|
83
84
|
it('connection count to 0', async () => {
|
|
84
85
|
const streamPartId = StreamPartIDUtils.parse('stream#0')
|
|
85
86
|
const proxy = createMockPeerDescriptor()
|
|
86
|
-
const userId =
|
|
87
|
+
const userId = randomUserId()
|
|
87
88
|
await manager.setProxies(streamPartId, [proxy], ProxyDirection.PUBLISH, userId, 0)
|
|
88
89
|
expect(manager.isProxiedStreamPart(streamPartId)).toBe(false)
|
|
89
90
|
await manager.setProxies(streamPartId, [proxy], ProxyDirection.PUBLISH, userId)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ListeningRpcCommunicator } from '@streamr/dht'
|
|
2
|
-
import { randomEthereumAddress } from '@streamr/test-utils'
|
|
3
2
|
import { StreamPartIDUtils } from '@streamr/utils'
|
|
4
3
|
import { ContentDeliveryRpcLocal } from '../../src/logic/ContentDeliveryRpcLocal'
|
|
5
|
-
import { LeaveStreamPartNotice } from '../../
|
|
4
|
+
import { LeaveStreamPartNotice } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
6
5
|
import { MockTransport } from '../utils/mock/MockTransport'
|
|
7
6
|
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
7
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
8
8
|
|
|
9
9
|
describe('ContentDeliveryRpcLocal', () => {
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ describe('ContentDeliveryRpcLocal', () => {
|
|
|
16
16
|
const message = createStreamMessage(
|
|
17
17
|
JSON.stringify({ hello: 'WORLD' }),
|
|
18
18
|
StreamPartIDUtils.parse('random-graph#0'),
|
|
19
|
-
|
|
19
|
+
randomUserId()
|
|
20
20
|
)
|
|
21
21
|
|
|
22
22
|
let mockBroadcast: jest.Mock
|
|
@@ -60,10 +60,10 @@ describe('gap handling', () => {
|
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
test('gap division', () => {
|
|
63
|
-
expect(detector.markAndCheck(new NumberPair(15, 0), new NumberPair(18, 0)))
|
|
63
|
+
expect(detector.markAndCheck(new NumberPair(15, 0), new NumberPair(18, 0))).toEqual(true)
|
|
64
64
|
expect(detector.toString()).toEqual('(10|0, 15|0], (18|0, 20|0], (40|0, 80|10], (100|0, Infinity|Infinity]')
|
|
65
65
|
|
|
66
|
-
expect(detector.markAndCheck(new NumberPair(60, 0), new NumberPair(79, 5)))
|
|
66
|
+
expect(detector.markAndCheck(new NumberPair(60, 0), new NumberPair(79, 5))).toEqual(true)
|
|
67
67
|
expect(detector.toString()).toEqual('(10|0, 15|0], (18|0, 20|0], (40|0, 60|0], (79|5, 80|10], (100|0, Infinity|Infinity]')
|
|
68
68
|
})
|
|
69
69
|
|
|
@@ -84,10 +84,10 @@ describe('gap handling', () => {
|
|
|
84
84
|
})
|
|
85
85
|
|
|
86
86
|
test('full contraction', () => {
|
|
87
|
-
expect(detector.markAndCheck(new NumberPair(40, 0), new NumberPair(80, 10)))
|
|
87
|
+
expect(detector.markAndCheck(new NumberPair(40, 0), new NumberPair(80, 10))).toEqual(true)
|
|
88
88
|
expect(detector.toString()).toEqual('(10|0, 20|0], (100|0, Infinity|Infinity]')
|
|
89
89
|
|
|
90
|
-
expect(detector.markAndCheck(new NumberPair(10, 0), new NumberPair(20, 0)))
|
|
90
|
+
expect(detector.markAndCheck(new NumberPair(10, 0), new NumberPair(20, 0))).toEqual(true)
|
|
91
91
|
expect(detector.toString()).toEqual('(100|0, Infinity|Infinity]')
|
|
92
92
|
})
|
|
93
93
|
})
|
|
@@ -153,28 +153,28 @@ describe('erroneous messages that overlap gaps', () => {
|
|
|
153
153
|
})
|
|
154
154
|
|
|
155
155
|
it('completely around gap', () => {
|
|
156
|
-
expect(() => detector.markAndCheck(new NumberPair(5, 0), new NumberPair(30, 0))).
|
|
156
|
+
expect(() => detector.markAndCheck(new NumberPair(5, 0), new NumberPair(30, 0))).toThrow(GapMisMatchError)
|
|
157
157
|
})
|
|
158
158
|
|
|
159
159
|
it('previousNumber below gap while number in gap', () => {
|
|
160
|
-
expect(() => detector.markAndCheck(new NumberPair(5, 0), new NumberPair(15, 0))).
|
|
160
|
+
expect(() => detector.markAndCheck(new NumberPair(5, 0), new NumberPair(15, 0))).toThrow(GapMisMatchError)
|
|
161
161
|
})
|
|
162
162
|
|
|
163
163
|
it('previousNumber in gap while number over gap', () => {
|
|
164
|
-
expect(() => detector.markAndCheck(new NumberPair(15, 0), new NumberPair(20, 5))).
|
|
164
|
+
expect(() => detector.markAndCheck(new NumberPair(15, 0), new NumberPair(20, 5))).toThrow(GapMisMatchError)
|
|
165
165
|
})
|
|
166
166
|
|
|
167
167
|
it('completely around multiple gaps', () => {
|
|
168
|
-
expect(() => detector.markAndCheck(new NumberPair(10, 0), new NumberPair(200, 0))).
|
|
168
|
+
expect(() => detector.markAndCheck(new NumberPair(10, 0), new NumberPair(200, 0))).toThrow(GapMisMatchError)
|
|
169
169
|
})
|
|
170
170
|
})
|
|
171
171
|
|
|
172
172
|
test('checks that number > previousNumber', () => {
|
|
173
173
|
const detector = new DuplicateMessageDetector()
|
|
174
174
|
expect(() => detector.markAndCheck(new NumberPair(5, 0), new NumberPair(1, 0)))
|
|
175
|
-
.
|
|
175
|
+
.toThrow(InvalidNumberingError)
|
|
176
176
|
expect(() => detector.markAndCheck(new NumberPair(5, 5), new NumberPair(5, 5)))
|
|
177
|
-
.
|
|
177
|
+
.toThrow(InvalidNumberingError)
|
|
178
178
|
})
|
|
179
179
|
|
|
180
180
|
test('lowest gaps get dropped when reaching maximum number of gaps', () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Message } from '@streamr/dht'
|
|
2
2
|
import { ExternalNetworkRpc, SERVICE_ID } from '../../src/logic/ExternalNetworkRpc'
|
|
3
|
-
import { HandshakeRequest, HandshakeResponse } from '../../
|
|
3
|
+
import { HandshakeRequest, HandshakeResponse } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { MockTransport } from '../utils/mock/MockTransport'
|
|
5
5
|
import { RpcMessage } from '@streamr/proto-rpc'
|
|
6
|
-
import { Any } from '../../
|
|
7
|
-
import { HandshakeRpcClient } from '../../
|
|
6
|
+
import { Any } from '../../generated/google/protobuf/any'
|
|
7
|
+
import { HandshakeRpcClient } from '../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
8
8
|
|
|
9
9
|
describe('ExternalNetworkRpc', () => {
|
|
10
10
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DhtAddress, NodeType,
|
|
1
|
+
import { DhtAddress, NodeType, toNodeId, toDhtAddressRaw } from '@streamr/dht'
|
|
2
2
|
import { StreamPartIDUtils } from '@streamr/utils'
|
|
3
3
|
import { NodeList } from '../../src/logic/NodeList'
|
|
4
4
|
import { HandshakeRpcLocal } from '../../src/logic/neighbor-discovery/HandshakeRpcLocal'
|
|
5
|
-
import { InterleaveRequest, StreamPartHandshakeRequest } from '../../
|
|
5
|
+
import { InterleaveRequest, StreamPartHandshakeRequest } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
6
6
|
import { createMockContentDeliveryRpcRemote, createMockHandshakeRpcRemote, createMockPeerDescriptor } from '../utils/utils'
|
|
7
7
|
|
|
8
8
|
const STREAM_PART_ID = StreamPartIDUtils.parse('stream#0')
|
|
@@ -19,7 +19,7 @@ describe('HandshakeRpcLocal', () => {
|
|
|
19
19
|
let handshakeWithInterleaving: jest.Mock
|
|
20
20
|
|
|
21
21
|
beforeEach(() => {
|
|
22
|
-
neighbors = new NodeList(
|
|
22
|
+
neighbors = new NodeList(toNodeId(localPeerDescriptor), 10)
|
|
23
23
|
ongoingHandshakes = new Set()
|
|
24
24
|
ongoingInterleaves = new Set()
|
|
25
25
|
handshakeWithInterleaving = jest.fn()
|
|
@@ -86,20 +86,7 @@ describe('HandshakeRpcLocal', () => {
|
|
|
86
86
|
it('handshakeWithInterleaving success', async () => {
|
|
87
87
|
const req: InterleaveRequest = {
|
|
88
88
|
interleaveTargetDescriptor: {
|
|
89
|
-
nodeId:
|
|
90
|
-
type: NodeType.NODEJS
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
await rpcLocal.interleaveRequest(req, {
|
|
94
|
-
incomingSourceDescriptor: createMockPeerDescriptor()
|
|
95
|
-
} as any)
|
|
96
|
-
expect(handshakeWithInterleaving).toHaveBeenCalledTimes(1)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
it('handshakeWithInterleaving success', async () => {
|
|
100
|
-
const req: InterleaveRequest = {
|
|
101
|
-
interleaveTargetDescriptor: {
|
|
102
|
-
nodeId: getRawFromDhtAddress('0x2222' as DhtAddress),
|
|
89
|
+
nodeId: toDhtAddressRaw('0x2222' as DhtAddress),
|
|
103
90
|
type: NodeType.NODEJS
|
|
104
91
|
}
|
|
105
92
|
}
|
|
@@ -115,7 +102,7 @@ describe('HandshakeRpcLocal', () => {
|
|
|
115
102
|
neighbors.add(createMockContentDeliveryRpcRemote())
|
|
116
103
|
neighbors.add(createMockContentDeliveryRpcRemote())
|
|
117
104
|
const requestor = createMockPeerDescriptor()
|
|
118
|
-
ongoingInterleaves.add(
|
|
105
|
+
ongoingInterleaves.add(toNodeId(requestor))
|
|
119
106
|
const req = StreamPartHandshakeRequest.create({
|
|
120
107
|
streamPartId: STREAM_PART_ID,
|
|
121
108
|
requestId: 'requestId'
|
|
@@ -134,9 +121,9 @@ describe('HandshakeRpcLocal', () => {
|
|
|
134
121
|
neighbors.add(createMockContentDeliveryRpcRemote(interleavingPeer2))
|
|
135
122
|
neighbors.add(createMockContentDeliveryRpcRemote(interleavingPeer3))
|
|
136
123
|
neighbors.add(createMockContentDeliveryRpcRemote())
|
|
137
|
-
ongoingInterleaves.add(
|
|
138
|
-
ongoingInterleaves.add(
|
|
139
|
-
ongoingInterleaves.add(
|
|
124
|
+
ongoingInterleaves.add(toNodeId(interleavingPeer1))
|
|
125
|
+
ongoingInterleaves.add(toNodeId(interleavingPeer2))
|
|
126
|
+
ongoingInterleaves.add(toNodeId(interleavingPeer3))
|
|
140
127
|
const req = StreamPartHandshakeRequest.create({
|
|
141
128
|
streamPartId: STREAM_PART_ID,
|
|
142
129
|
requestId: 'requestId'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListeningRpcCommunicator, Simulator, SimulatorTransport,
|
|
1
|
+
import { ListeningRpcCommunicator, Simulator, SimulatorTransport, toNodeId } from '@streamr/dht'
|
|
2
2
|
import { StreamPartIDUtils } from '@streamr/utils'
|
|
3
3
|
import { range } from 'lodash'
|
|
4
4
|
import { NodeList } from '../../src/logic/NodeList'
|
|
@@ -28,7 +28,7 @@ describe('Handshaker', () => {
|
|
|
28
28
|
await simulatorTransport.start()
|
|
29
29
|
const rpcCommunicator = new ListeningRpcCommunicator(streamPartId, simulatorTransport)
|
|
30
30
|
|
|
31
|
-
const nodeId =
|
|
31
|
+
const nodeId = toNodeId(peerDescriptor)
|
|
32
32
|
neighbors = new NodeList(nodeId, 10)
|
|
33
33
|
leftNodeView = new NodeList(nodeId, 20)
|
|
34
34
|
rightNodeView = new NodeList(nodeId, 20)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InspectSession, Events } from '../../src/logic/inspect/InspectSession'
|
|
2
|
-
import { MessageID } from '../../
|
|
2
|
+
import { MessageID } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
3
3
|
import { waitForEvent3 } from '../../../utils/dist/src/waitForEvent3'
|
|
4
4
|
import { utf8ToBinary } from '@streamr/utils'
|
|
5
|
-
import { DhtAddress,
|
|
5
|
+
import { DhtAddress, randomDhtAddress } from '@streamr/dht'
|
|
6
6
|
|
|
7
7
|
describe('InspectSession', () => {
|
|
8
8
|
|
|
@@ -30,8 +30,8 @@ describe('InspectSession', () => {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
beforeEach(() => {
|
|
33
|
-
inspectedNode =
|
|
34
|
-
anotherNode =
|
|
33
|
+
inspectedNode = randomDhtAddress()
|
|
34
|
+
anotherNode = randomDhtAddress()
|
|
35
35
|
inspectSession = new InspectSession({
|
|
36
36
|
inspectedNode
|
|
37
37
|
})
|
|
@@ -52,6 +52,7 @@ describe('InspectSession', () => {
|
|
|
52
52
|
inspectSession.markMessage(anotherNode, messageId1)
|
|
53
53
|
await Promise.all([
|
|
54
54
|
waitForEvent3<Events>(inspectSession, 'done', 100),
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
55
56
|
inspectSession.markMessage(inspectedNode, messageId1)
|
|
56
57
|
])
|
|
57
58
|
expect(inspectSession.getInspectedMessageCount()).toBe(1)
|
|
@@ -61,6 +62,7 @@ describe('InspectSession', () => {
|
|
|
61
62
|
inspectSession.markMessage(inspectedNode, messageId1)
|
|
62
63
|
await Promise.all([
|
|
63
64
|
waitForEvent3<Events>(inspectSession, 'done', 100),
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
64
66
|
inspectSession.markMessage(anotherNode, messageId1)
|
|
65
67
|
])
|
|
66
68
|
expect(inspectSession.getInspectedMessageCount()).toBe(1)
|
|
@@ -71,6 +73,7 @@ describe('InspectSession', () => {
|
|
|
71
73
|
await expect(async () => {
|
|
72
74
|
await Promise.all([
|
|
73
75
|
waitForEvent3<Events>(inspectSession, 'done', 100),
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
74
77
|
inspectSession.markMessage(anotherNode, messageId2)
|
|
75
78
|
])
|
|
76
79
|
}).rejects.toThrow('waitForEvent3')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListeningRpcCommunicator,
|
|
1
|
+
import { ListeningRpcCommunicator, randomDhtAddress, toNodeId } from '@streamr/dht'
|
|
2
2
|
import { StreamPartIDUtils, utf8ToBinary } from '@streamr/utils'
|
|
3
3
|
import { Inspector } from '../../src/logic/inspect/Inspector'
|
|
4
4
|
import { MockTransport } from '../utils/mock/MockTransport'
|
|
@@ -11,7 +11,7 @@ describe('Inspector', () => {
|
|
|
11
11
|
|
|
12
12
|
const inspectedDescriptor = createMockPeerDescriptor()
|
|
13
13
|
|
|
14
|
-
const nodeId =
|
|
14
|
+
const nodeId = randomDhtAddress()
|
|
15
15
|
let mockConnect: jest.Mock
|
|
16
16
|
|
|
17
17
|
const messageRef = {
|
|
@@ -40,12 +40,12 @@ describe('Inspector', () => {
|
|
|
40
40
|
|
|
41
41
|
it('Opens inspection connection and runs successfully', async () => {
|
|
42
42
|
setTimeout(() => {
|
|
43
|
-
inspector.markMessage(
|
|
43
|
+
inspector.markMessage(toNodeId(inspectedDescriptor), messageRef)
|
|
44
44
|
inspector.markMessage(nodeId, messageRef)
|
|
45
45
|
}, 250)
|
|
46
46
|
await inspector.inspect(inspectedDescriptor)
|
|
47
|
-
expect(inspector.isInspected(
|
|
48
|
-
expect(mockConnect).
|
|
47
|
+
expect(inspector.isInspected(toNodeId(inspectedDescriptor))).toBe(false)
|
|
48
|
+
expect(mockConnect).toHaveBeenCalledTimes(1)
|
|
49
49
|
})
|
|
50
50
|
|
|
51
51
|
})
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { NeighborFinder } from '../../src/logic/neighbor-discovery/NeighborFinder'
|
|
2
2
|
import { NodeList } from '../../src/logic/NodeList'
|
|
3
|
-
import {
|
|
3
|
+
import { until } from '@streamr/utils'
|
|
4
4
|
import { range } from 'lodash'
|
|
5
5
|
import { expect } from 'expect'
|
|
6
6
|
import { createMockContentDeliveryRpcRemote } from '../utils/utils'
|
|
7
|
-
import { DhtAddress,
|
|
7
|
+
import { DhtAddress, randomDhtAddress, toNodeId } from '@streamr/dht'
|
|
8
8
|
|
|
9
9
|
describe('NeighborFinder', () => {
|
|
10
10
|
|
|
11
|
-
const nodeId =
|
|
11
|
+
const nodeId = randomDhtAddress()
|
|
12
12
|
let neighbors: NodeList
|
|
13
13
|
let nearbyNodeView: NodeList
|
|
14
14
|
let neighborFinder: NeighborFinder
|
|
@@ -24,7 +24,7 @@ describe('NeighborFinder', () => {
|
|
|
24
24
|
if (Math.random() < 0.5) {
|
|
25
25
|
neighbors.add(target!)
|
|
26
26
|
} else {
|
|
27
|
-
excluded.push(
|
|
27
|
+
excluded.push(toNodeId(target!.getPeerDescriptor()))
|
|
28
28
|
}
|
|
29
29
|
return excluded
|
|
30
30
|
}
|
|
@@ -45,7 +45,7 @@ describe('NeighborFinder', () => {
|
|
|
45
45
|
|
|
46
46
|
it('Finds target number of nodes', async () => {
|
|
47
47
|
neighborFinder.start()
|
|
48
|
-
await
|
|
48
|
+
await until(() => neighbors.size() >= minCount, 10000)
|
|
49
49
|
expect(neighborFinder.isRunning()).toEqual(false)
|
|
50
50
|
})
|
|
51
51
|
})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DhtAddress, ListeningRpcCommunicator,
|
|
1
|
+
import { DhtAddress, ListeningRpcCommunicator, toNodeId } from '@streamr/dht'
|
|
2
2
|
import { StreamPartIDUtils } from '@streamr/utils'
|
|
3
3
|
import { range } from 'lodash'
|
|
4
4
|
import { ContentDeliveryRpcRemote } from '../../src/logic/ContentDeliveryRpcRemote'
|
|
5
5
|
import { NodeList } from '../../src/logic/NodeList'
|
|
6
6
|
import { NeighborFinder } from '../../src/logic/neighbor-discovery/NeighborFinder'
|
|
7
7
|
import { NeighborUpdateRpcLocal } from '../../src/logic/neighbor-discovery/NeighborUpdateRpcLocal'
|
|
8
|
-
import { ContentDeliveryRpcClient } from '../../
|
|
8
|
+
import { ContentDeliveryRpcClient } from '../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
9
9
|
import { MockTransport } from '../utils/mock/MockTransport'
|
|
10
10
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
11
11
|
|
|
@@ -35,8 +35,8 @@ describe('NeighborUpdateRpcLocal', () => {
|
|
|
35
35
|
|
|
36
36
|
beforeEach(() => {
|
|
37
37
|
rpcCommunicator = new ListeningRpcCommunicator('mock', new MockTransport())
|
|
38
|
-
neighbors = new NodeList(
|
|
39
|
-
nearbyNodeView = new NodeList(
|
|
38
|
+
neighbors = new NodeList(toNodeId(localPeerDescriptor), neighborTargetCount + 1)
|
|
39
|
+
nearbyNodeView = new NodeList(toNodeId(localPeerDescriptor), neighborTargetCount)
|
|
40
40
|
neighborFinder = {
|
|
41
41
|
start: jest.fn()
|
|
42
42
|
} as any
|
|
@@ -122,12 +122,12 @@ describe('NeighborUpdateRpcLocal', () => {
|
|
|
122
122
|
removeMe: false
|
|
123
123
|
}, { incomingSourceDescriptor: caller } as any)
|
|
124
124
|
expect(res.removeMe).toEqual(true)
|
|
125
|
-
expect(neighbors.has(
|
|
125
|
+
expect(neighbors.has(toNodeId(caller))).toEqual(false)
|
|
126
126
|
})
|
|
127
127
|
|
|
128
128
|
it('does not ask to be removed if there is an ongoing handshake to the caller', async () => {
|
|
129
129
|
const caller = createMockPeerDescriptor()
|
|
130
|
-
ongoingHandshakes.add(
|
|
130
|
+
ongoingHandshakes.add(toNodeId(caller))
|
|
131
131
|
const res = await rpcLocal.neighborUpdate({
|
|
132
132
|
streamPartId,
|
|
133
133
|
neighborDescriptors: [localPeerDescriptor],
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { randomEthereumAddress } from '@streamr/test-utils'
|
|
2
1
|
import { StreamPartIDUtils } from '@streamr/utils'
|
|
3
2
|
import { EventEmitter } from 'eventemitter3'
|
|
4
3
|
import { NetworkNode } from '../../src/NetworkNode'
|
|
5
4
|
import { NetworkStack } from '../../src/NetworkStack'
|
|
6
5
|
import { Events } from '../../src/logic/ContentDeliveryManager'
|
|
7
|
-
import { StreamMessage } from '../../
|
|
6
|
+
import { StreamMessage } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
8
7
|
import { createStreamMessage } from '../utils/utils'
|
|
8
|
+
import { randomUserId } from '@streamr/test-utils'
|
|
9
9
|
|
|
10
10
|
const STREAM_PART = StreamPartIDUtils.parse('stream#0')
|
|
11
|
-
const PUBLISHER_ID =
|
|
11
|
+
const PUBLISHER_ID = randomUserId()
|
|
12
12
|
|
|
13
13
|
const createMessage = (id: number): StreamMessage => {
|
|
14
14
|
return createStreamMessage(`${id}`, STREAM_PART, PUBLISHER_ID)
|
|
@@ -33,10 +33,10 @@ describe('NetworkNode', () => {
|
|
|
33
33
|
contentDeliveryManager.emit('newMessage', msg2)
|
|
34
34
|
expect(onMessage.mock.calls[0][0]).toEqual(msg1)
|
|
35
35
|
expect(onMessage.mock.calls[1][0]).toEqual(msg2)
|
|
36
|
-
expect(onMessage).
|
|
36
|
+
expect(onMessage).toHaveBeenCalledTimes(2)
|
|
37
37
|
|
|
38
38
|
node.removeMessageListener(onMessage)
|
|
39
39
|
contentDeliveryManager.emit('newMessage', createMessage(3))
|
|
40
|
-
expect(onMessage).
|
|
40
|
+
expect(onMessage).toHaveBeenCalledTimes(2)
|
|
41
41
|
})
|
|
42
42
|
})
|