@streamr/trackerless-network 102.0.0-beta.0 → 102.0.0-beta.2
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/generated/google/protobuf/any.js.map +1 -0
- package/dist/generated/google/protobuf/empty.js.map +1 -0
- 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 +3 -3
- package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.js +1 -1
- 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 +9 -10
- package/dist/src/NetworkNode.d.ts +4 -3
- package/dist/src/NetworkNode.js.map +1 -1
- package/dist/src/NetworkStack.d.ts +2 -2
- package/dist/src/NetworkStack.js +4 -4
- 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 +2 -1
- package/dist/src/logic/ContentDeliveryLayerNode.js +5 -5
- package/dist/src/logic/ContentDeliveryLayerNode.js.map +1 -1
- package/dist/src/logic/ContentDeliveryManager.d.ts +2 -1
- package/dist/src/logic/ContentDeliveryManager.js +2 -1
- package/dist/src/logic/ContentDeliveryManager.js.map +1 -1
- package/dist/src/logic/ContentDeliveryRpcLocal.d.ts +3 -3
- package/dist/src/logic/ContentDeliveryRpcLocal.js +1 -1
- package/dist/src/logic/ContentDeliveryRpcLocal.js.map +1 -1
- package/dist/src/logic/ContentDeliveryRpcRemote.d.ts +2 -2
- package/dist/src/logic/ControlLayerNode.d.ts +1 -1
- package/dist/src/logic/DiscoveryLayerNode.d.ts +3 -3
- package/dist/src/logic/DuplicateMessageDetector.js +1 -1
- package/dist/src/logic/DuplicateMessageDetector.js.map +1 -1
- package/dist/src/logic/PeerDescriptorStoreManager.d.ts +1 -1
- package/dist/src/logic/PeerDescriptorStoreManager.js +1 -1
- package/dist/src/logic/PeerDescriptorStoreManager.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 +1 -1
- 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/HandshakeRpcRemote.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/Handshaker.js +2 -2
- package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +2 -2
- 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 +1 -1
- 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/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/PropagationTaskStore.d.ts +1 -1
- package/dist/src/logic/proxy/ProxyClient.d.ts +1 -2
- package/dist/src/logic/proxy/ProxyClient.js +2 -3
- package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.d.ts +2 -2
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js +4 -4
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.d.ts +2 -2
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.js +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.d.ts +4 -4
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +1 -1
- 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/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 +2 -2
- 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 +5 -4
- package/dist/test/utils/utils.js.map +1 -1
- package/jest.config.ts +13 -0
- package/package.json +9 -10
- package/proto.sh +2 -2
- package/protos/NetworkRpc.proto +2 -3
- 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 -8
- package/src/NetworkNode.ts +0 -141
- package/src/NetworkStack.ts +0 -198
- package/src/exports.ts +0 -16
- package/src/logic/ContentDeliveryLayerNode.ts +0 -424
- package/src/logic/ContentDeliveryManager.ts +0 -399
- package/src/logic/ContentDeliveryRpcLocal.ts +0 -48
- package/src/logic/ContentDeliveryRpcRemote.ts +0 -44
- package/src/logic/ControlLayerNode.ts +0 -17
- package/src/logic/DiscoveryLayerNode.ts +0 -30
- package/src/logic/DuplicateMessageDetector.ts +0 -167
- package/src/logic/ExternalNetworkRpc.ts +0 -42
- package/src/logic/NodeList.ts +0 -114
- package/src/logic/PeerDescriptorStoreManager.ts +0 -96
- package/src/logic/StreamPartNetworkSplitAvoidance.ts +0 -90
- package/src/logic/StreamPartReconnect.ts +0 -38
- package/src/logic/createContentDeliveryLayerNode.ts +0 -130
- package/src/logic/formStreamPartDeliveryServiceId.ts +0 -7
- package/src/logic/inspect/InspectSession.ts +0 -54
- package/src/logic/inspect/Inspector.ts +0 -100
- package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +0 -138
- package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +0 -66
- package/src/logic/neighbor-discovery/Handshaker.ts +0 -215
- package/src/logic/neighbor-discovery/NeighborFinder.ts +0 -77
- package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +0 -69
- package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +0 -75
- package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +0 -35
- package/src/logic/node-info/NodeInfoClient.ts +0 -23
- package/src/logic/node-info/NodeInfoRpcLocal.ts +0 -28
- package/src/logic/node-info/NodeInfoRpcRemote.ts +0 -11
- package/src/logic/propagation/FifoMapWithTTL.ts +0 -116
- package/src/logic/propagation/Propagation.ts +0 -84
- package/src/logic/propagation/PropagationTaskStore.ts +0 -41
- package/src/logic/proxy/ProxyClient.ts +0 -287
- package/src/logic/proxy/ProxyConnectionRpcLocal.ts +0 -106
- package/src/logic/proxy/ProxyConnectionRpcRemote.ts +0 -26
- package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +0 -73
- package/src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts +0 -29
- package/src/logic/utils.ts +0 -18
- package/src/proto/google/protobuf/any.ts +0 -326
- package/src/proto/google/protobuf/empty.ts +0 -81
- package/src/proto/google/protobuf/timestamp.ts +0 -287
- 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 -783
- package/test/benchmark/StreamPartIdDataKeyDistribution.test.ts +0 -60
- package/test/benchmark/first-message.ts +0 -169
- package/test/end-to-end/content-delivery-layer-node-with-real-connections.test.ts +0 -160
- package/test/end-to-end/external-network-rpc.test.ts +0 -67
- package/test/end-to-end/inspect.test.ts +0 -124
- package/test/end-to-end/proxy-and-full-node.test.ts +0 -143
- package/test/end-to-end/proxy-connections.test.ts +0 -228
- package/test/end-to-end/proxy-key-exchange.test.ts +0 -126
- package/test/end-to-end/webrtc-full-node-network.test.ts +0 -85
- package/test/end-to-end/websocket-full-node-network.test.ts +0 -84
- package/test/integration/ContentDeliveryLayerNode-Layer1Node-Latencies.test.ts +0 -139
- package/test/integration/ContentDeliveryLayerNode-Layer1Node.test.ts +0 -162
- package/test/integration/ContentDeliveryManager.test.ts +0 -157
- package/test/integration/ContentDeliveryRpcRemote.test.ts +0 -100
- package/test/integration/HandshakeRpcRemote.test.ts +0 -79
- package/test/integration/Handshakes.test.ts +0 -176
- package/test/integration/Inspect.test.ts +0 -89
- package/test/integration/NeighborUpdateRpcRemote.test.ts +0 -82
- package/test/integration/NetworkNode.test.ts +0 -115
- package/test/integration/NetworkRpc.test.ts +0 -52
- package/test/integration/NetworkStack.test.ts +0 -72
- package/test/integration/NodeInfoRpc.test.ts +0 -109
- package/test/integration/Propagation.test.ts +0 -76
- package/test/integration/joining-streams-on-offline-peers.test.ts +0 -82
- package/test/integration/stream-without-default-entrypoints.test.ts +0 -128
- package/test/integration/streamEntryPointReplacing.test.ts +0 -97
- package/test/types/global.d.ts +0 -2
- package/test/unit/ContentDeliveryLayerNode.test.ts +0 -112
- package/test/unit/ContentDeliveryManager.test.ts +0 -95
- package/test/unit/ContentDeliveryRpcLocal.test.ts +0 -60
- package/test/unit/DuplicateMessageDetector.test.ts +0 -192
- package/test/unit/ExternalNetworkRpc.test.ts +0 -48
- package/test/unit/FifoMapWithTtl.test.ts +0 -253
- package/test/unit/HandshakeRpcLocal.test.ts +0 -168
- package/test/unit/Handshaker.test.ts +0 -69
- package/test/unit/InspectSession.test.ts +0 -80
- package/test/unit/Inspector.test.ts +0 -51
- package/test/unit/NeighborFinder.test.ts +0 -51
- package/test/unit/NeighborUpdateRpcLocal.test.ts +0 -139
- package/test/unit/NetworkNode.test.ts +0 -42
- package/test/unit/NodeList.test.ts +0 -164
- package/test/unit/NumberPair.test.ts +0 -22
- package/test/unit/PeerDescriptorStoreManager.test.ts +0 -103
- package/test/unit/Propagation.test.ts +0 -151
- package/test/unit/ProxyConnectionRpcRemote.test.ts +0 -39
- package/test/unit/StreamPartIDDataKey.test.ts +0 -12
- package/test/unit/StreamPartNetworkSplitAvoidance.test.ts +0 -31
- package/test/unit/StreamPartReconnect.test.ts +0 -30
- package/test/unit/TemporaryConnectionRpcLocal.test.ts +0 -38
- package/test/utils/fake/FakePeerDescriptorStoreManager.ts +0 -29
- package/test/utils/mock/MockConnectionsView.ts +0 -18
- package/test/utils/mock/MockControlLayerNode.ts +0 -78
- package/test/utils/mock/MockDiscoveryLayerNode.ts +0 -60
- package/test/utils/mock/MockHandshaker.ts +0 -17
- package/test/utils/mock/MockNeighborFinder.ts +0 -20
- package/test/utils/mock/MockNeighborUpdateManager.ts +0 -21
- package/test/utils/mock/MockTransport.ts +0 -30
- package/test/utils/utils.ts +0 -143
- package/tsconfig.browser.json +0 -12
- package/tsconfig.jest.json +0 -16
- package/tsconfig.json +0 -3
- package/tsconfig.node.json +0 -16
- /package/dist/{src/proto → generated}/google/protobuf/any.d.ts +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/any.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/empty.d.ts +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/empty.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/timestamp.d.ts +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,143 +0,0 @@
|
|
|
1
|
-
import { randomUserId } from '@streamr/test-utils'
|
|
2
|
-
import { StreamPartID, StreamPartIDUtils, hexToBinary, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
|
|
3
|
-
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
4
|
-
import {
|
|
5
|
-
ContentType,
|
|
6
|
-
EncryptionType,
|
|
7
|
-
ProxyDirection,
|
|
8
|
-
SignatureType,
|
|
9
|
-
StreamMessage
|
|
10
|
-
} from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
11
|
-
import { createMockPeerDescriptor } from '../utils/utils'
|
|
12
|
-
|
|
13
|
-
const PROXIED_NODE_USER_ID = randomUserId()
|
|
14
|
-
|
|
15
|
-
const createMessage = (streamPartId: StreamPartID): StreamMessage => {
|
|
16
|
-
return {
|
|
17
|
-
messageId: {
|
|
18
|
-
streamId: StreamPartIDUtils.getStreamID(streamPartId),
|
|
19
|
-
streamPartition: StreamPartIDUtils.getStreamPartition(streamPartId),
|
|
20
|
-
timestamp: 666,
|
|
21
|
-
sequenceNumber: 0,
|
|
22
|
-
publisherId: hexToBinary(randomUserId()),
|
|
23
|
-
messageChainId: 'msgChainId'
|
|
24
|
-
},
|
|
25
|
-
previousMessageRef: {
|
|
26
|
-
timestamp: 665,
|
|
27
|
-
sequenceNumber: 0
|
|
28
|
-
},
|
|
29
|
-
body: {
|
|
30
|
-
oneofKind: 'contentMessage',
|
|
31
|
-
contentMessage: {
|
|
32
|
-
content: utf8ToBinary(JSON.stringify({
|
|
33
|
-
hello: 'world'
|
|
34
|
-
})),
|
|
35
|
-
contentType: ContentType.JSON,
|
|
36
|
-
encryptionType: EncryptionType.NONE,
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
signatureType: SignatureType.SECP256K1,
|
|
40
|
-
signature: hexToBinary('0x1234'),
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
describe('proxy and full node', () => {
|
|
45
|
-
|
|
46
|
-
const proxyNodeDescriptor = createMockPeerDescriptor({
|
|
47
|
-
websocket: { host: '127.0.0.1', port: 23135, tls: false }
|
|
48
|
-
})
|
|
49
|
-
const proxiedNodeDescriptor = createMockPeerDescriptor()
|
|
50
|
-
const proxiedStreamPart = StreamPartIDUtils.parse('proxy-stream#0')
|
|
51
|
-
const regularStreamPart1 = StreamPartIDUtils.parse('regular-stream1#0')
|
|
52
|
-
const regularStreamPart2 = StreamPartIDUtils.parse('regular-stream2#0')
|
|
53
|
-
const regularStreamPart3 = StreamPartIDUtils.parse('regular-stream3#0')
|
|
54
|
-
const regularStreamPart4 = StreamPartIDUtils.parse('regular-stream4#0')
|
|
55
|
-
let proxyNode: NetworkNode
|
|
56
|
-
let proxiedNode: NetworkNode
|
|
57
|
-
|
|
58
|
-
beforeEach(async () => {
|
|
59
|
-
proxyNode = createNetworkNode({
|
|
60
|
-
layer0: {
|
|
61
|
-
entryPoints: [proxyNodeDescriptor],
|
|
62
|
-
peerDescriptor: proxyNodeDescriptor,
|
|
63
|
-
websocketServerEnableTls: false
|
|
64
|
-
},
|
|
65
|
-
networkNode: {
|
|
66
|
-
acceptProxyConnections: true
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
await proxyNode.start()
|
|
70
|
-
proxyNode.stack.getContentDeliveryManager().joinStreamPart(proxiedStreamPart)
|
|
71
|
-
proxyNode.stack.getContentDeliveryManager().joinStreamPart(regularStreamPart1)
|
|
72
|
-
proxyNode.stack.getContentDeliveryManager().joinStreamPart(regularStreamPart2)
|
|
73
|
-
proxyNode.stack.getContentDeliveryManager().joinStreamPart(regularStreamPart3)
|
|
74
|
-
proxyNode.stack.getContentDeliveryManager().joinStreamPart(regularStreamPart4)
|
|
75
|
-
|
|
76
|
-
proxiedNode = createNetworkNode({
|
|
77
|
-
layer0: {
|
|
78
|
-
entryPoints: [proxyNodeDescriptor],
|
|
79
|
-
peerDescriptor: proxiedNodeDescriptor,
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
await proxiedNode.start(false)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
afterEach(async () => {
|
|
86
|
-
await proxyNode.stop()
|
|
87
|
-
await proxiedNode.stop()
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
it('proxied node can act as full node on another stream part', async () => {
|
|
91
|
-
await proxiedNode.setProxies(proxiedStreamPart, [proxyNodeDescriptor], ProxyDirection.PUBLISH, PROXIED_NODE_USER_ID, 1)
|
|
92
|
-
expect(proxiedNode.stack.getControlLayerNode().hasJoined()).toBe(false)
|
|
93
|
-
|
|
94
|
-
await Promise.all([
|
|
95
|
-
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage'),
|
|
96
|
-
proxiedNode.broadcast(createMessage(regularStreamPart1))
|
|
97
|
-
])
|
|
98
|
-
|
|
99
|
-
expect(proxiedNode.stack.getControlLayerNode().hasJoined()).toBe(true)
|
|
100
|
-
|
|
101
|
-
await Promise.all([
|
|
102
|
-
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage'),
|
|
103
|
-
proxiedNode.broadcast(createMessage(proxiedStreamPart))
|
|
104
|
-
])
|
|
105
|
-
|
|
106
|
-
expect(proxiedNode.stack.getContentDeliveryManager().getStreamPartDelivery(proxiedStreamPart)!.proxied).toBe(true)
|
|
107
|
-
expect(proxiedNode.stack.getContentDeliveryManager().getStreamPartDelivery(regularStreamPart1)!.proxied).toBe(false)
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
it('proxied node can act as full node on multiple stream parts', async () => {
|
|
111
|
-
await proxiedNode.setProxies(proxiedStreamPart, [proxyNodeDescriptor], ProxyDirection.PUBLISH, PROXIED_NODE_USER_ID, 1)
|
|
112
|
-
expect(proxiedNode.stack.getControlLayerNode().hasJoined()).toBe(false)
|
|
113
|
-
|
|
114
|
-
await Promise.all([
|
|
115
|
-
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
|
|
116
|
-
(streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart1)),
|
|
117
|
-
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
|
|
118
|
-
(streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart2)),
|
|
119
|
-
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
|
|
120
|
-
(streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart3)),
|
|
121
|
-
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
|
|
122
|
-
(streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart4)),
|
|
123
|
-
proxiedNode.broadcast(createMessage(regularStreamPart1)),
|
|
124
|
-
proxiedNode.broadcast(createMessage(regularStreamPart2)),
|
|
125
|
-
proxiedNode.broadcast(createMessage(regularStreamPart3)),
|
|
126
|
-
proxiedNode.broadcast(createMessage(regularStreamPart4))
|
|
127
|
-
])
|
|
128
|
-
|
|
129
|
-
expect(proxiedNode.stack.getControlLayerNode().hasJoined()).toBe(true)
|
|
130
|
-
|
|
131
|
-
await Promise.all([
|
|
132
|
-
waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage'),
|
|
133
|
-
proxiedNode.broadcast(createMessage(proxiedStreamPart))
|
|
134
|
-
])
|
|
135
|
-
|
|
136
|
-
expect(proxiedNode.stack.getContentDeliveryManager().getStreamPartDelivery(proxiedStreamPart)!.proxied).toBe(true)
|
|
137
|
-
expect(proxiedNode.stack.getContentDeliveryManager().getStreamPartDelivery(regularStreamPart1)!.proxied).toBe(false)
|
|
138
|
-
expect(proxiedNode.stack.getContentDeliveryManager().getStreamPartDelivery(regularStreamPart2)!.proxied).toBe(false)
|
|
139
|
-
expect(proxiedNode.stack.getContentDeliveryManager().getStreamPartDelivery(regularStreamPart3)!.proxied).toBe(false)
|
|
140
|
-
expect(proxiedNode.stack.getContentDeliveryManager().getStreamPartDelivery(regularStreamPart4)!.proxied).toBe(false)
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
})
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { DhtAddress } from '@streamr/dht'
|
|
2
|
-
import { randomUserId } from '@streamr/test-utils'
|
|
3
|
-
import { StreamPartIDUtils, hexToBinary, utf8ToBinary, wait, waitForCondition, waitForEvent3 } from '@streamr/utils'
|
|
4
|
-
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
5
|
-
import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
|
|
6
|
-
import { ProxyClient } from '../../src/logic/proxy/ProxyClient'
|
|
7
|
-
import {
|
|
8
|
-
ContentType,
|
|
9
|
-
EncryptionType,
|
|
10
|
-
ProxyDirection,
|
|
11
|
-
SignatureType,
|
|
12
|
-
StreamMessage
|
|
13
|
-
} from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
14
|
-
import { createMockPeerDescriptor } from '../utils/utils'
|
|
15
|
-
|
|
16
|
-
const PROXIED_NODE_USER_ID = randomUserId()
|
|
17
|
-
const STREAM_PART_ID = StreamPartIDUtils.parse('proxy-test#0')
|
|
18
|
-
const MESSAGE: StreamMessage = {
|
|
19
|
-
messageId: {
|
|
20
|
-
streamId: StreamPartIDUtils.getStreamID(STREAM_PART_ID),
|
|
21
|
-
streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
22
|
-
timestamp: 666,
|
|
23
|
-
sequenceNumber: 0,
|
|
24
|
-
publisherId: hexToBinary(randomUserId()),
|
|
25
|
-
messageChainId: 'msgChainId'
|
|
26
|
-
},
|
|
27
|
-
previousMessageRef: {
|
|
28
|
-
timestamp: 665,
|
|
29
|
-
sequenceNumber: 0
|
|
30
|
-
},
|
|
31
|
-
body: {
|
|
32
|
-
oneofKind: 'contentMessage',
|
|
33
|
-
contentMessage: {
|
|
34
|
-
content: utf8ToBinary(JSON.stringify({
|
|
35
|
-
hello: 'world'
|
|
36
|
-
})),
|
|
37
|
-
contentType: ContentType.JSON,
|
|
38
|
-
encryptionType: EncryptionType.NONE,
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
signatureType: SignatureType.SECP256K1,
|
|
42
|
-
signature: hexToBinary('0x1234')
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
describe('Proxy connections', () => {
|
|
46
|
-
|
|
47
|
-
let proxyNode1: NetworkNode
|
|
48
|
-
let proxyNode2: NetworkNode
|
|
49
|
-
let proxiedNode: NetworkNode
|
|
50
|
-
|
|
51
|
-
const hasConnectionFromProxy = (proxyNode: NetworkNode): boolean => {
|
|
52
|
-
const delivery = proxyNode.stack.getContentDeliveryManager().getStreamPartDelivery(STREAM_PART_ID)
|
|
53
|
-
return (delivery !== undefined)
|
|
54
|
-
? ((delivery as { node: ContentDeliveryLayerNode }).node).hasProxyConnection(proxiedNode.getNodeId())
|
|
55
|
-
: false
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const hasConnectionToProxy = (proxyNodeId: DhtAddress, direction: ProxyDirection): boolean => {
|
|
59
|
-
const client = (proxiedNode.stack.getContentDeliveryManager().getStreamPartDelivery(STREAM_PART_ID) as { client: ProxyClient }).client
|
|
60
|
-
return client.hasConnection(proxyNodeId, direction)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
beforeEach(async () => {
|
|
64
|
-
const proxyNodeDescriptor1 = createMockPeerDescriptor({
|
|
65
|
-
websocket: { host: '127.0.0.1', port: 23132, tls: false }
|
|
66
|
-
})
|
|
67
|
-
const proxyNodeDescriptor2 = createMockPeerDescriptor({
|
|
68
|
-
websocket: { host: '127.0.0.1', port: 23133, tls: false }
|
|
69
|
-
})
|
|
70
|
-
const proxiedNodeDescriptor = createMockPeerDescriptor()
|
|
71
|
-
proxyNode1 = createNetworkNode({
|
|
72
|
-
layer0: {
|
|
73
|
-
entryPoints: [proxyNodeDescriptor1],
|
|
74
|
-
peerDescriptor: proxyNodeDescriptor1,
|
|
75
|
-
websocketServerEnableTls: false
|
|
76
|
-
},
|
|
77
|
-
networkNode: {
|
|
78
|
-
acceptProxyConnections: true
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
await proxyNode1.start()
|
|
82
|
-
proxyNode1.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor1])
|
|
83
|
-
proxyNode1.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
84
|
-
proxyNode2 = createNetworkNode({
|
|
85
|
-
layer0: {
|
|
86
|
-
entryPoints: [proxyNodeDescriptor1],
|
|
87
|
-
peerDescriptor: proxyNodeDescriptor2,
|
|
88
|
-
websocketServerEnableTls: false
|
|
89
|
-
},
|
|
90
|
-
networkNode: {
|
|
91
|
-
acceptProxyConnections: true
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
await proxyNode2.start()
|
|
95
|
-
proxyNode2.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor1])
|
|
96
|
-
proxyNode2.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
97
|
-
proxiedNode = createNetworkNode({
|
|
98
|
-
layer0: {
|
|
99
|
-
entryPoints: [proxyNode1.getPeerDescriptor()],
|
|
100
|
-
peerDescriptor: proxiedNodeDescriptor,
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
await proxiedNode.start(false)
|
|
104
|
-
}, 30000)
|
|
105
|
-
|
|
106
|
-
afterEach(async () => {
|
|
107
|
-
await proxyNode1.stop()
|
|
108
|
-
await proxyNode2.stop()
|
|
109
|
-
await proxiedNode.stop()
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
it('happy path publishing', async () => {
|
|
113
|
-
await proxiedNode.setProxies(STREAM_PART_ID, [proxyNode1.getPeerDescriptor()], ProxyDirection.PUBLISH, PROXIED_NODE_USER_ID, 1)
|
|
114
|
-
await Promise.all([
|
|
115
|
-
waitForEvent3(proxyNode1.stack.getContentDeliveryManager() as any, 'newMessage'),
|
|
116
|
-
proxiedNode.broadcast(MESSAGE)
|
|
117
|
-
])
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
it('happy path subscribing', async () => {
|
|
121
|
-
await proxiedNode.setProxies(STREAM_PART_ID, [proxyNode1.getPeerDescriptor()], ProxyDirection.SUBSCRIBE, PROXIED_NODE_USER_ID, 1)
|
|
122
|
-
await Promise.all([
|
|
123
|
-
waitForEvent3(proxiedNode.stack.getContentDeliveryManager() as any, 'newMessage'),
|
|
124
|
-
proxyNode1.broadcast(MESSAGE)
|
|
125
|
-
])
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('can leave proxy publish connection', async () => {
|
|
129
|
-
await proxiedNode.setProxies(STREAM_PART_ID, [proxyNode1.getPeerDescriptor()], ProxyDirection.PUBLISH, PROXIED_NODE_USER_ID, 1)
|
|
130
|
-
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(true)
|
|
131
|
-
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
132
|
-
await proxiedNode.setProxies(STREAM_PART_ID, [], ProxyDirection.PUBLISH, PROXIED_NODE_USER_ID, 0)
|
|
133
|
-
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(false)
|
|
134
|
-
await waitForCondition(() => hasConnectionFromProxy(proxyNode1) === false)
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
it('can leave proxy subscribe connection', async () => {
|
|
138
|
-
await proxiedNode.setProxies(STREAM_PART_ID, [proxyNode1.getPeerDescriptor()], ProxyDirection.SUBSCRIBE, PROXIED_NODE_USER_ID, 1)
|
|
139
|
-
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(true)
|
|
140
|
-
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
141
|
-
await proxiedNode.setProxies(STREAM_PART_ID, [], ProxyDirection.SUBSCRIBE, PROXIED_NODE_USER_ID, 0)
|
|
142
|
-
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(false)
|
|
143
|
-
await waitForCondition(() => hasConnectionFromProxy(proxyNode1) === false)
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
it('can open multiple proxy connections', async () => {
|
|
147
|
-
await proxiedNode.setProxies(
|
|
148
|
-
STREAM_PART_ID,
|
|
149
|
-
[proxyNode1.getPeerDescriptor(), proxyNode2.getPeerDescriptor()],
|
|
150
|
-
ProxyDirection.SUBSCRIBE,
|
|
151
|
-
PROXIED_NODE_USER_ID
|
|
152
|
-
)
|
|
153
|
-
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(true)
|
|
154
|
-
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
155
|
-
expect(hasConnectionFromProxy(proxyNode2)).toBe(true)
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
it('can open multiple proxy connections and close one', async () => {
|
|
159
|
-
await proxiedNode.setProxies(
|
|
160
|
-
STREAM_PART_ID,
|
|
161
|
-
[proxyNode1.getPeerDescriptor(), proxyNode2.getPeerDescriptor()],
|
|
162
|
-
ProxyDirection.SUBSCRIBE,
|
|
163
|
-
PROXIED_NODE_USER_ID
|
|
164
|
-
)
|
|
165
|
-
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(true)
|
|
166
|
-
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
167
|
-
expect(hasConnectionFromProxy(proxyNode2)).toBe(true)
|
|
168
|
-
await proxiedNode.setProxies(STREAM_PART_ID, [proxyNode1.getPeerDescriptor()], ProxyDirection.SUBSCRIBE, PROXIED_NODE_USER_ID)
|
|
169
|
-
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(true)
|
|
170
|
-
await waitForCondition(() => hasConnectionFromProxy(proxyNode2) === false)
|
|
171
|
-
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
it('can open and close all connections', async () => {
|
|
175
|
-
await proxiedNode.setProxies(
|
|
176
|
-
STREAM_PART_ID,
|
|
177
|
-
[proxyNode1.getPeerDescriptor(), proxyNode2.getPeerDescriptor()],
|
|
178
|
-
ProxyDirection.SUBSCRIBE,
|
|
179
|
-
PROXIED_NODE_USER_ID
|
|
180
|
-
)
|
|
181
|
-
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(true)
|
|
182
|
-
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
183
|
-
expect(hasConnectionFromProxy(proxyNode2)).toBe(true)
|
|
184
|
-
|
|
185
|
-
await proxiedNode.setProxies(STREAM_PART_ID, [], ProxyDirection.SUBSCRIBE, PROXIED_NODE_USER_ID)
|
|
186
|
-
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(false)
|
|
187
|
-
await waitForCondition(() => hasConnectionFromProxy(proxyNode1) === false)
|
|
188
|
-
await waitForCondition(() => hasConnectionFromProxy(proxyNode2) === false)
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
it('will reconnect if proxy node goes offline and comes back online', async () => {
|
|
192
|
-
await proxiedNode.setProxies(
|
|
193
|
-
STREAM_PART_ID,
|
|
194
|
-
[proxyNode1.getPeerDescriptor()],
|
|
195
|
-
ProxyDirection.SUBSCRIBE,
|
|
196
|
-
PROXIED_NODE_USER_ID
|
|
197
|
-
)
|
|
198
|
-
expect(proxiedNode.hasStreamPart(STREAM_PART_ID)).toBe(true)
|
|
199
|
-
await proxyNode1.leave(STREAM_PART_ID)
|
|
200
|
-
await waitForCondition(() => hasConnectionToProxy(proxyNode1.getNodeId(), ProxyDirection.SUBSCRIBE))
|
|
201
|
-
expect(hasConnectionFromProxy(proxyNode1)).toBe(false)
|
|
202
|
-
proxyNode1.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
203
|
-
await waitForCondition(() => hasConnectionToProxy(proxyNode1.getNodeId(), ProxyDirection.SUBSCRIBE), 25000)
|
|
204
|
-
// TODO why wait is needed?
|
|
205
|
-
await wait(100)
|
|
206
|
-
expect(hasConnectionFromProxy(proxyNode1)).toBe(true)
|
|
207
|
-
}, 30000)
|
|
208
|
-
|
|
209
|
-
it('can\'t join proxied stream part', async () => {
|
|
210
|
-
await proxiedNode.setProxies(
|
|
211
|
-
STREAM_PART_ID,
|
|
212
|
-
[proxyNode1.getPeerDescriptor()],
|
|
213
|
-
ProxyDirection.PUBLISH,
|
|
214
|
-
PROXIED_NODE_USER_ID
|
|
215
|
-
)
|
|
216
|
-
await expect(proxiedNode.join(STREAM_PART_ID)).rejects.toThrow('Cannot join')
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
it('can\'t broadcast to subscribe-only proxied stream part', async () => {
|
|
220
|
-
await proxiedNode.setProxies(
|
|
221
|
-
STREAM_PART_ID,
|
|
222
|
-
[proxyNode1.getPeerDescriptor()],
|
|
223
|
-
ProxyDirection.SUBSCRIBE,
|
|
224
|
-
PROXIED_NODE_USER_ID
|
|
225
|
-
)
|
|
226
|
-
await expect(proxiedNode.broadcast(MESSAGE)).rejects.toThrow('Cannot broadcast')
|
|
227
|
-
})
|
|
228
|
-
})
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { randomUserId } from '@streamr/test-utils'
|
|
2
|
-
import {
|
|
3
|
-
StreamPartIDUtils,
|
|
4
|
-
hexToBinary,
|
|
5
|
-
waitForEvent3
|
|
6
|
-
} from '@streamr/utils'
|
|
7
|
-
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
8
|
-
import { ProxyDirection, SignatureType, StreamMessage } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
9
|
-
import { createMockPeerDescriptor } from '../utils/utils'
|
|
10
|
-
|
|
11
|
-
const STREAM_PART_ID = StreamPartIDUtils.parse('proxy-test#0')
|
|
12
|
-
|
|
13
|
-
describe('proxy group key exchange', () => {
|
|
14
|
-
const proxyNodeDescriptor = createMockPeerDescriptor({
|
|
15
|
-
websocket: { host: '127.0.0.1', port: 23134, tls: false }
|
|
16
|
-
})
|
|
17
|
-
const publisherDescriptor = createMockPeerDescriptor()
|
|
18
|
-
const subscriberDescriptor = createMockPeerDescriptor()
|
|
19
|
-
|
|
20
|
-
const publisherUserId = randomUserId()
|
|
21
|
-
const subscriberUserId = randomUserId()
|
|
22
|
-
|
|
23
|
-
let proxyNode: NetworkNode
|
|
24
|
-
let publisher: NetworkNode
|
|
25
|
-
let subscriber: NetworkNode
|
|
26
|
-
|
|
27
|
-
beforeEach(async () => {
|
|
28
|
-
proxyNode = createNetworkNode({
|
|
29
|
-
layer0: {
|
|
30
|
-
entryPoints: [proxyNodeDescriptor],
|
|
31
|
-
peerDescriptor: proxyNodeDescriptor,
|
|
32
|
-
websocketServerEnableTls: false
|
|
33
|
-
},
|
|
34
|
-
networkNode: {
|
|
35
|
-
acceptProxyConnections: true
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
await proxyNode.start()
|
|
39
|
-
proxyNode.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor])
|
|
40
|
-
proxyNode.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
41
|
-
publisher = createNetworkNode({
|
|
42
|
-
layer0: {
|
|
43
|
-
entryPoints: [proxyNodeDescriptor],
|
|
44
|
-
peerDescriptor: publisherDescriptor,
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
await publisher.start(false)
|
|
48
|
-
|
|
49
|
-
subscriber = createNetworkNode({
|
|
50
|
-
layer0: {
|
|
51
|
-
entryPoints: [proxyNodeDescriptor],
|
|
52
|
-
peerDescriptor: subscriberDescriptor,
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
await subscriber.start(false)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
afterEach(async () => {
|
|
59
|
-
await proxyNode.stop()
|
|
60
|
-
await publisher.stop()
|
|
61
|
-
await subscriber.stop()
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('happy path request', async () => {
|
|
65
|
-
await publisher.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.PUBLISH, publisherUserId)
|
|
66
|
-
await subscriber.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.SUBSCRIBE, subscriberUserId)
|
|
67
|
-
|
|
68
|
-
const request: StreamMessage = {
|
|
69
|
-
messageId: {
|
|
70
|
-
streamId: StreamPartIDUtils.getStreamID(STREAM_PART_ID),
|
|
71
|
-
streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
72
|
-
timestamp: Date.now(),
|
|
73
|
-
sequenceNumber: 0,
|
|
74
|
-
publisherId: hexToBinary(subscriberUserId),
|
|
75
|
-
messageChainId: '0'
|
|
76
|
-
},
|
|
77
|
-
body: {
|
|
78
|
-
oneofKind: 'groupKeyRequest' as const,
|
|
79
|
-
groupKeyRequest: {
|
|
80
|
-
requestId: 'requestId',
|
|
81
|
-
recipientId: hexToBinary(publisherUserId),
|
|
82
|
-
rsaPublicKey: new Uint8Array(),
|
|
83
|
-
groupKeyIds: ['mock']
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
signatureType: SignatureType.SECP256K1,
|
|
87
|
-
signature: hexToBinary('1234')
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
await Promise.all([
|
|
91
|
-
waitForEvent3(publisher.stack.getContentDeliveryManager() as any, 'newMessage'),
|
|
92
|
-
subscriber.broadcast(request)
|
|
93
|
-
])
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('happy path response', async () => {
|
|
97
|
-
await publisher.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.PUBLISH, publisherUserId)
|
|
98
|
-
await subscriber.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.SUBSCRIBE, subscriberUserId)
|
|
99
|
-
|
|
100
|
-
const response: StreamMessage = {
|
|
101
|
-
messageId: {
|
|
102
|
-
streamId: StreamPartIDUtils.getStreamID(STREAM_PART_ID),
|
|
103
|
-
streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
104
|
-
timestamp: Date.now(),
|
|
105
|
-
sequenceNumber: 0,
|
|
106
|
-
publisherId: hexToBinary(publisherUserId),
|
|
107
|
-
messageChainId: '0'
|
|
108
|
-
},
|
|
109
|
-
body: {
|
|
110
|
-
oneofKind: 'groupKeyResponse' as const,
|
|
111
|
-
groupKeyResponse: {
|
|
112
|
-
requestId: 'requestId',
|
|
113
|
-
recipientId: hexToBinary(publisherUserId),
|
|
114
|
-
groupKeys: []
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
signatureType: SignatureType.SECP256K1,
|
|
118
|
-
signature: hexToBinary('1234')
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
await Promise.all([
|
|
122
|
-
waitForEvent3(subscriber.stack.getContentDeliveryManager() as any, 'newMessage'),
|
|
123
|
-
publisher.broadcast(response)
|
|
124
|
-
])
|
|
125
|
-
})
|
|
126
|
-
})
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { toNodeId, getRandomRegion } from '@streamr/dht'
|
|
2
|
-
import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
|
|
3
|
-
import { range } from 'lodash'
|
|
4
|
-
import { NetworkStack } from '../../src/NetworkStack'
|
|
5
|
-
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
6
|
-
import { randomUserId } from '@streamr/test-utils'
|
|
7
|
-
|
|
8
|
-
describe('Full node network with WebRTC connections', () => {
|
|
9
|
-
|
|
10
|
-
const NUM_OF_NODES = 22
|
|
11
|
-
|
|
12
|
-
const epPeerDescriptor = createMockPeerDescriptor({
|
|
13
|
-
websocket: { host: '127.0.0.1', port: 14444, tls: false },
|
|
14
|
-
region: getRandomRegion()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
const streamPartId = StreamPartIDUtils.parse('webrtc-network#0')
|
|
18
|
-
|
|
19
|
-
let entryPoint: NetworkStack
|
|
20
|
-
|
|
21
|
-
let nodes: NetworkStack[]
|
|
22
|
-
|
|
23
|
-
beforeEach(async () => {
|
|
24
|
-
|
|
25
|
-
nodes = []
|
|
26
|
-
|
|
27
|
-
entryPoint = new NetworkStack({
|
|
28
|
-
layer0: {
|
|
29
|
-
entryPoints: [epPeerDescriptor],
|
|
30
|
-
peerDescriptor: epPeerDescriptor,
|
|
31
|
-
websocketServerEnableTls: false
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
await entryPoint.start()
|
|
35
|
-
entryPoint.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
36
|
-
entryPoint.getContentDeliveryManager().joinStreamPart(streamPartId)
|
|
37
|
-
|
|
38
|
-
await Promise.all(range(NUM_OF_NODES).map(async () => {
|
|
39
|
-
const peerDescriptor = createMockPeerDescriptor()
|
|
40
|
-
const node = new NetworkStack({
|
|
41
|
-
layer0: {
|
|
42
|
-
peerDescriptor,
|
|
43
|
-
entryPoints: [epPeerDescriptor]
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
nodes.push(node)
|
|
47
|
-
await node.start()
|
|
48
|
-
node.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
49
|
-
node.getContentDeliveryManager().joinStreamPart(streamPartId)
|
|
50
|
-
}))
|
|
51
|
-
|
|
52
|
-
}, 90000)
|
|
53
|
-
|
|
54
|
-
afterEach(async () => {
|
|
55
|
-
await Promise.all([
|
|
56
|
-
entryPoint.stop(),
|
|
57
|
-
...nodes.map((node) => node.stop())
|
|
58
|
-
])
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('happy path', async () => {
|
|
62
|
-
await Promise.all(nodes.map((node) =>
|
|
63
|
-
waitForCondition(() => {
|
|
64
|
-
return node.getContentDeliveryManager().getNeighbors(streamPartId).length >= 3
|
|
65
|
-
}
|
|
66
|
-
, 30000)
|
|
67
|
-
))
|
|
68
|
-
let receivedMessageCount = 0
|
|
69
|
-
const successIds: string[] = []
|
|
70
|
-
nodes.forEach((node) => {
|
|
71
|
-
node.getContentDeliveryManager().on('newMessage', () => {
|
|
72
|
-
successIds.push(toNodeId(node.getContentDeliveryManager().getPeerDescriptor()))
|
|
73
|
-
receivedMessageCount += 1
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
const msg = createStreamMessage(
|
|
77
|
-
JSON.stringify({ hello: 'WORLD' }),
|
|
78
|
-
streamPartId,
|
|
79
|
-
randomUserId()
|
|
80
|
-
)
|
|
81
|
-
entryPoint.getContentDeliveryManager().broadcast(msg)
|
|
82
|
-
await waitForCondition(() => receivedMessageCount === NUM_OF_NODES)
|
|
83
|
-
}, 120000)
|
|
84
|
-
|
|
85
|
-
})
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { toNodeId } from '@streamr/dht'
|
|
2
|
-
import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
|
|
3
|
-
import { range } from 'lodash'
|
|
4
|
-
import { NetworkStack } from '../../src/NetworkStack'
|
|
5
|
-
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
6
|
-
import { randomUserId } from '@streamr/test-utils'
|
|
7
|
-
|
|
8
|
-
describe('Full node network with WebSocket connections only', () => {
|
|
9
|
-
|
|
10
|
-
const NUM_OF_NODES = 20
|
|
11
|
-
const epPeerDescriptor = createMockPeerDescriptor({
|
|
12
|
-
websocket: { host: '127.0.0.1', port: 15555, tls: false }
|
|
13
|
-
})
|
|
14
|
-
const streamPartId = StreamPartIDUtils.parse('websocket-network#0')
|
|
15
|
-
|
|
16
|
-
let entryPoint: NetworkStack
|
|
17
|
-
|
|
18
|
-
let nodes: NetworkStack[]
|
|
19
|
-
|
|
20
|
-
beforeEach(async () => {
|
|
21
|
-
|
|
22
|
-
nodes = []
|
|
23
|
-
|
|
24
|
-
entryPoint = new NetworkStack({
|
|
25
|
-
layer0: {
|
|
26
|
-
entryPoints: [epPeerDescriptor],
|
|
27
|
-
peerDescriptor: epPeerDescriptor,
|
|
28
|
-
websocketServerEnableTls: false
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
await entryPoint.start()
|
|
32
|
-
entryPoint.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
33
|
-
entryPoint.getContentDeliveryManager().joinStreamPart(streamPartId)
|
|
34
|
-
|
|
35
|
-
await Promise.all(range(NUM_OF_NODES).map(async (i) => {
|
|
36
|
-
const node = new NetworkStack({
|
|
37
|
-
layer0: {
|
|
38
|
-
entryPoints: [epPeerDescriptor],
|
|
39
|
-
websocketPortRange: { min: 15556 + i, max: 15556 + i },
|
|
40
|
-
numberOfNodesPerKBucket: 4,
|
|
41
|
-
websocketServerEnableTls: false
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
nodes.push(node)
|
|
45
|
-
await node.start()
|
|
46
|
-
node.getContentDeliveryManager().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
47
|
-
node.getContentDeliveryManager().joinStreamPart(streamPartId)
|
|
48
|
-
}))
|
|
49
|
-
|
|
50
|
-
}, 120000)
|
|
51
|
-
|
|
52
|
-
afterEach(async () => {
|
|
53
|
-
await Promise.all([
|
|
54
|
-
entryPoint.stop(),
|
|
55
|
-
...nodes.map((node) => node.stop())
|
|
56
|
-
])
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('happy path', async () => {
|
|
60
|
-
await Promise.all(nodes.map((node) =>
|
|
61
|
-
waitForCondition(() => {
|
|
62
|
-
return node.getContentDeliveryManager().getNeighbors(streamPartId).length >= 4
|
|
63
|
-
}
|
|
64
|
-
, 30000)
|
|
65
|
-
))
|
|
66
|
-
let receivedMessageCount = 0
|
|
67
|
-
const successIds: string[] = []
|
|
68
|
-
nodes.forEach((node) => {
|
|
69
|
-
node.getContentDeliveryManager().on('newMessage', () => {
|
|
70
|
-
successIds.push(toNodeId(node.getContentDeliveryManager().getPeerDescriptor()))
|
|
71
|
-
receivedMessageCount += 1
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
const msg = createStreamMessage(
|
|
76
|
-
JSON.stringify({ hello: 'WORLD' }),
|
|
77
|
-
streamPartId,
|
|
78
|
-
randomUserId()
|
|
79
|
-
)
|
|
80
|
-
entryPoint.getContentDeliveryManager().broadcast(msg)
|
|
81
|
-
await waitForCondition(() => receivedMessageCount === NUM_OF_NODES)
|
|
82
|
-
}, 220000)
|
|
83
|
-
|
|
84
|
-
})
|