@streamr/trackerless-network 100.0.0-testnet-two.0 → 100.0.0-testnet-two.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.
Files changed (121) hide show
  1. package/dist/package.json +6 -6
  2. package/dist/src/NetworkNode.d.ts +3 -4
  3. package/dist/src/NetworkNode.js.map +1 -1
  4. package/dist/src/exports.d.ts +0 -1
  5. package/dist/src/exports.js.map +1 -1
  6. package/dist/src/logic/DeliveryRpcLocal.d.ts +4 -5
  7. package/dist/src/logic/DeliveryRpcLocal.js +3 -3
  8. package/dist/src/logic/DeliveryRpcLocal.js.map +1 -1
  9. package/dist/src/logic/DeliveryRpcRemote.d.ts +2 -1
  10. package/dist/src/logic/DeliveryRpcRemote.js +2 -2
  11. package/dist/src/logic/DeliveryRpcRemote.js.map +1 -1
  12. package/dist/src/logic/EntryPointDiscovery.d.ts +5 -5
  13. package/dist/src/logic/EntryPointDiscovery.js +4 -5
  14. package/dist/src/logic/EntryPointDiscovery.js.map +1 -1
  15. package/dist/src/logic/Layer0Node.d.ts +4 -4
  16. package/dist/src/logic/NodeList.d.ts +12 -13
  17. package/dist/src/logic/NodeList.js +4 -4
  18. package/dist/src/logic/NodeList.js.map +1 -1
  19. package/dist/src/logic/RandomGraphNode.d.ts +6 -7
  20. package/dist/src/logic/RandomGraphNode.js +9 -9
  21. package/dist/src/logic/RandomGraphNode.js.map +1 -1
  22. package/dist/src/logic/StreamrNode.d.ts +3 -4
  23. package/dist/src/logic/StreamrNode.js +2 -3
  24. package/dist/src/logic/StreamrNode.js.map +1 -1
  25. package/dist/src/logic/createRandomGraphNode.js +1 -3
  26. package/dist/src/logic/createRandomGraphNode.js.map +1 -1
  27. package/dist/src/logic/inspect/InspectSession.d.ts +3 -3
  28. package/dist/src/logic/inspect/InspectSession.js.map +1 -1
  29. package/dist/src/logic/inspect/Inspector.d.ts +3 -4
  30. package/dist/src/logic/inspect/Inspector.js +3 -3
  31. package/dist/src/logic/inspect/Inspector.js.map +1 -1
  32. package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.d.ts +4 -5
  33. package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js +10 -10
  34. package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -1
  35. package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.d.ts +3 -3
  36. package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js +7 -8
  37. package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -1
  38. package/dist/src/logic/neighbor-discovery/Handshaker.d.ts +3 -4
  39. package/dist/src/logic/neighbor-discovery/Handshaker.js +12 -12
  40. package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
  41. package/dist/src/logic/neighbor-discovery/NeighborFinder.d.ts +3 -3
  42. package/dist/src/logic/neighbor-discovery/NeighborFinder.js.map +1 -1
  43. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +4 -4
  44. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
  45. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js +5 -5
  46. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +1 -1
  47. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.d.ts +2 -1
  48. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js +3 -4
  49. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js.map +1 -1
  50. package/dist/src/logic/propagation/Propagation.d.ts +4 -4
  51. package/dist/src/logic/propagation/Propagation.js.map +1 -1
  52. package/dist/src/logic/propagation/PropagationTaskStore.d.ts +2 -2
  53. package/dist/src/logic/proxy/ProxyClient.d.ts +3 -4
  54. package/dist/src/logic/proxy/ProxyClient.js +8 -9
  55. package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
  56. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.d.ts +6 -7
  57. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js +4 -4
  58. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -1
  59. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.d.ts +0 -2
  60. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +3 -3
  61. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +1 -1
  62. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js +1 -2
  63. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js.map +1 -1
  64. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +13 -5
  65. package/dist/src/proto/packages/dht/protos/DhtRpc.js +9 -5
  66. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
  67. package/dist/test/benchmark/first-message.js +2 -3
  68. package/dist/test/benchmark/first-message.js.map +1 -1
  69. package/dist/test/utils/utils.d.ts +2 -3
  70. package/dist/test/utils/utils.js +4 -4
  71. package/dist/test/utils/utils.js.map +1 -1
  72. package/package.json +6 -6
  73. package/src/NetworkNode.ts +3 -4
  74. package/src/exports.ts +0 -1
  75. package/src/logic/DeliveryRpcLocal.ts +4 -5
  76. package/src/logic/DeliveryRpcRemote.ts +3 -2
  77. package/src/logic/EntryPointDiscovery.ts +11 -9
  78. package/src/logic/Layer0Node.ts +4 -4
  79. package/src/logic/NodeList.ts +15 -16
  80. package/src/logic/RandomGraphNode.ts +16 -17
  81. package/src/logic/StreamrNode.ts +6 -5
  82. package/src/logic/createRandomGraphNode.ts +2 -4
  83. package/src/logic/inspect/InspectSession.ts +4 -4
  84. package/src/logic/inspect/Inspector.ts +4 -6
  85. package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +17 -10
  86. package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +11 -10
  87. package/src/logic/neighbor-discovery/Handshaker.ts +14 -15
  88. package/src/logic/neighbor-discovery/NeighborFinder.ts +4 -4
  89. package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +2 -4
  90. package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +1 -3
  91. package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +4 -4
  92. package/src/logic/propagation/Propagation.ts +6 -6
  93. package/src/logic/propagation/PropagationTaskStore.ts +2 -2
  94. package/src/logic/proxy/ProxyClient.ts +20 -21
  95. package/src/logic/proxy/ProxyConnectionRpcLocal.ts +10 -12
  96. package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +1 -5
  97. package/src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts +1 -2
  98. package/src/proto/packages/dht/protos/DhtRpc.ts +18 -10
  99. package/test/benchmark/first-message.ts +2 -3
  100. package/test/end-to-end/proxy-connections.test.ts +2 -2
  101. package/test/end-to-end/webrtc-full-node-network.test.ts +1 -2
  102. package/test/end-to-end/websocket-full-node-network.test.ts +1 -1
  103. package/test/integration/DeliveryRpcRemote.test.ts +2 -5
  104. package/test/integration/HandshakeRpcRemote.test.ts +2 -2
  105. package/test/integration/Handshakes.test.ts +2 -6
  106. package/test/integration/NeighborUpdateRpcRemote.test.ts +1 -2
  107. package/test/unit/HandshakeRpcLocal.test.ts +9 -11
  108. package/test/unit/Handshaker.test.ts +1 -2
  109. package/test/unit/InspectSession.test.ts +3 -3
  110. package/test/unit/Inspector.test.ts +1 -2
  111. package/test/unit/NeighborFinder.test.ts +2 -2
  112. package/test/unit/NodeList.test.ts +12 -13
  113. package/test/unit/Propagation.test.ts +9 -9
  114. package/test/unit/ProxyConnectionRpcRemote.test.ts +0 -2
  115. package/test/unit/RandomGraphNode.test.ts +1 -1
  116. package/test/utils/mock/MockHandshaker.ts +3 -3
  117. package/test/utils/utils.ts +15 -7
  118. package/dist/src/identifiers.d.ts +0 -4
  119. package/dist/src/identifiers.js +0 -9
  120. package/dist/src/identifiers.js.map +0 -1
  121. package/src/identifiers.ts +0 -8
@@ -9,12 +9,11 @@ import {
9
9
  } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
10
10
  import { IProxyConnectionRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
11
11
  import { DeliveryRpcRemote } from '../DeliveryRpcRemote'
12
- import { DhtCallContext, ListeningRpcCommunicator, PeerDescriptor } from '@streamr/dht'
12
+ import { DhtAddress, DhtCallContext, ListeningRpcCommunicator, PeerDescriptor, getNodeIdFromPeerDescriptor } from '@streamr/dht'
13
13
  import { DeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
14
14
  import { EventEmitter } from 'eventemitter3'
15
15
  import { EthereumAddress, Logger, binaryToHex, toEthereumAddress } from '@streamr/utils'
16
16
  import { StreamPartID } from '@streamr/protocol'
17
- import { NodeID, getNodeIdFromPeerDescriptor } from '../../identifiers'
18
17
 
19
18
  const logger = new Logger(module)
20
19
 
@@ -31,13 +30,13 @@ interface ProxyConnectionRpcLocalConfig {
31
30
  }
32
31
 
33
32
  export interface Events {
34
- newConnection: (nodeId: NodeID) => void
33
+ newConnection: (nodeId: DhtAddress) => void
35
34
  }
36
35
 
37
36
  export class ProxyConnectionRpcLocal extends EventEmitter<Events> implements IProxyConnectionRpc {
38
37
 
39
38
  private readonly config: ProxyConnectionRpcLocalConfig
40
- private readonly connections: Map<NodeID, ProxyConnection> = new Map()
39
+ private readonly connections: Map<DhtAddress, ProxyConnection> = new Map()
41
40
 
42
41
  constructor(config: ProxyConnectionRpcLocalConfig) {
43
42
  super()
@@ -46,25 +45,25 @@ export class ProxyConnectionRpcLocal extends EventEmitter<Events> implements IPr
46
45
  (msg: ProxyConnectionRequest, context) => this.requestConnection(msg, context))
47
46
  }
48
47
 
49
- getConnection(nodeId: NodeID): ProxyConnection | undefined {
48
+ getConnection(nodeId: DhtAddress): ProxyConnection | undefined {
50
49
  return this.connections.get(nodeId)
51
50
  }
52
51
 
53
- hasConnection(nodeId: NodeID): boolean {
52
+ hasConnection(nodeId: DhtAddress): boolean {
54
53
  return this.connections.has(nodeId)
55
54
  }
56
55
 
57
- removeConnection(nodeId: NodeID): void {
56
+ removeConnection(nodeId: DhtAddress): void {
58
57
  this.connections.delete(nodeId)
59
58
  }
60
59
 
61
60
  stop(): void {
62
- this.connections.forEach((connection) => connection.remote.leaveStreamPartNotice(false))
61
+ this.connections.forEach((connection) => connection.remote.leaveStreamPartNotice(this.config.streamPartId, false))
63
62
  this.connections.clear()
64
63
  this.removeAllListeners()
65
64
  }
66
65
 
67
- getPropagationTargets(msg: StreamMessage): NodeID[] {
66
+ getPropagationTargets(msg: StreamMessage): DhtAddress[] {
68
67
  if (msg.messageType === StreamMessageType.GROUP_KEY_REQUEST) {
69
68
  try {
70
69
  const recipientId = GroupKeyRequest.fromBinary(msg.content).recipientId
@@ -78,11 +77,11 @@ export class ProxyConnectionRpcLocal extends EventEmitter<Events> implements IPr
78
77
  }
79
78
  }
80
79
 
81
- private getNodeIdsForUserId(userId: EthereumAddress): NodeID[] {
80
+ private getNodeIdsForUserId(userId: EthereumAddress): DhtAddress[] {
82
81
  return Array.from(this.connections.keys()).filter((nodeId) => this.connections.get(nodeId)!.userId === userId)
83
82
  }
84
83
 
85
- private getSubscribers(): NodeID[] {
84
+ private getSubscribers(): DhtAddress[] {
86
85
  return Array.from(this.connections.keys()).filter((key) => this.connections.get(key)!.direction === ProxyDirection.SUBSCRIBE)
87
86
  }
88
87
 
@@ -96,7 +95,6 @@ export class ProxyConnectionRpcLocal extends EventEmitter<Events> implements IPr
96
95
  remote: new DeliveryRpcRemote(
97
96
  this.config.localPeerDescriptor,
98
97
  senderPeerDescriptor,
99
- this.config.streamPartId,
100
98
  this.config.rpcCommunicator,
101
99
  DeliveryRpcClient
102
100
  )
@@ -1,16 +1,13 @@
1
1
  import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
2
2
  import { TemporaryConnectionRequest, TemporaryConnectionResponse } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
3
3
  import { ITemporaryConnectionRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
4
- import { DhtCallContext, ListeningRpcCommunicator } from '@streamr/dht'
4
+ import { DhtCallContext, ListeningRpcCommunicator, getNodeIdFromPeerDescriptor } from '@streamr/dht'
5
5
  import { DeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
6
6
  import { NodeList } from '../NodeList'
7
7
  import { DeliveryRpcRemote } from '../DeliveryRpcRemote'
8
8
  import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc'
9
- import { getNodeIdFromPeerDescriptor } from '../../identifiers'
10
- import { StreamPartID } from '@streamr/protocol'
11
9
 
12
10
  interface TemporaryConnectionRpcLocalConfig {
13
- streamPartId: StreamPartID
14
11
  rpcCommunicator: ListeningRpcCommunicator
15
12
  localPeerDescriptor: PeerDescriptor
16
13
  }
@@ -42,7 +39,6 @@ export class TemporaryConnectionRpcLocal implements ITemporaryConnectionRpc {
42
39
  const remote = new DeliveryRpcRemote(
43
40
  this.config.localPeerDescriptor,
44
41
  sender,
45
- this.config.streamPartId,
46
42
  this.config.rpcCommunicator,
47
43
  DeliveryRpcClient
48
44
  )
@@ -1,6 +1,5 @@
1
- import { RpcRemote } from '@streamr/dht'
1
+ import { RpcRemote, getNodeIdFromPeerDescriptor } from '@streamr/dht'
2
2
  import { Logger } from '@streamr/utils'
3
- import { getNodeIdFromPeerDescriptor } from '../../identifiers'
4
3
  import { TemporaryConnectionRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
5
4
 
6
5
  const logger = new Logger(module)
@@ -189,10 +189,6 @@ export interface PingResponse {
189
189
  * @generated from protobuf message dht.LeaveNotice
190
190
  */
191
191
  export interface LeaveNotice {
192
- /**
193
- * @generated from protobuf field: string serviceId = 1;
194
- */
195
- serviceId: string;
196
192
  }
197
193
  /**
198
194
  * @generated from protobuf message dht.PeerDescriptor
@@ -334,6 +330,10 @@ export interface HandshakeRequest {
334
330
  * @generated from protobuf field: optional dht.PeerDescriptor targetPeerDescriptor = 2;
335
331
  */
336
332
  targetPeerDescriptor?: PeerDescriptor;
333
+ /**
334
+ * @generated from protobuf field: string version = 3;
335
+ */
336
+ version: string;
337
337
  }
338
338
  /**
339
339
  * @generated from protobuf message dht.HandshakeResponse
@@ -347,6 +347,10 @@ export interface HandshakeResponse {
347
347
  * @generated from protobuf field: optional dht.HandshakeError error = 2;
348
348
  */
349
349
  error?: HandshakeError;
350
+ /**
351
+ * @generated from protobuf field: string version = 3;
352
+ */
353
+ version: string;
350
354
  }
351
355
  /**
352
356
  * @generated from protobuf message dht.Message
@@ -615,7 +619,11 @@ export enum HandshakeError {
615
619
  /**
616
620
  * @generated from protobuf enum value: INVALID_TARGET_PEER_DESCRIPTOR = 1;
617
621
  */
618
- INVALID_TARGET_PEER_DESCRIPTOR = 1
622
+ INVALID_TARGET_PEER_DESCRIPTOR = 1,
623
+ /**
624
+ * @generated from protobuf enum value: UNSUPPORTED_VERSION = 2;
625
+ */
626
+ UNSUPPORTED_VERSION = 2
619
627
  }
620
628
  // Wraps all messages
621
629
 
@@ -824,9 +832,7 @@ export const PingResponse = new PingResponse$Type();
824
832
  // @generated message type with reflection information, may provide speed optimized methods
825
833
  class LeaveNotice$Type extends MessageType$<LeaveNotice> {
826
834
  constructor() {
827
- super("dht.LeaveNotice", [
828
- { no: 1, name: "serviceId", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
829
- ]);
835
+ super("dht.LeaveNotice", []);
830
836
  }
831
837
  }
832
838
  /**
@@ -928,7 +934,8 @@ class HandshakeRequest$Type extends MessageType$<HandshakeRequest> {
928
934
  constructor() {
929
935
  super("dht.HandshakeRequest", [
930
936
  { no: 1, name: "sourcePeerDescriptor", kind: "message", T: () => PeerDescriptor },
931
- { no: 2, name: "targetPeerDescriptor", kind: "message", T: () => PeerDescriptor }
937
+ { no: 2, name: "targetPeerDescriptor", kind: "message", T: () => PeerDescriptor },
938
+ { no: 3, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
932
939
  ]);
933
940
  }
934
941
  }
@@ -941,7 +948,8 @@ class HandshakeResponse$Type extends MessageType$<HandshakeResponse> {
941
948
  constructor() {
942
949
  super("dht.HandshakeResponse", [
943
950
  { no: 1, name: "sourcePeerDescriptor", kind: "message", T: () => PeerDescriptor },
944
- { no: 2, name: "error", kind: "enum", opt: true, T: () => ["dht.HandshakeError", HandshakeError] }
951
+ { no: 2, name: "error", kind: "enum", opt: true, T: () => ["dht.HandshakeError", HandshakeError] },
952
+ { no: 3, name: "version", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
945
953
  ]);
946
954
  }
947
955
  }
@@ -1,12 +1,11 @@
1
1
  /* eslint-disable no-console */
2
2
 
3
- import { DhtNode, LatencyType, Simulator, getRandomRegion } from '@streamr/dht'
3
+ import { DhtNode, LatencyType, Simulator, getNodeIdFromPeerDescriptor, getRandomRegion } from '@streamr/dht'
4
4
  import { MessageID, StreamMessage, StreamMessageType, StreamPartID, StreamPartIDUtils, toStreamID, toStreamPartID } from '@streamr/protocol'
5
5
  import { hexToBinary, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
6
6
  import fs from 'fs'
7
7
  import { PeerDescriptor } from '@streamr/dht'
8
8
  import { NetworkNode } from '../../src/NetworkNode'
9
- import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
10
9
  import { streamPartIdToDataKey } from '../../src/logic/EntryPointDiscovery'
11
10
  import { createMockPeerDescriptor, createNetworkNodeWithSimulator } from '../utils/utils'
12
11
  import { Layer1Node } from '../../src/logic/Layer1Node'
@@ -52,7 +51,7 @@ const prepareStream = async (streamId: string) => {
52
51
  }
53
52
 
54
53
  const shutdownNetwork = async () => {
55
- publishIntervals.map((interval) => clearInterval(interval))
54
+ publishIntervals.forEach((interval) => clearInterval(interval))
56
55
  await Promise.all([
57
56
  ...nodes.map((node) => node.stop())
58
57
  ])
@@ -2,11 +2,11 @@ import { MessageID, MessageRef, StreamMessage, StreamMessageType, StreamPartIDUt
2
2
  import { randomEthereumAddress } from '@streamr/test-utils'
3
3
  import { hexToBinary, utf8ToBinary, wait, waitForCondition, waitForEvent3 } from '@streamr/utils'
4
4
  import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
5
- import { NodeID } from '../../src/identifiers'
6
5
  import { RandomGraphNode } from '../../src/logic/RandomGraphNode'
7
6
  import { ProxyClient } from '../../src/logic/proxy/ProxyClient'
8
7
  import { ProxyDirection } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
9
8
  import { createMockPeerDescriptor } from '../utils/utils'
9
+ import { DhtAddress } from '@streamr/dht'
10
10
 
11
11
  const PROXIED_NODE_USER_ID = randomEthereumAddress()
12
12
  const STREAM_PART_ID = StreamPartIDUtils.parse('proxy-test#0')
@@ -40,7 +40,7 @@ describe('Proxy connections', () => {
40
40
  : false
41
41
  }
42
42
 
43
- const hasConnectionToProxy = (proxyNodeId: NodeID, direction: ProxyDirection): boolean => {
43
+ const hasConnectionToProxy = (proxyNodeId: DhtAddress, direction: ProxyDirection): boolean => {
44
44
  const client = (proxiedNode.stack.getStreamrNode()!.getStreamPartDelivery(STREAM_PART_ID) as { client: ProxyClient }).client
45
45
  return client.hasConnection(proxyNodeId, direction)
46
46
  }
@@ -1,10 +1,9 @@
1
- import { getRandomRegion } from '@streamr/dht'
1
+ import { getNodeIdFromPeerDescriptor, getRandomRegion } from '@streamr/dht'
2
2
  import { StreamPartIDUtils } from '@streamr/protocol'
3
3
  import { randomEthereumAddress } from '@streamr/test-utils'
4
4
  import { waitForCondition } from '@streamr/utils'
5
5
  import { range } from 'lodash'
6
6
  import { NetworkStack } from '../../src/NetworkStack'
7
- import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
8
7
  import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
9
8
 
10
9
  describe('Full node network with WebRTC connections', () => {
@@ -3,8 +3,8 @@ import { randomEthereumAddress } from '@streamr/test-utils'
3
3
  import { waitForCondition } from '@streamr/utils'
4
4
  import { range } from 'lodash'
5
5
  import { NetworkStack } from '../../src/NetworkStack'
6
- import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
7
6
  import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
7
+ import { getNodeIdFromPeerDescriptor } from '@streamr/dht'
8
8
 
9
9
  describe('Full node network with WebSocket connections only', () => {
10
10
 
@@ -17,8 +17,6 @@ import { createStreamMessage } from '../utils/utils'
17
17
  import { StreamPartIDUtils } from '@streamr/protocol'
18
18
  import { randomEthereumAddress } from '@streamr/test-utils'
19
19
 
20
- const STREAM_PART_ID = StreamPartIDUtils.parse('test-stream#0')
21
-
22
20
  describe('DeliveryRpcRemote', () => {
23
21
  let mockServerRpc: ListeningRpcCommunicator
24
22
  let clientRpc: ListeningRpcCommunicator
@@ -71,7 +69,6 @@ describe('DeliveryRpcRemote', () => {
71
69
  rpcRemote = new DeliveryRpcRemote(
72
70
  clientNode,
73
71
  serverNode,
74
- STREAM_PART_ID,
75
72
  clientRpc,
76
73
  DeliveryRpcClient
77
74
  )
@@ -88,7 +85,7 @@ describe('DeliveryRpcRemote', () => {
88
85
  it('sendStreamMessage', async () => {
89
86
  const msg = createStreamMessage(
90
87
  JSON.stringify({ hello: 'WORLD' }),
91
- STREAM_PART_ID,
88
+ StreamPartIDUtils.parse('test-stream#0'),
92
89
  randomEthereumAddress()
93
90
  )
94
91
 
@@ -97,7 +94,7 @@ describe('DeliveryRpcRemote', () => {
97
94
  })
98
95
 
99
96
  it('leaveNotice', async () => {
100
- rpcRemote.leaveStreamPartNotice(false)
97
+ rpcRemote.leaveStreamPartNotice(StreamPartIDUtils.parse('test#0'), false)
101
98
  await waitForCondition(() => recvCounter === 1)
102
99
  })
103
100
 
@@ -13,6 +13,7 @@ import {
13
13
  HandshakeRpcClient,
14
14
  } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
15
15
  import { HandshakeRpcRemote } from '../../src/logic/neighbor-discovery/HandshakeRpcRemote'
16
+ import { StreamPartIDUtils } from '@streamr/protocol'
16
17
 
17
18
  describe('HandshakeRpcRemote', () => {
18
19
  let mockServerRpc: ListeningRpcCommunicator
@@ -58,7 +59,6 @@ describe('HandshakeRpcRemote', () => {
58
59
  rpcRemote = new HandshakeRpcRemote(
59
60
  clientNode,
60
61
  serverNode,
61
- 'test-stream-part',
62
62
  clientRpc,
63
63
  HandshakeRpcClient
64
64
  )
@@ -73,7 +73,7 @@ describe('HandshakeRpcRemote', () => {
73
73
  })
74
74
 
75
75
  it('handshake', async () => {
76
- const result = await rpcRemote.handshake([])
76
+ const result = await rpcRemote.handshake(StreamPartIDUtils.parse('test#0'), [])
77
77
  expect(result.accepted).toEqual(true)
78
78
  })
79
79
  })
@@ -4,7 +4,8 @@ import {
4
4
  PeerDescriptor,
5
5
  ListeningRpcCommunicator,
6
6
  Simulator,
7
- SimulatorTransport
7
+ SimulatorTransport,
8
+ getNodeIdFromPeerDescriptor
8
9
  } from '@streamr/dht'
9
10
  import {
10
11
  HandshakeRpcClient
@@ -13,7 +14,6 @@ import { NodeList } from '../../src/logic/NodeList'
13
14
  import { mockConnectionLocker } from '../utils/utils'
14
15
  import { StreamPartHandshakeRequest, StreamPartHandshakeResponse } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
15
16
  import { HandshakeRpcRemote } from '../../src/logic/neighbor-discovery/HandshakeRpcRemote'
16
- import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
17
17
  import { StreamPartIDUtils } from '@streamr/protocol'
18
18
 
19
19
  describe('Handshakes', () => {
@@ -114,7 +114,6 @@ describe('Handshakes', () => {
114
114
  new HandshakeRpcRemote(
115
115
  peerDescriptor2,
116
116
  peerDescriptor1,
117
- streamPartId,
118
117
  rpcCommunicator2,
119
118
  HandshakeRpcClient
120
119
  )
@@ -130,7 +129,6 @@ describe('Handshakes', () => {
130
129
  new HandshakeRpcRemote(
131
130
  peerDescriptor2,
132
131
  peerDescriptor1,
133
- streamPartId,
134
132
  rpcCommunicator2,
135
133
  HandshakeRpcClient
136
134
  )
@@ -146,7 +144,6 @@ describe('Handshakes', () => {
146
144
  new HandshakeRpcRemote(
147
145
  peerDescriptor2,
148
146
  peerDescriptor1,
149
- streamPartId,
150
147
  rpcCommunicator2,
151
148
  HandshakeRpcClient
152
149
  )
@@ -163,7 +160,6 @@ describe('Handshakes', () => {
163
160
  new HandshakeRpcRemote(
164
161
  peerDescriptor2,
165
162
  peerDescriptor1,
166
- streamPartId,
167
163
  rpcCommunicator2,
168
164
  HandshakeRpcClient
169
165
  )
@@ -62,7 +62,6 @@ describe('NeighborUpdateRpcRemote', () => {
62
62
  rpcRemote = new NeighborUpdateRpcRemote(
63
63
  clientNode,
64
64
  serverNode,
65
- 'test-stream-part',
66
65
  clientRpc,
67
66
  NeighborUpdateRpcClient
68
67
  )
@@ -77,7 +76,7 @@ describe('NeighborUpdateRpcRemote', () => {
77
76
  })
78
77
 
79
78
  it('updateNeighbors', async () => {
80
- const res = await rpcRemote.updateNeighbors([])
79
+ const res = await rpcRemote.updateNeighbors(StreamPartIDUtils.parse('test#0'), [])
81
80
  expect(res.peerDescriptors.length).toEqual(1)
82
81
  })
83
82
  })
@@ -1,6 +1,4 @@
1
- import { NodeType } from '@streamr/dht'
2
- import { hexToBinary } from '@streamr/utils'
3
- import { NodeID, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
1
+ import { DhtAddress, NodeType, getNodeIdFromPeerDescriptor, getRawFromDhtAddress } from '@streamr/dht'
4
2
  import { NodeList } from '../../src/logic/NodeList'
5
3
  import { HandshakeRpcLocal } from '../../src/logic/neighbor-discovery/HandshakeRpcLocal'
6
4
  import { InterleaveRequest, StreamPartHandshakeRequest } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
@@ -16,8 +14,8 @@ describe('HandshakeRpcLocal', () => {
16
14
  const localPeerDescriptor = createMockPeerDescriptor()
17
15
 
18
16
  let targetNeighbors: NodeList
19
- let ongoingHandshakes: Set<NodeID>
20
- let ongoingInterleaves: Set<NodeID>
17
+ let ongoingHandshakes: Set<DhtAddress>
18
+ let ongoingInterleaves: Set<DhtAddress>
21
19
  let handshakeWithInterleaving: jest.Mock
22
20
 
23
21
  beforeEach(() => {
@@ -72,10 +70,10 @@ describe('HandshakeRpcLocal', () => {
72
70
  })
73
71
 
74
72
  it('unaccepted handshake', async () => {
75
- ongoingHandshakes.add('0x2222' as NodeID)
76
- ongoingHandshakes.add('0x3333' as NodeID)
77
- ongoingHandshakes.add('0x4444' as NodeID)
78
- ongoingHandshakes.add('0x5555' as NodeID)
73
+ ongoingHandshakes.add('0x2222' as DhtAddress)
74
+ ongoingHandshakes.add('0x3333' as DhtAddress)
75
+ ongoingHandshakes.add('0x4444' as DhtAddress)
76
+ ongoingHandshakes.add('0x5555' as DhtAddress)
79
77
  const req = StreamPartHandshakeRequest.create({
80
78
  streamPartId: STREAM_PART_ID,
81
79
  requestId: 'requestId'
@@ -89,7 +87,7 @@ describe('HandshakeRpcLocal', () => {
89
87
  it('handshakeWithInterleaving success', async () => {
90
88
  const req: InterleaveRequest = {
91
89
  interleaveTargetDescriptor: {
92
- nodeId: hexToBinary('0x2222'),
90
+ nodeId: getRawFromDhtAddress('0x2222' as DhtAddress),
93
91
  type: NodeType.NODEJS
94
92
  }
95
93
  }
@@ -102,7 +100,7 @@ describe('HandshakeRpcLocal', () => {
102
100
  it('handshakeWithInterleaving success', async () => {
103
101
  const req: InterleaveRequest = {
104
102
  interleaveTargetDescriptor: {
105
- nodeId: hexToBinary('0x2222'),
103
+ nodeId: getRawFromDhtAddress('0x2222' as DhtAddress),
106
104
  type: NodeType.NODEJS
107
105
  }
108
106
  }
@@ -1,6 +1,5 @@
1
- import { ListeningRpcCommunicator, Simulator, SimulatorTransport } from '@streamr/dht'
1
+ import { ListeningRpcCommunicator, Simulator, SimulatorTransport, getNodeIdFromPeerDescriptor } from '@streamr/dht'
2
2
  import { range } from 'lodash'
3
- import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
4
3
  import { NodeList } from '../../src/logic/NodeList'
5
4
  import { Handshaker } from '../../src/logic/neighbor-discovery/Handshaker'
6
5
  import { createMockPeerDescriptor, createMockDeliveryRpcRemote, mockConnectionLocker } from '../utils/utils'
@@ -2,14 +2,14 @@ import { InspectSession, Events } from '../../src/logic/inspect/InspectSession'
2
2
  import { MessageID } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
3
3
  import { waitForEvent3 } from '../../../utils/dist/src/waitForEvent3'
4
4
  import { utf8ToBinary } from '@streamr/utils'
5
- import { NodeID } from '../../src/identifiers'
6
5
  import { createRandomNodeId } from '../utils/utils'
6
+ import { DhtAddress } from '@streamr/dht'
7
7
 
8
8
  describe('InspectSession', () => {
9
9
 
10
10
  let inspectSession: InspectSession
11
- let inspectedNode: NodeID
12
- let anotherNode: NodeID
11
+ let inspectedNode: DhtAddress
12
+ let anotherNode: DhtAddress
13
13
 
14
14
  const publisherId = utf8ToBinary('publisherId')
15
15
  const messageId1: MessageID = {
@@ -1,6 +1,5 @@
1
- import { ListeningRpcCommunicator } from '@streamr/dht'
1
+ import { ListeningRpcCommunicator, getNodeIdFromPeerDescriptor } from '@streamr/dht'
2
2
  import { utf8ToBinary } from '@streamr/utils'
3
- import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
4
3
  import { Inspector } from '../../src/logic/inspect/Inspector'
5
4
  import { MockTransport } from '../utils/mock/Transport'
6
5
  import { createMockPeerDescriptor, createRandomNodeId, mockConnectionLocker } from '../utils/utils'
@@ -4,7 +4,7 @@ import { waitForCondition } from '@streamr/utils'
4
4
  import { range } from 'lodash'
5
5
  import { expect } from 'expect'
6
6
  import { createMockDeliveryRpcRemote, createRandomNodeId } from '../utils/utils'
7
- import { NodeID, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
7
+ import { DhtAddress, getNodeIdFromPeerDescriptor } from '@streamr/dht'
8
8
 
9
9
  describe('NeighborFinder', () => {
10
10
 
@@ -19,7 +19,7 @@ describe('NeighborFinder', () => {
19
19
  targetNeighbors = new NodeList(nodeId, 15)
20
20
  nearbyNodeView = new NodeList(nodeId, 30)
21
21
  range(30).forEach(() => nearbyNodeView.add(createMockDeliveryRpcRemote()))
22
- const mockDoFindNeighbors = async (excluded: NodeID[]) => {
22
+ const mockDoFindNeighbors = async (excluded: DhtAddress[]) => {
23
23
  const target = nearbyNodeView.getRandom(excluded)
24
24
  if (Math.random() < 0.5) {
25
25
  targetNeighbors.add(target!)
@@ -4,11 +4,11 @@ import {
4
4
  PeerDescriptor,
5
5
  Simulator,
6
6
  SimulatorTransport,
7
+ getDhtAddressFromRaw,
8
+ getNodeIdFromPeerDescriptor,
7
9
  } from '@streamr/dht'
8
10
  import { StreamPartIDUtils } from '@streamr/protocol'
9
- import { binaryToHex } from '@streamr/utils'
10
11
  import { expect } from 'expect'
11
- import { NodeID, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
12
12
  import { DeliveryRpcRemote } from '../../src/logic/DeliveryRpcRemote'
13
13
  import { NodeList } from '../../src/logic/NodeList'
14
14
  import { formStreamPartDeliveryServiceId } from '../../src/logic/formStreamPartDeliveryServiceId'
@@ -39,7 +39,6 @@ describe('NodeList', () => {
39
39
  return new DeliveryRpcRemote(
40
40
  createMockPeerDescriptor(),
41
41
  peerDescriptor,
42
- streamPartId,
43
42
  mockCommunicator,
44
43
  DeliveryRpcClient
45
44
  )
@@ -100,25 +99,25 @@ describe('NodeList', () => {
100
99
  it('getClosest', () => {
101
100
  const closest = nodeList.getClosest([])
102
101
  expect(getNodeIdFromPeerDescriptor(closest!.getPeerDescriptor()))
103
- .toEqual(binaryToHex(new Uint8Array([1, 1, 1])))
102
+ .toEqual(getDhtAddressFromRaw(new Uint8Array([1, 1, 1])))
104
103
  })
105
104
 
106
105
  it('getClosest with exclude', () => {
107
- const closest = nodeList.getClosest([binaryToHex(new Uint8Array([1, 1, 1])) as unknown as NodeID])
106
+ const closest = nodeList.getClosest([getDhtAddressFromRaw(new Uint8Array([1, 1, 1]))])
108
107
  expect(getNodeIdFromPeerDescriptor(closest!.getPeerDescriptor()))
109
- .toEqual(binaryToHex(new Uint8Array([1, 1, 2])))
108
+ .toEqual(getDhtAddressFromRaw(new Uint8Array([1, 1, 2])))
110
109
  })
111
110
 
112
111
  it('getFurthest', () => {
113
112
  const closest = nodeList.getFurthest([])
114
113
  expect(getNodeIdFromPeerDescriptor(closest!.getPeerDescriptor()))
115
- .toEqual(binaryToHex(new Uint8Array([1, 1, 5])))
114
+ .toEqual(getDhtAddressFromRaw(new Uint8Array([1, 1, 5])))
116
115
  })
117
116
 
118
117
  it('getFurthest with exclude', () => {
119
- const closest = nodeList.getFurthest([binaryToHex(new Uint8Array([1, 1, 5])) as unknown as NodeID])
118
+ const closest = nodeList.getFurthest([getDhtAddressFromRaw(new Uint8Array([1, 1, 5]))])
120
119
  expect(getNodeIdFromPeerDescriptor(closest!.getPeerDescriptor()))
121
- .toEqual(binaryToHex(new Uint8Array([1, 1, 4])))
120
+ .toEqual(getDhtAddressFromRaw(new Uint8Array([1, 1, 4])))
122
121
  })
123
122
 
124
123
  it('getClosestAndFurthest', () => {
@@ -148,12 +147,12 @@ describe('NodeList', () => {
148
147
 
149
148
  it('getClosestAndFurthest with exclude', () => {
150
149
  const results = nodeList.getClosestAndFurthest([
151
- binaryToHex(new Uint8Array([1, 1, 1])) as unknown as NodeID,
152
- binaryToHex(new Uint8Array([1, 1, 5])) as unknown as NodeID
150
+ getDhtAddressFromRaw(new Uint8Array([1, 1, 1])),
151
+ getDhtAddressFromRaw(new Uint8Array([1, 1, 5]))
153
152
  ])
154
153
  expect(results).toEqual([
155
- nodeList.getClosest([binaryToHex(new Uint8Array([1, 1, 1])) as unknown as NodeID]),
156
- nodeList.getFurthest([binaryToHex(new Uint8Array([1, 1, 5])) as unknown as NodeID])
154
+ nodeList.getClosest([getDhtAddressFromRaw(new Uint8Array([1, 1, 1]))]),
155
+ nodeList.getFurthest([getDhtAddressFromRaw(new Uint8Array([1, 1, 5]))])
157
156
  ])
158
157
  })
159
158
  })
@@ -7,7 +7,7 @@ import {
7
7
  } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
8
8
  import { Propagation } from '../../src/logic/propagation/Propagation'
9
9
  import { toEthereumAddress, wait, utf8ToBinary, hexToBinary } from '@streamr/utils'
10
- import { NodeID } from '../../src/identifiers'
10
+ import { DhtAddress } from '@streamr/dht'
11
11
 
12
12
  const PUBLISHER_ID = toEthereumAddress('0x1111111111111111111111111111111111111111')
13
13
 
@@ -32,15 +32,15 @@ function makeMsg(streamId: string, partition: number, ts: number, msgNo: number)
32
32
 
33
33
  const TTL = 100
34
34
 
35
- const N1 = 'n1' as NodeID
36
- const N2 = 'n2' as NodeID
37
- const N3 = 'n3' as NodeID
38
- const N4 = 'n4' as NodeID
39
- const N5 = 'n5' as NodeID
35
+ const N1 = 'n1' as DhtAddress
36
+ const N2 = 'n2' as DhtAddress
37
+ const N3 = 'n3' as DhtAddress
38
+ const N4 = 'n4' as DhtAddress
39
+ const N5 = 'n5' as DhtAddress
40
40
 
41
41
  describe(Propagation, () => {
42
- let getNeighbors: jest.Mock<ReadonlyArray<NodeID>, [string]>
43
- let sendToNeighbor: jest.Mock<Promise<void>, [NodeID, StreamMessage]>
42
+ let getNeighbors: jest.Mock<ReadonlyArray<DhtAddress>, [string]>
43
+ let sendToNeighbor: jest.Mock<Promise<void>, [DhtAddress, StreamMessage]>
44
44
  let propagation: Propagation
45
45
 
46
46
  beforeEach(() => {
@@ -80,7 +80,7 @@ describe(Propagation, () => {
80
80
  describe('#onNeighborJoined', () => {
81
81
  let msg: StreamMessage
82
82
 
83
- async function setUpAndFeed(neighbors: NodeID[]): Promise<void> {
83
+ async function setUpAndFeed(neighbors: DhtAddress[]): Promise<void> {
84
84
  getNeighbors.mockReturnValueOnce(neighbors)
85
85
  msg = makeMsg('s1', 0, 1000, 1)
86
86
  propagation.feedUnseenMessage(msg, [...getNeighbors('s1#0')], N2)
@@ -1,5 +1,4 @@
1
1
  import { RpcCommunicator } from '@streamr/proto-rpc'
2
- import { StreamPartIDUtils } from '@streamr/protocol'
3
2
  import { randomEthereumAddress } from '@streamr/test-utils'
4
3
  import { hexToBinary } from '@streamr/utils'
5
4
  import { ProxyConnectionRpcRemote } from '../../src/logic/proxy/ProxyConnectionRpcRemote'
@@ -18,7 +17,6 @@ describe('ProxyConnectionRpcRemote', () => {
18
17
  const rpcRemote = new ProxyConnectionRpcRemote(
19
18
  clientPeerDescriptor,
20
19
  serverPeerDescriptor,
21
- StreamPartIDUtils.parse('stream#0'),
22
20
  rpcCommunicator,
23
21
  ProxyConnectionRpcClient
24
22
  )
@@ -1,5 +1,4 @@
1
1
  import { waitForCondition } from '@streamr/utils'
2
- import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
3
2
  import { NodeList } from '../../src/logic/NodeList'
4
3
  import { RandomGraphNode } from '../../src/logic/RandomGraphNode'
5
4
  import { createRandomGraphNode } from '../../src/logic/createRandomGraphNode'
@@ -10,6 +9,7 @@ import { MockNeighborUpdateManager } from '../utils/mock/MockNeighborUpdateManag
10
9
  import { MockTransport } from '../utils/mock/Transport'
11
10
  import { createMockPeerDescriptor, createMockDeliveryRpcRemote, mockConnectionLocker } from '../utils/utils'
12
11
  import { StreamPartIDUtils } from '@streamr/protocol'
12
+ import { getNodeIdFromPeerDescriptor } from '@streamr/dht'
13
13
 
14
14
  describe('RandomGraphNode', () => {
15
15