@streamr/dht 0.0.1-tatum.1 → 0.0.1-tatum.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 (89) hide show
  1. package/dist/src/connection/ConnectionManager.d.ts +6 -1
  2. package/dist/src/connection/ConnectionManager.js +21 -26
  3. package/dist/src/connection/ConnectionManager.js.map +1 -1
  4. package/dist/src/connection/ConnectivityChecker.d.ts +4 -2
  5. package/dist/src/connection/ConnectivityChecker.js +23 -19
  6. package/dist/src/connection/ConnectivityChecker.js.map +1 -1
  7. package/dist/src/connection/ManagedConnection.js +2 -6
  8. package/dist/src/connection/ManagedConnection.js.map +1 -1
  9. package/dist/src/connection/Simulator/SimulatorTransport.js +1 -1
  10. package/dist/src/connection/Simulator/SimulatorTransport.js.map +1 -1
  11. package/dist/src/connection/WebRTC/WebRtcConnector.d.ts +2 -0
  12. package/dist/src/connection/WebRTC/WebRtcConnector.js +14 -1
  13. package/dist/src/connection/WebRTC/WebRtcConnector.js.map +1 -1
  14. package/dist/src/connection/WebSocket/WebSocketConnector.d.ts +5 -3
  15. package/dist/src/connection/WebSocket/WebSocketConnector.js +19 -12
  16. package/dist/src/connection/WebSocket/WebSocketConnector.js.map +1 -1
  17. package/dist/src/connection/WebSocket/WebSocketServer.d.ts +2 -2
  18. package/dist/src/connection/WebSocket/WebSocketServer.js +29 -37
  19. package/dist/src/connection/WebSocket/WebSocketServer.js.map +1 -1
  20. package/dist/src/dht/DhtNode.d.ts +9 -6
  21. package/dist/src/dht/DhtNode.js +14 -21
  22. package/dist/src/dht/DhtNode.js.map +1 -1
  23. package/dist/src/dht/DhtPeer.js +1 -1
  24. package/dist/src/dht/discovery/PeerDiscovery.d.ts +4 -2
  25. package/dist/src/dht/discovery/PeerDiscovery.js +18 -33
  26. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
  27. package/dist/src/dht/routing/RemoteRouter.js +2 -4
  28. package/dist/src/dht/routing/RemoteRouter.js.map +1 -1
  29. package/dist/src/dht/store/DataStore.js +6 -6
  30. package/dist/src/exports.d.ts +1 -1
  31. package/dist/src/exports.js.map +1 -1
  32. package/dist/src/helpers/errors.d.ts +1 -1
  33. package/dist/src/helpers/errors.js +3 -3
  34. package/dist/src/helpers/errors.js.map +1 -1
  35. package/dist/src/helpers/protoClasses.js +0 -2
  36. package/dist/src/helpers/protoClasses.js.map +1 -1
  37. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +1 -1
  38. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +14 -50
  39. package/dist/src/proto/packages/dht/protos/DhtRpc.js +9 -35
  40. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
  41. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
  42. package/package.json +9 -9
  43. package/protos/DhtRpc.proto +7 -16
  44. package/src/connection/ConnectionManager.ts +31 -28
  45. package/src/connection/ConnectivityChecker.ts +28 -23
  46. package/src/connection/ManagedConnection.ts +2 -6
  47. package/src/connection/Simulator/SimulatorTransport.ts +1 -1
  48. package/src/connection/WebRTC/BrowserWebRtcConnection.ts +13 -2
  49. package/src/connection/WebRTC/WebRtcConnector.ts +14 -0
  50. package/src/connection/WebSocket/WebSocketConnector.ts +23 -12
  51. package/src/connection/WebSocket/WebSocketServer.ts +33 -20
  52. package/src/dht/DhtNode.ts +23 -24
  53. package/src/dht/DhtPeer.ts +1 -1
  54. package/src/dht/discovery/PeerDiscovery.ts +17 -8
  55. package/src/dht/routing/RemoteRouter.ts +2 -4
  56. package/src/dht/store/DataStore.ts +6 -6
  57. package/src/exports.ts +1 -1
  58. package/src/helpers/errors.ts +1 -1
  59. package/src/helpers/protoClasses.ts +1 -5
  60. package/src/proto/google/protobuf/any.ts +1 -1
  61. package/src/proto/google/protobuf/empty.ts +1 -1
  62. package/src/proto/google/protobuf/timestamp.ts +1 -1
  63. package/src/proto/packages/dht/protos/DhtRpc.client.ts +1 -1
  64. package/src/proto/packages/dht/protos/DhtRpc.server.ts +1 -1
  65. package/src/proto/packages/dht/protos/DhtRpc.ts +22 -69
  66. package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
  67. package/test/benchmark/KademliaCorrectness.test.ts +1 -1
  68. package/test/benchmark/RecursiveFind.test.ts +1 -1
  69. package/test/end-to-end/Layer0-Layer1.test.ts +3 -3
  70. package/test/end-to-end/Layer0.test.ts +5 -5
  71. package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +6 -6
  72. package/test/end-to-end/Layer0WebRTC-Layer1.test.ts +18 -19
  73. package/test/end-to-end/Layer0WebRTC.test.ts +18 -24
  74. package/test/end-to-end/Layer1-Scale-WebRTC.test.ts +2 -2
  75. package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +2 -2
  76. package/test/end-to-end/WebSocketConnectionRequest.test.ts +3 -3
  77. package/test/integration/ConnectionManager.test.ts +10 -9
  78. package/test/integration/DhtRpc.test.ts +2 -2
  79. package/test/integration/MigrateData.test.ts +3 -3
  80. package/test/integration/RouteMessage.test.ts +2 -2
  81. package/test/integration/ScaleDownDht.test.ts +1 -1
  82. package/test/integration/SimultaneousConnections.test.ts +9 -6
  83. package/test/integration/WebRtcConnectionManagement.test.ts +2 -2
  84. package/test/integration/WebRtcConnectorRpc.test.ts +2 -2
  85. package/test/integration/WebSocketConnectionManagement.test.ts +3 -2
  86. package/test/integration/WebSocketConnectorRpc.test.ts +4 -4
  87. package/test/unit/WebSocketServer.test.ts +1 -8
  88. package/test/unit/webrtcReplaceInternalIpWithExternalIp.ts +18 -0
  89. package/test/utils/utils.ts +1 -2
@@ -35,10 +35,10 @@ describe('WebRTC Connection Management', () => {
35
35
  simulator = new Simulator(LatencyType.FIXED, 500)
36
36
 
37
37
  connectorTransport1 = new SimulatorTransport(peerDescriptor1, simulator)
38
- manager1 = new ConnectionManager({ transportLayer: connectorTransport1, nodeName: peerDescriptor1.nodeName })
38
+ manager1 = new ConnectionManager({ transportLayer: connectorTransport1 })
39
39
 
40
40
  connectorTransport2 = new SimulatorTransport(peerDescriptor2, simulator)
41
- manager2 = new ConnectionManager({ transportLayer: connectorTransport2, nodeName: peerDescriptor2.nodeName })
41
+ manager2 = new ConnectionManager({ transportLayer: connectorTransport2 })
42
42
 
43
43
  await manager1.start((_msg) => peerDescriptor1)
44
44
  await manager2.start((_msg) => peerDescriptor2)
@@ -88,8 +88,8 @@ describe('WebRTC rpc messages', () => {
88
88
  })
89
89
 
90
90
  afterEach(async () => {
91
- await rpcCommunicator1.stop()
92
- await rpcCommunicator2.stop()
91
+ rpcCommunicator1.stop()
92
+ rpcCommunicator2.stop()
93
93
  })
94
94
 
95
95
  it('send connectionRequest', async () => {
@@ -22,8 +22,9 @@ describe('WebSocket Connection Management', () => {
22
22
  kademliaId: PeerID.fromString('peerWithServer').value,
23
23
  type: NodeType.NODEJS,
24
24
  websocket: {
25
- ip: '127.0.0.1',
26
- port: 12223
25
+ host: '127.0.0.1',
26
+ port: 12223,
27
+ tls: false
27
28
  }
28
29
  }
29
30
 
@@ -57,8 +57,8 @@ describe('WebSocketConnectorRpc', () => {
57
57
  })
58
58
 
59
59
  afterEach(async () => {
60
- await rpcCommunicator1.stop()
61
- await rpcCommunicator2.stop()
60
+ rpcCommunicator1.stop()
61
+ rpcCommunicator2.stop()
62
62
  })
63
63
 
64
64
  it('Happy path', async () => {
@@ -71,7 +71,7 @@ describe('WebSocketConnectorRpc', () => {
71
71
  { targetDescriptor: peerDescriptor2 },
72
72
  )
73
73
  const res1 = await response1
74
- await (expect(res1.accepted)).toEqual(true)
74
+ expect(res1.accepted).toEqual(true)
75
75
 
76
76
  const response2 = client2.requestConnection({
77
77
  requester: peerDescriptor2,
@@ -82,6 +82,6 @@ describe('WebSocketConnectorRpc', () => {
82
82
  { targetDescriptor: peerDescriptor1 },
83
83
  )
84
84
  const res2 = await response2
85
- await (expect(res2.accepted)).toEqual(true)
85
+ expect(res2.accepted).toEqual(true)
86
86
  })
87
87
  })
@@ -2,14 +2,7 @@ import { WebSocketServer } from '../../src/connection/WebSocket/WebSocketServer'
2
2
 
3
3
  describe('WebSocketServer', () => {
4
4
 
5
- it('starts and stops with host "127.0.0.1"', async () => {
6
- const server = new WebSocketServer()
7
- const port = await server.start({ min: 19792, max: 19792 }, '127.0.0.1')
8
- expect(port).toEqual(19792)
9
- await server.stop()
10
- })
11
-
12
- it('starts and stops if no host given', async () => {
5
+ it('starts and stops', async () => {
13
6
  const server = new WebSocketServer()
14
7
  const port = await server.start({ min: 19792, max: 19792 })
15
8
  expect(port).toEqual(19792)
@@ -0,0 +1,18 @@
1
+ import { replaceInternalIpWithExternalIp } from '../../src/connection/WebRTC/WebRtcConnector'
2
+
3
+ describe('replaceIpIfCandidateTypeIsHost', () => {
4
+
5
+ const hostCandidate = 'candidate:1 1 UDP 2013266431 127.0.0.1 30000 typ host'
6
+ const srflxCandidate = 'candidate:1 1 UDP 2013266431 127.0.0.1 30000 typ srflx'
7
+
8
+ it('replaces ip if candidate type is host', () => {
9
+ const replaced = replaceInternalIpWithExternalIp(hostCandidate, '0.0.0.0')
10
+ expect(replaced).toEqual('candidate:1 1 UDP 2013266431 0.0.0.0 30000 typ host')
11
+ })
12
+
13
+ it('does not replace candidate if type is not host', () => {
14
+ const replaced = replaceInternalIpWithExternalIp(srflxCandidate, '0.0.0.0')
15
+ expect(replaced).toEqual(srflxCandidate)
16
+ })
17
+
18
+ })
@@ -66,8 +66,7 @@ export const createMockConnectionDhtNode = async (stringId: string,
66
66
 
67
67
  const mockConnectionManager = new ConnectionManager({
68
68
  ownPeerDescriptor: peerDescriptor,
69
- simulator: simulator,
70
- nodeName: nodeName ? nodeName : stringId
69
+ simulator: simulator
71
70
  })
72
71
 
73
72
  const node = new DhtNode({