@streamr/trackerless-network 101.0.0-beta.1 → 101.0.0-beta.3

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.
Files changed (133) hide show
  1. package/dist/package.json +5 -6
  2. package/dist/src/NetworkNode.d.ts +5 -7
  3. package/dist/src/NetworkNode.js +5 -24
  4. package/dist/src/NetworkNode.js.map +1 -1
  5. package/dist/src/NetworkStack.d.ts +1 -2
  6. package/dist/src/NetworkStack.js +1 -2
  7. package/dist/src/NetworkStack.js.map +1 -1
  8. package/dist/src/exports.d.ts +3 -5
  9. package/dist/src/exports.js +13 -13
  10. package/dist/src/exports.js.map +1 -1
  11. package/dist/src/logic/ContentDeliveryLayerNode.d.ts +5 -5
  12. package/dist/src/logic/ContentDeliveryLayerNode.js +3 -3
  13. package/dist/src/logic/ContentDeliveryLayerNode.js.map +1 -1
  14. package/dist/src/logic/ContentDeliveryManager.d.ts +1 -2
  15. package/dist/src/logic/ContentDeliveryManager.js +2 -3
  16. package/dist/src/logic/ContentDeliveryManager.js.map +1 -1
  17. package/dist/src/logic/ContentDeliveryRpcLocal.d.ts +3 -3
  18. package/dist/src/logic/ContentDeliveryRpcLocal.js.map +1 -1
  19. package/dist/src/logic/ContentDeliveryRpcRemote.d.ts +1 -1
  20. package/dist/src/logic/ContentDeliveryRpcRemote.js.map +1 -1
  21. package/dist/src/logic/createContentDeliveryLayerNode.d.ts +1 -1
  22. package/dist/src/logic/formStreamPartDeliveryServiceId.d.ts +1 -1
  23. package/dist/src/logic/inspect/Inspector.d.ts +2 -2
  24. package/dist/src/logic/inspect/Inspector.js +2 -2
  25. package/dist/src/logic/inspect/Inspector.js.map +1 -1
  26. package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.d.ts +4 -4
  27. package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -1
  28. package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.d.ts +1 -1
  29. package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -1
  30. package/dist/src/logic/neighbor-discovery/Handshaker.d.ts +2 -2
  31. package/dist/src/logic/neighbor-discovery/Handshaker.js +4 -4
  32. package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
  33. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.d.ts +2 -2
  34. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +3 -3
  35. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
  36. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.d.ts +1 -1
  37. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +1 -1
  38. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.d.ts +1 -1
  39. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js.map +1 -1
  40. package/dist/src/logic/proxy/ProxyClient.d.ts +1 -2
  41. package/dist/src/logic/proxy/ProxyClient.js +3 -3
  42. package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
  43. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.d.ts +3 -4
  44. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js +4 -4
  45. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -1
  46. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.d.ts +4 -4
  47. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +1 -1
  48. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +1 -1
  49. package/dist/test/benchmark/first-message.js +23 -12
  50. package/dist/test/benchmark/first-message.js.map +1 -1
  51. package/dist/test/utils/utils.d.ts +4 -5
  52. package/dist/test/utils/utils.js +6 -7
  53. package/dist/test/utils/utils.js.map +1 -1
  54. package/package.json +5 -6
  55. package/src/NetworkNode.ts +7 -25
  56. package/src/NetworkStack.ts +1 -2
  57. package/src/exports.ts +14 -11
  58. package/src/logic/ContentDeliveryLayerNode.ts +28 -29
  59. package/src/logic/ContentDeliveryManager.ts +1 -2
  60. package/src/logic/ContentDeliveryRpcLocal.ts +3 -3
  61. package/src/logic/ContentDeliveryRpcRemote.ts +1 -2
  62. package/src/logic/createContentDeliveryLayerNode.ts +1 -1
  63. package/src/logic/formStreamPartDeliveryServiceId.ts +1 -1
  64. package/src/logic/inspect/Inspector.ts +3 -4
  65. package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +9 -10
  66. package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +1 -2
  67. package/src/logic/neighbor-discovery/Handshaker.ts +8 -9
  68. package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +4 -5
  69. package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +2 -2
  70. package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +1 -2
  71. package/src/logic/proxy/ProxyClient.ts +6 -7
  72. package/src/logic/proxy/ProxyConnectionRpcLocal.ts +5 -6
  73. package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +7 -7
  74. package/test/benchmark/StreamPartIdDataKeyDistribution.test.ts +2 -2
  75. package/test/benchmark/first-message.ts +28 -29
  76. package/test/end-to-end/content-delivery-layer-node-with-real-connections.test.ts +4 -5
  77. package/test/end-to-end/inspect.test.ts +26 -28
  78. package/test/end-to-end/proxy-and-full-node.test.ts +34 -32
  79. package/test/end-to-end/proxy-connections.test.ts +34 -31
  80. package/test/end-to-end/proxy-key-exchange.test.ts +41 -57
  81. package/test/end-to-end/webrtc-full-node-network.test.ts +1 -2
  82. package/test/end-to-end/websocket-full-node-network.test.ts +2 -3
  83. package/test/integration/ContentDeliveryLayerNode-Layer1Node-Latencies.test.ts +2 -3
  84. package/test/integration/ContentDeliveryLayerNode-Layer1Node.test.ts +2 -3
  85. package/test/integration/ContentDeliveryManager.test.ts +3 -4
  86. package/test/integration/ContentDeliveryRpcRemote.test.ts +7 -8
  87. package/test/integration/HandshakeRpcRemote.test.ts +6 -6
  88. package/test/integration/Handshakes.test.ts +6 -6
  89. package/test/integration/Inspect.test.ts +1 -1
  90. package/test/integration/NeighborUpdateRpcRemote.test.ts +1 -1
  91. package/test/integration/NetworkNode.test.ts +28 -29
  92. package/test/integration/NetworkRpc.test.ts +7 -8
  93. package/test/integration/NetworkStack.test.ts +4 -4
  94. package/test/integration/NodeInfoRpc.test.ts +3 -4
  95. package/test/integration/Propagation.test.ts +2 -3
  96. package/test/integration/joining-streams-on-offline-peers.test.ts +3 -4
  97. package/test/integration/stream-without-default-entrypoints.test.ts +26 -28
  98. package/test/integration/streamEntryPointReplacing.test.ts +5 -6
  99. package/test/unit/ContentDeliveryLayerNode.test.ts +5 -6
  100. package/test/unit/ContentDeliveryManager.test.ts +2 -3
  101. package/test/unit/ContentDeliveryRpcLocal.test.ts +1 -1
  102. package/test/unit/HandshakeRpcLocal.test.ts +2 -2
  103. package/test/unit/Handshaker.test.ts +2 -2
  104. package/test/unit/Inspector.test.ts +1 -2
  105. package/test/unit/NeighborUpdateRpcLocal.test.ts +6 -6
  106. package/test/unit/NetworkNode.test.ts +3 -4
  107. package/test/unit/NodeList.test.ts +2 -2
  108. package/test/unit/StreamPartIDDataKey.test.ts +1 -1
  109. package/test/unit/StreamPartNetworkSplitAvoidance.test.ts +1 -2
  110. package/test/unit/TemporaryConnectionRpcLocal.test.ts +2 -2
  111. package/test/utils/mock/MockTransport.ts +1 -2
  112. package/test/utils/utils.ts +8 -9
  113. package/tsconfig.jest.json +0 -1
  114. package/tsconfig.node.json +0 -2
  115. package/dist/src/logic/protocol-integration/stream-message/GroupKeyRequestTranslator.d.ts +0 -6
  116. package/dist/src/logic/protocol-integration/stream-message/GroupKeyRequestTranslator.js +0 -28
  117. package/dist/src/logic/protocol-integration/stream-message/GroupKeyRequestTranslator.js.map +0 -1
  118. package/dist/src/logic/protocol-integration/stream-message/GroupKeyResponseTranslator.d.ts +0 -6
  119. package/dist/src/logic/protocol-integration/stream-message/GroupKeyResponseTranslator.js +0 -32
  120. package/dist/src/logic/protocol-integration/stream-message/GroupKeyResponseTranslator.js.map +0 -1
  121. package/dist/src/logic/protocol-integration/stream-message/StreamMessageTranslator.d.ts +0 -6
  122. package/dist/src/logic/protocol-integration/stream-message/StreamMessageTranslator.js +0 -170
  123. package/dist/src/logic/protocol-integration/stream-message/StreamMessageTranslator.js.map +0 -1
  124. package/dist/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.d.ts +0 -7
  125. package/dist/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.js +0 -32
  126. package/dist/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.js.map +0 -1
  127. package/src/logic/protocol-integration/stream-message/GroupKeyRequestTranslator.ts +0 -28
  128. package/src/logic/protocol-integration/stream-message/GroupKeyResponseTranslator.ts +0 -34
  129. package/src/logic/protocol-integration/stream-message/StreamMessageTranslator.ts +0 -197
  130. package/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.ts +0 -37
  131. package/test/unit/GroupKeyResponseTranslator.test.ts +0 -39
  132. package/test/unit/StreamMessageTranslator.test.ts +0 -71
  133. package/test/unit/oldStreamMessageBinaryUtils.test.ts +0 -39
@@ -1,42 +1,44 @@
1
+ import { randomEthereumAddress } from '@streamr/test-utils'
2
+ import { StreamPartID, StreamPartIDUtils, hexToBinary, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
3
+ import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
1
4
  import {
2
5
  ContentType,
3
6
  EncryptionType,
4
- MessageID,
5
- MessageRef,
7
+ ProxyDirection,
6
8
  SignatureType,
7
- StreamMessage,
8
- StreamMessageType,
9
- StreamPartID,
10
- StreamPartIDUtils
11
- } from '@streamr/protocol'
12
- import { randomEthereumAddress } from '@streamr/test-utils'
13
- import { hexToBinary, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
14
- import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
15
- import { StreamMessage as InternalStreamMessage, ProxyDirection } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
9
+ StreamMessage
10
+ } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
16
11
  import { createMockPeerDescriptor } from '../utils/utils'
17
12
 
18
13
  const PROXIED_NODE_USER_ID = randomEthereumAddress()
19
14
 
20
15
  const createMessage = (streamPartId: StreamPartID): StreamMessage => {
21
- return new StreamMessage({
22
- messageId: new MessageID(
23
- StreamPartIDUtils.getStreamID(streamPartId),
24
- StreamPartIDUtils.getStreamPartition(streamPartId),
25
- 666,
26
- 0,
27
- randomEthereumAddress(),
28
- 'msgChainId'
29
- ),
30
- prevMsgRef: new MessageRef(665, 0),
31
- content: utf8ToBinary(JSON.stringify({
32
- hello: 'world'
33
- })),
34
- messageType: StreamMessageType.MESSAGE,
35
- contentType: ContentType.JSON,
36
- encryptionType: EncryptionType.NONE,
16
+ return {
17
+ messageId: {
18
+ streamId: StreamPartIDUtils.getStreamID(streamPartId),
19
+ streamPartition: StreamPartIDUtils.getStreamPartition(streamPartId),
20
+ timestamp: 666,
21
+ sequenceNumber: 0,
22
+ publisherId: hexToBinary(randomEthereumAddress()),
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
+ },
37
39
  signatureType: SignatureType.SECP256K1,
38
40
  signature: hexToBinary('0x1234'),
39
- })
41
+ }
40
42
  }
41
43
 
42
44
  describe('proxy and full node', () => {
@@ -111,13 +113,13 @@ describe('proxy and full node', () => {
111
113
 
112
114
  await Promise.all([
113
115
  waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
114
- (streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart1)),
116
+ (streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart1)),
115
117
  waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
116
- (streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart2)),
118
+ (streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart2)),
117
119
  waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
118
- (streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart3)),
120
+ (streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart3)),
119
121
  waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
120
- (streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart4)),
122
+ (streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart4)),
121
123
  proxiedNode.broadcast(createMessage(regularStreamPart1)),
122
124
  proxiedNode.broadcast(createMessage(regularStreamPart2)),
123
125
  proxiedNode.broadcast(createMessage(regularStreamPart3)),
@@ -1,43 +1,46 @@
1
- import {
2
- ContentType,
3
- EncryptionType,
4
- MessageID,
5
- MessageRef,
6
- SignatureType,
7
- StreamMessage,
8
- StreamMessageType,
9
- StreamPartIDUtils
10
- } from '@streamr/protocol'
1
+ import { DhtAddress } from '@streamr/dht'
11
2
  import { randomEthereumAddress } from '@streamr/test-utils'
12
- import { hexToBinary, utf8ToBinary, wait, waitForCondition, waitForEvent3 } from '@streamr/utils'
3
+ import { StreamPartIDUtils, hexToBinary, utf8ToBinary, wait, waitForCondition, waitForEvent3 } from '@streamr/utils'
13
4
  import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
14
5
  import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
15
6
  import { ProxyClient } from '../../src/logic/proxy/ProxyClient'
16
- import { ProxyDirection } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
7
+ import {
8
+ ContentType,
9
+ EncryptionType,
10
+ ProxyDirection,
11
+ SignatureType,
12
+ StreamMessage
13
+ } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
17
14
  import { createMockPeerDescriptor } from '../utils/utils'
18
- import { DhtAddress } from '@streamr/dht'
19
15
 
20
16
  const PROXIED_NODE_USER_ID = randomEthereumAddress()
21
17
  const STREAM_PART_ID = StreamPartIDUtils.parse('proxy-test#0')
22
- const MESSAGE = new StreamMessage({
23
- messageId: new MessageID(
24
- StreamPartIDUtils.getStreamID(STREAM_PART_ID),
25
- StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
26
- 666,
27
- 0,
28
- randomEthereumAddress(),
29
- 'msgChainId'
30
- ),
31
- prevMsgRef: new MessageRef(665, 0),
32
- content: utf8ToBinary(JSON.stringify({
33
- hello: 'world'
34
- })),
35
- messageType: StreamMessageType.MESSAGE,
36
- encryptionType: EncryptionType.NONE,
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(randomEthereumAddress()),
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
+ },
37
41
  signatureType: SignatureType.SECP256K1,
38
- signature: hexToBinary('0x1234'),
39
- contentType: ContentType.JSON
40
- })
42
+ signature: hexToBinary('0x1234')
43
+ }
41
44
 
42
45
  describe('Proxy connections', () => {
43
46
 
@@ -1,21 +1,9 @@
1
1
  import {
2
- ContentType,
3
- EncryptionType,
4
- MessageID,
5
- GroupKeyRequest as OldGroupKeyRequest,
6
- GroupKeyResponse as OldGroupKeyResponse,
7
- SignatureType,
8
- StreamMessage,
9
- StreamMessageType,
10
- StreamPartIDUtils
11
- } from '@streamr/protocol'
12
- import { hexToBinary, toEthereumAddress, waitForEvent3 } from '@streamr/utils'
2
+ StreamPartIDUtils,
3
+ hexToBinary, toEthereumAddress, waitForEvent3
4
+ } from '@streamr/utils'
13
5
  import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
14
- import {
15
- convertGroupKeyRequestToBytes,
16
- convertGroupKeyResponseToBytes
17
- } from '../../src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils'
18
- import { ProxyDirection } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
6
+ import { ProxyDirection, SignatureType, StreamMessage } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
19
7
  import { createMockPeerDescriptor } from '../utils/utils'
20
8
 
21
9
  const STREAM_PART_ID = StreamPartIDUtils.parse('proxy-test#0')
@@ -75,30 +63,27 @@ describe('proxy group key exchange', () => {
75
63
  await publisher.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.PUBLISH, publisherUserId)
76
64
  await subscriber.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.SUBSCRIBE, subscriberUserId)
77
65
 
78
- const groupKeyRequest = new OldGroupKeyRequest({
79
- recipient: publisherUserId,
80
- requestId: 'requestId',
81
- rsaPublicKey: 'mockKey',
82
- groupKeyIds: [
83
- 'mock'
84
- ],
85
- })
86
- const request = new StreamMessage({
87
- messageId: new MessageID(
88
- StreamPartIDUtils.getStreamID(STREAM_PART_ID),
89
- StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
90
- Date.now(),
91
- 0,
92
- subscriberUserId,
93
- '0'
94
- ),
95
- messageType: StreamMessageType.GROUP_KEY_REQUEST,
96
- contentType: ContentType.BINARY,
97
- encryptionType: EncryptionType.NONE,
98
- content: convertGroupKeyRequestToBytes(groupKeyRequest),
66
+ const request: StreamMessage = {
67
+ messageId: {
68
+ streamId: StreamPartIDUtils.getStreamID(STREAM_PART_ID),
69
+ streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
70
+ timestamp: Date.now(),
71
+ sequenceNumber: 0,
72
+ publisherId: hexToBinary(subscriberUserId),
73
+ messageChainId: '0'
74
+ },
75
+ body: {
76
+ oneofKind: 'groupKeyRequest' as const,
77
+ groupKeyRequest: {
78
+ requestId: 'requestId',
79
+ recipientId: hexToBinary(publisherUserId),
80
+ rsaPublicKey: new Uint8Array(),
81
+ groupKeyIds: ['mock']
82
+ }
83
+ },
99
84
  signatureType: SignatureType.SECP256K1,
100
85
  signature: hexToBinary('1234')
101
- })
86
+ }
102
87
 
103
88
  await Promise.all([
104
89
  waitForEvent3(publisher.stack.getContentDeliveryManager() as any, 'newMessage'),
@@ -110,27 +95,26 @@ describe('proxy group key exchange', () => {
110
95
  await publisher.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.PUBLISH, publisherUserId)
111
96
  await subscriber.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.SUBSCRIBE, subscriberUserId)
112
97
 
113
- const groupKeyResponse = new OldGroupKeyResponse({
114
- recipient: publisherUserId,
115
- requestId: 'requestId',
116
- encryptedGroupKeys: []
117
- })
118
- const response = new StreamMessage({
119
- messageId: new MessageID(
120
- StreamPartIDUtils.getStreamID(STREAM_PART_ID),
121
- StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
122
- Date.now(),
123
- 0,
124
- publisherUserId,
125
- '0'
126
- ),
127
- messageType: StreamMessageType.GROUP_KEY_RESPONSE,
128
- contentType: ContentType.BINARY,
129
- encryptionType: EncryptionType.NONE,
130
- content: convertGroupKeyResponseToBytes(groupKeyResponse),
98
+ const response: StreamMessage = {
99
+ messageId: {
100
+ streamId: StreamPartIDUtils.getStreamID(STREAM_PART_ID),
101
+ streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
102
+ timestamp: Date.now(),
103
+ sequenceNumber: 0,
104
+ publisherId: hexToBinary(publisherUserId),
105
+ messageChainId: '0'
106
+ },
107
+ body: {
108
+ oneofKind: 'groupKeyResponse' as const,
109
+ groupKeyResponse: {
110
+ requestId: 'requestId',
111
+ recipientId: hexToBinary(publisherUserId),
112
+ groupKeys: []
113
+ }
114
+ },
131
115
  signatureType: SignatureType.SECP256K1,
132
116
  signature: hexToBinary('1234')
133
- })
117
+ }
134
118
 
135
119
  await Promise.all([
136
120
  waitForEvent3(subscriber.stack.getContentDeliveryManager() as any, 'newMessage'),
@@ -1,7 +1,6 @@
1
1
  import { getNodeIdFromPeerDescriptor, getRandomRegion } from '@streamr/dht'
2
- import { StreamPartIDUtils } from '@streamr/protocol'
3
2
  import { randomEthereumAddress } from '@streamr/test-utils'
4
- import { waitForCondition } from '@streamr/utils'
3
+ import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
5
4
  import { range } from 'lodash'
6
5
  import { NetworkStack } from '../../src/NetworkStack'
7
6
  import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
@@ -1,10 +1,9 @@
1
- import { StreamPartIDUtils } from '@streamr/protocol'
1
+ import { getNodeIdFromPeerDescriptor } from '@streamr/dht'
2
2
  import { randomEthereumAddress } from '@streamr/test-utils'
3
- import { waitForCondition } from '@streamr/utils'
3
+ import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
4
4
  import { range } from 'lodash'
5
5
  import { NetworkStack } from '../../src/NetworkStack'
6
6
  import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
7
- import { getNodeIdFromPeerDescriptor } from '@streamr/dht'
8
7
 
9
8
  describe('Full node network with WebSocket connections only', () => {
10
9
 
@@ -1,11 +1,10 @@
1
1
  import { DhtNode, LatencyType, PeerDescriptor, Simulator, SimulatorTransport, getNodeIdFromPeerDescriptor } from '@streamr/dht'
2
- import { waitForCondition } from '@streamr/utils'
2
+ import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
3
3
  import { range } from 'lodash'
4
4
  import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
5
+ import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
5
6
  import { createContentDeliveryLayerNode } from '../../src/logic/createContentDeliveryLayerNode'
6
7
  import { createMockPeerDescriptor } from '../utils/utils'
7
- import { StreamPartIDUtils } from '@streamr/protocol'
8
- import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
9
8
 
10
9
  describe('ContentDeliveryLayerNode-DhtNode-Latencies', () => {
11
10
  const otherNodeCount = 64
@@ -1,11 +1,10 @@
1
1
  import { ConnectionManager, DhtNode, PeerDescriptor, Simulator, SimulatorTransport, getNodeIdFromPeerDescriptor, getRandomRegion } from '@streamr/dht'
2
- import { Logger, waitForCondition } from '@streamr/utils'
2
+ import { Logger, StreamPartIDUtils, waitForCondition } from '@streamr/utils'
3
3
  import { range } from 'lodash'
4
4
  import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
5
+ import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
5
6
  import { createContentDeliveryLayerNode } from '../../src/logic/createContentDeliveryLayerNode'
6
7
  import { createMockPeerDescriptor } from '../utils/utils'
7
- import { StreamPartIDUtils } from '@streamr/protocol'
8
- import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
9
8
 
10
9
  const logger = new Logger(module)
11
10
 
@@ -3,12 +3,11 @@ import {
3
3
  Simulator,
4
4
  SimulatorTransport
5
5
  } from '@streamr/dht'
6
- import { ContentDeliveryManager, Events } from '../../src/logic/ContentDeliveryManager'
7
- import { waitForEvent3, waitForCondition } from '@streamr/utils'
8
- import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
9
- import { StreamPartIDUtils } from '@streamr/protocol'
10
6
  import { randomEthereumAddress } from '@streamr/test-utils'
7
+ import { StreamPartIDUtils, waitForCondition, waitForEvent3 } from '@streamr/utils'
8
+ import { ContentDeliveryManager, Events } from '../../src/logic/ContentDeliveryManager'
11
9
  import { ControlLayerNode } from '../../src/logic/ControlLayerNode'
10
+ import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
12
11
 
13
12
  describe('ContentDeliveryManager', () => {
14
13
 
@@ -1,21 +1,20 @@
1
1
  import {
2
2
  ListeningRpcCommunicator,
3
- Simulator,
3
+ NodeType,
4
4
  PeerDescriptor,
5
- SimulatorTransport,
6
- NodeType
5
+ Simulator,
6
+ SimulatorTransport
7
7
  } from '@streamr/dht'
8
+ import { randomEthereumAddress } from '@streamr/test-utils'
9
+ import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
8
10
  import { ContentDeliveryRpcRemote } from '../../src/logic/ContentDeliveryRpcRemote'
9
- import { ContentDeliveryRpcClient } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
11
+ import { Empty } from '../../src/proto/google/protobuf/empty'
10
12
  import {
11
13
  LeaveStreamPartNotice,
12
14
  StreamMessage
13
15
  } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
14
- import { Empty } from '../../src/proto/google/protobuf/empty'
15
- import { waitForCondition } from '@streamr/utils'
16
+ import { ContentDeliveryRpcClient } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
16
17
  import { createStreamMessage } from '../utils/utils'
17
- import { StreamPartIDUtils } from '@streamr/protocol'
18
- import { randomEthereumAddress } from '@streamr/test-utils'
19
18
 
20
19
  describe('ContentDeliveryRpcRemote', () => {
21
20
  let mockServerRpc: ListeningRpcCommunicator
@@ -1,7 +1,3 @@
1
- import {
2
- StreamPartHandshakeRequest,
3
- StreamPartHandshakeResponse
4
- } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
5
1
  import {
6
2
  ListeningRpcCommunicator,
7
3
  NodeType,
@@ -9,11 +5,15 @@ import {
9
5
  Simulator,
10
6
  SimulatorTransport
11
7
  } from '@streamr/dht'
8
+ import { StreamPartIDUtils } from '@streamr/utils'
9
+ import { HandshakeRpcRemote } from '../../src/logic/neighbor-discovery/HandshakeRpcRemote'
10
+ import {
11
+ StreamPartHandshakeRequest,
12
+ StreamPartHandshakeResponse
13
+ } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
12
14
  import {
13
15
  HandshakeRpcClient,
14
16
  } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
15
- import { HandshakeRpcRemote } from '../../src/logic/neighbor-discovery/HandshakeRpcRemote'
16
- import { StreamPartIDUtils } from '@streamr/protocol'
17
17
 
18
18
  describe('HandshakeRpcRemote', () => {
19
19
  let mockServerRpc: ListeningRpcCommunicator
@@ -1,19 +1,19 @@
1
- import { Handshaker } from '../../src/logic/neighbor-discovery/Handshaker'
2
1
  import {
2
+ ListeningRpcCommunicator,
3
3
  NodeType,
4
4
  PeerDescriptor,
5
- ListeningRpcCommunicator,
6
5
  Simulator,
7
6
  SimulatorTransport,
8
7
  getNodeIdFromPeerDescriptor
9
8
  } from '@streamr/dht'
9
+ import { StreamPartIDUtils } from '@streamr/utils'
10
+ import { NodeList } from '../../src/logic/NodeList'
11
+ import { HandshakeRpcRemote } from '../../src/logic/neighbor-discovery/HandshakeRpcRemote'
12
+ import { Handshaker } from '../../src/logic/neighbor-discovery/Handshaker'
13
+ import { StreamPartHandshakeRequest, StreamPartHandshakeResponse } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
10
14
  import {
11
15
  HandshakeRpcClient
12
16
  } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
13
- import { NodeList } from '../../src/logic/NodeList'
14
- import { StreamPartHandshakeRequest, StreamPartHandshakeResponse } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
15
- import { HandshakeRpcRemote } from '../../src/logic/neighbor-discovery/HandshakeRpcRemote'
16
- import { StreamPartIDUtils } from '@streamr/protocol'
17
17
 
18
18
  describe('Handshakes', () => {
19
19
 
@@ -1,6 +1,6 @@
1
1
  import { LatencyType, PeerDescriptor, Simulator, SimulatorTransport } from '@streamr/dht'
2
- import { StreamPartIDUtils } from '@streamr/protocol'
3
2
  import { randomEthereumAddress } from '@streamr/test-utils'
3
+ import { StreamPartIDUtils } from '@streamr/utils'
4
4
  import { range } from 'lodash'
5
5
  import { NetworkStack } from '../../src/NetworkStack'
6
6
  import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
@@ -5,12 +5,12 @@ import {
5
5
  Simulator,
6
6
  SimulatorTransport
7
7
  } from '@streamr/dht'
8
+ import { StreamPartIDUtils } from '@streamr/utils'
8
9
  import { NeighborUpdateRpcRemote } from '../../src/logic/neighbor-discovery/NeighborUpdateRpcRemote'
9
10
  import { NeighborUpdate } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
10
11
  import {
11
12
  NeighborUpdateRpcClient,
12
13
  } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
13
- import { StreamPartIDUtils } from '@streamr/protocol'
14
14
 
15
15
  describe('NeighborUpdateRpcRemote', () => {
16
16
  let mockServerRpc: ListeningRpcCommunicator
@@ -1,15 +1,7 @@
1
1
  import { PeerDescriptor, Simulator, SimulatorTransport } from '@streamr/dht'
2
- import {
3
- ContentType,
4
- EncryptionType,
5
- MessageID,
6
- MessageRef, SignatureType,
7
- StreamMessage,
8
- StreamMessageType,
9
- StreamPartIDUtils
10
- } from '@streamr/protocol'
11
- import { EthereumAddress, hexToBinary, utf8ToBinary, waitForCondition } from '@streamr/utils'
2
+ import { StreamPartIDUtils, hexToBinary, utf8ToBinary, waitForCondition } from '@streamr/utils'
12
3
  import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
4
+ import { ContentType, EncryptionType, SignatureType, StreamMessage } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
13
5
  import { createMockPeerDescriptor } from '../utils/utils'
14
6
 
15
7
  const STREAM_PART_ID = StreamPartIDUtils.parse('test#0')
@@ -64,31 +56,38 @@ describe('NetworkNode', () => {
64
56
  })
65
57
 
66
58
  it('wait for join + broadcast and subscribe', async () => {
67
- const streamMessage = new StreamMessage({
68
- messageId: new MessageID(
69
- StreamPartIDUtils.getStreamID(STREAM_PART_ID),
70
- StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
71
- 666,
72
- 0,
73
- '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' as EthereumAddress,
74
- 'msgChainId'
75
- ),
76
- prevMsgRef: new MessageRef(665, 0),
77
- content: utf8ToBinary(JSON.stringify({
78
- hello: 'world'
79
- })),
80
- contentType: ContentType.JSON,
81
- messageType: StreamMessageType.MESSAGE,
82
- encryptionType: EncryptionType.NONE,
59
+ const streamMessage: StreamMessage = {
60
+ messageId: {
61
+ streamId: StreamPartIDUtils.getStreamID(STREAM_PART_ID),
62
+ streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
63
+ timestamp: 666,
64
+ sequenceNumber: 0,
65
+ publisherId: hexToBinary('0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
66
+ messageChainId: 'msgChainId'
67
+ },
68
+ previousMessageRef: {
69
+ timestamp: 665,
70
+ sequenceNumber: 0
71
+ },
72
+ body: {
73
+ oneofKind: 'contentMessage',
74
+ contentMessage: {
75
+ content: utf8ToBinary(JSON.stringify({
76
+ hello: 'world'
77
+ })),
78
+ contentType: ContentType.JSON,
79
+ encryptionType: EncryptionType.NONE,
80
+ }
81
+ },
83
82
  signatureType: SignatureType.SECP256K1,
84
83
  signature: hexToBinary('0x1234'),
85
- })
84
+ }
86
85
 
87
86
  let msgCount = 0
88
87
  await node1.join(STREAM_PART_ID)
89
88
  node1.addMessageListener((msg) => {
90
- expect(msg.messageId.timestamp).toEqual(666)
91
- expect(msg.getSequenceNumber()).toEqual(0)
89
+ expect(msg.messageId!.timestamp).toEqual(666)
90
+ expect(msg.messageId!.sequenceNumber).toEqual(0)
92
91
  msgCount += 1
93
92
  })
94
93
  await node2.broadcast(streamMessage)
@@ -1,17 +1,16 @@
1
+ import { DhtCallContext } from '@streamr/dht'
1
2
  import {
2
- RpcCommunicator,
3
3
  ProtoRpcClient,
4
+ RpcCommunicator,
4
5
  toProtoRpcClient
5
6
  } from '@streamr/proto-rpc'
6
- import { ContentDeliveryRpcClient } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
7
- import { StreamMessage } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
8
- import { waitForCondition } from '@streamr/utils'
7
+ import { randomEthereumAddress } from '@streamr/test-utils'
8
+ import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
9
9
  import { Empty } from '../../src/proto/google/protobuf/empty'
10
- import { createStreamMessage } from '../utils/utils'
11
10
  import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
12
- import { DhtCallContext } from '@streamr/dht'
13
- import { StreamPartIDUtils } from '@streamr/protocol'
14
- import { randomEthereumAddress } from '@streamr/test-utils'
11
+ import { StreamMessage } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
12
+ import { ContentDeliveryRpcClient } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
13
+ import { createStreamMessage } from '../utils/utils'
15
14
 
16
15
  describe('Network RPC', () => {
17
16
  let rpcCommunicator1: RpcCommunicator<DhtCallContext>
@@ -1,8 +1,8 @@
1
- import {
2
- StreamPartIDUtils
3
- } from '@streamr/protocol'
4
1
  import { randomEthereumAddress } from '@streamr/test-utils'
5
- import { waitForCondition } from '@streamr/utils'
2
+ import {
3
+ StreamPartIDUtils,
4
+ waitForCondition
5
+ } from '@streamr/utils'
6
6
  import { NetworkStack } from '../../src/NetworkStack'
7
7
  import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
8
8
 
@@ -1,10 +1,9 @@
1
- import { Simulator, SimulatorTransport, ListeningRpcCommunicator, PeerDescriptor } from '@streamr/dht'
1
+ import { ListeningRpcCommunicator, PeerDescriptor, Simulator, SimulatorTransport } from '@streamr/dht'
2
+ import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
2
3
  import { NetworkStack } from '../../src/NetworkStack'
3
- import { createMockPeerDescriptor } from '../utils/utils'
4
4
  import { NodeInfoClient } from '../../src/logic/node-info/NodeInfoClient'
5
5
  import { NODE_INFO_RPC_SERVICE_ID } from '../../src/logic/node-info/NodeInfoRpcLocal'
6
- import { StreamPartIDUtils } from '@streamr/protocol'
7
- import { waitForCondition } from '@streamr/utils'
6
+ import { createMockPeerDescriptor } from '../utils/utils'
8
7
 
9
8
  // TODO add Jest utility so that the normalization is not needed (NET-1254)
10
9
  const normalizePeerDescriptor = (peerDescriptor: PeerDescriptor) => {
@@ -1,11 +1,10 @@
1
1
  import { Simulator } from '@streamr/dht'
2
- import { StreamPartIDUtils } from '@streamr/protocol'
3
2
  import { randomEthereumAddress } from '@streamr/test-utils'
4
- import { waitForCondition } from '@streamr/utils'
3
+ import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
5
4
  import { range } from 'lodash'
6
5
  import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
7
- import { createMockPeerDescriptor, createMockContentDeliveryLayerNodeAndDhtNode, createStreamMessage } from '../utils/utils'
8
6
  import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
7
+ import { createMockContentDeliveryLayerNodeAndDhtNode, createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
9
8
 
10
9
  describe('Propagation', () => {
11
10
  const entryPointDescriptor = createMockPeerDescriptor()
@@ -1,11 +1,10 @@
1
- import { PeerDescriptor, Simulator, SimulatorTransport, LatencyType } from '@streamr/dht'
1
+ import { LatencyType, PeerDescriptor, Simulator, SimulatorTransport } from '@streamr/dht'
2
+ import { randomEthereumAddress } from '@streamr/test-utils'
3
+ import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
2
4
  import { NetworkStack } from '../../src/NetworkStack'
3
5
  import { streamPartIdToDataKey } from '../../src/logic/ContentDeliveryManager'
4
- import { StreamPartIDUtils } from '@streamr/protocol'
5
6
  import { Any } from '../../src/proto/google/protobuf/any'
6
7
  import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
7
- import { waitForCondition } from '@streamr/utils'
8
- import { randomEthereumAddress } from '@streamr/test-utils'
9
8
 
10
9
  const STREAM_PART_ID = StreamPartIDUtils.parse('stream#0')
11
10