@streamr/dht 0.0.1-tatum.5 → 0.0.1-tatum.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/connection/ConnectionLockHandler.d.ts +1 -1
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +17 -39
- package/dist/src/connection/ConnectionManager.js +138 -192
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.js +14 -11
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +49 -0
- package/dist/src/connection/ConnectorFacade.js +86 -0
- package/dist/src/connection/ConnectorFacade.js.map +1 -0
- package/dist/src/connection/ManagedConnection.d.ts +1 -4
- package/dist/src/connection/ManagedConnection.js +23 -31
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/RemoteConnectionLocker.js +4 -3
- package/dist/src/connection/RemoteConnectionLocker.js.map +1 -1
- package/dist/src/connection/Simulator/Simulator.d.ts +0 -2
- package/dist/src/connection/Simulator/Simulator.js +0 -5
- package/dist/src/connection/Simulator/Simulator.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorConnection.js +16 -13
- package/dist/src/connection/Simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorConnector.d.ts +2 -2
- package/dist/src/connection/Simulator/SimulatorConnector.js +10 -11
- package/dist/src/connection/Simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js +6 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js.map +1 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.d.ts +2 -0
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js +12 -12
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +1 -1
- package/dist/src/connection/WebRTC/WebRtcConnector.d.ts +9 -9
- package/dist/src/connection/WebRTC/WebRtcConnector.js +22 -22
- package/dist/src/connection/WebRTC/WebRtcConnector.js.map +1 -1
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js +2 -1
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js.map +1 -1
- package/dist/src/connection/WebSocket/WebSocketConnector.d.ts +19 -8
- package/dist/src/connection/WebSocket/WebSocketConnector.js +67 -46
- package/dist/src/connection/WebSocket/WebSocketConnector.js.map +1 -1
- package/dist/src/connection/WebSocket/WebSocketServer.d.ts +11 -1
- package/dist/src/connection/WebSocket/WebSocketServer.js +15 -10
- package/dist/src/connection/WebSocket/WebSocketServer.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +16 -54
- package/dist/src/dht/DhtNode.js +116 -137
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/{DhtPeer.d.ts → RemoteDhtNode.d.ts} +3 -2
- package/dist/src/dht/{DhtPeer.js → RemoteDhtNode.js} +22 -16
- package/dist/src/dht/RemoteDhtNode.js.map +1 -0
- package/dist/src/dht/contact/Contact.d.ts +1 -15
- package/dist/src/dht/contact/Contact.js +1 -9
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/ContactList.d.ts +13 -3
- package/dist/src/dht/contact/ContactList.js +9 -4
- package/dist/src/dht/contact/ContactList.js.map +1 -1
- package/dist/src/dht/contact/RandomContactList.d.ts +3 -3
- package/dist/src/dht/contact/RandomContactList.js +4 -8
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/Remote.d.ts +1 -5
- package/dist/src/dht/contact/Remote.js +0 -5
- package/dist/src/dht/contact/Remote.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +3 -5
- package/dist/src/dht/contact/SortedContactList.js +9 -19
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +5 -7
- package/dist/src/dht/discovery/DiscoverySession.js +9 -10
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +11 -10
- package/dist/src/dht/discovery/PeerDiscovery.js +32 -37
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/find/RecursiveFindSession.d.ts +5 -6
- package/dist/src/dht/find/RecursiveFindSession.js +8 -8
- package/dist/src/dht/find/RecursiveFindSession.js.map +1 -1
- package/dist/src/dht/find/RecursiveFinder.d.ts +2 -4
- package/dist/src/dht/find/RecursiveFinder.js +11 -12
- package/dist/src/dht/find/RecursiveFinder.js.map +1 -1
- package/dist/src/dht/registerExternalApiRpcMethods.d.ts +1 -1
- package/dist/src/dht/routing/DuplicateDetector.d.ts +1 -2
- package/dist/src/dht/routing/DuplicateDetector.js +2 -7
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
- package/dist/src/dht/routing/RemoteRouter.js +4 -4
- package/dist/src/dht/routing/RemoteRouter.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +10 -13
- package/dist/src/dht/routing/Router.js +28 -29
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +3 -5
- package/dist/src/dht/routing/RoutingSession.js +19 -13
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/DataStore.d.ts +2 -2
- package/dist/src/dht/store/DataStore.js +7 -7
- package/dist/src/dht/store/DataStore.js.map +1 -1
- package/dist/src/exports.d.ts +1 -8
- package/dist/src/exports.js +2 -16
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/PeerID.d.ts +0 -1
- package/dist/src/helpers/PeerID.js +0 -6
- package/dist/src/helpers/PeerID.js.map +1 -1
- package/dist/src/helpers/browser/isBrowserEnvironment.d.ts +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment.js +6 -0
- package/dist/src/helpers/browser/isBrowserEnvironment.js.map +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.d.ts +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.js +7 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.js.map +1 -0
- package/dist/src/helpers/kademliaId.d.ts +1 -0
- package/dist/src/helpers/kademliaId.js +14 -0
- package/dist/src/helpers/kademliaId.js.map +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +1 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +3 -3
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +0 -4
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +1 -2
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/package.json +10 -9
- package/protos/DhtRpc.proto +0 -1
- package/src/connection/ConnectionLockHandler.ts +1 -1
- package/src/connection/ConnectionManager.ts +156 -240
- package/src/connection/ConnectivityChecker.ts +14 -11
- package/src/connection/ConnectorFacade.ts +143 -0
- package/src/connection/ManagedConnection.ts +23 -34
- package/src/connection/RemoteConnectionLocker.ts +4 -3
- package/src/connection/Simulator/Simulator.ts +0 -7
- package/src/connection/Simulator/SimulatorConnection.ts +16 -13
- package/src/connection/Simulator/SimulatorConnector.ts +11 -12
- package/src/connection/Simulator/SimulatorTransport.ts +6 -1
- package/src/connection/WebRTC/NodeWebRtcConnection.ts +14 -13
- package/src/connection/WebRTC/WebRtcConnector.ts +31 -31
- package/src/connection/WebSocket/RemoteWebSocketConnector.ts +2 -1
- package/src/connection/WebSocket/WebSocketConnector.ts +85 -62
- package/src/connection/WebSocket/WebSocketServer.ts +26 -8
- package/src/dht/DhtNode.ts +164 -189
- package/src/dht/{DhtPeer.ts → RemoteDhtNode.ts} +14 -7
- package/src/dht/contact/Contact.ts +1 -18
- package/src/dht/contact/ContactList.ts +16 -6
- package/src/dht/contact/RandomContactList.ts +6 -11
- package/src/dht/contact/Remote.ts +1 -10
- package/src/dht/contact/SortedContactList.ts +12 -25
- package/src/dht/discovery/DiscoverySession.ts +20 -23
- package/src/dht/discovery/PeerDiscovery.ts +45 -44
- package/src/dht/find/RecursiveFindSession.ts +12 -13
- package/src/dht/find/RecursiveFinder.ts +16 -19
- package/src/dht/registerExternalApiRpcMethods.ts +1 -1
- package/src/dht/routing/DuplicateDetector.ts +3 -10
- package/src/dht/routing/RemoteRouter.ts +5 -5
- package/src/dht/routing/Router.ts +35 -39
- package/src/dht/routing/RoutingSession.ts +37 -28
- package/src/dht/store/DataStore.ts +11 -11
- package/src/exports.ts +1 -8
- package/src/helpers/PeerID.ts +0 -7
- package/src/helpers/browser/isBrowserEnvironment.ts +1 -0
- package/src/helpers/browser/isBrowserEnvironment_override.ts +3 -0
- package/src/helpers/kademliaId.ts +8 -0
- package/src/helpers/peerIdFromPeerDescriptor.ts +1 -1
- package/src/proto/packages/dht/protos/DhtRpc.ts +1 -6
- package/test/benchmark/KademliaCorrectness.test.ts +5 -2
- package/test/benchmark/RecursiveFind.test.ts +6 -6
- package/test/end-to-end/Layer0-Layer1.test.ts +14 -14
- package/test/end-to-end/Layer0WebRTC-Layer1.test.ts +5 -5
- package/test/end-to-end/Layer0WebRTC.test.ts +5 -6
- package/test/end-to-end/Layer1-Scale-WebRTC.test.ts +13 -8
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +15 -10
- package/test/end-to-end/WebSocketConnectionRequest.test.ts +5 -5
- package/test/integration/ConnectionLocking.test.ts +32 -26
- package/test/integration/ConnectionManager.test.ts +90 -93
- package/test/integration/DhtJoinPeerDiscovery.test.ts +53 -0
- package/test/integration/DhtRpc.test.ts +4 -6
- package/test/integration/Layer1-scale.test.ts +8 -8
- package/test/integration/MigrateData.test.ts +9 -9
- package/test/integration/Mock-Layer1-Layer0.test.ts +1 -2
- package/test/integration/RecursiveFind.test.ts +5 -5
- package/test/integration/{DhtPeer.test.ts → RemoteDhtNode.test.ts} +11 -12
- package/test/integration/RemoteRouter.test.ts +5 -6
- package/test/integration/RemoteStore.test.ts +4 -5
- package/test/integration/RouteMessage.test.ts +7 -9
- package/test/integration/RpcErrors.test.ts +25 -10
- package/test/integration/ScaleDownDht.test.ts +8 -8
- package/test/integration/SimultaneousConnections.test.ts +35 -36
- package/test/integration/Store.test.ts +8 -9
- package/test/integration/StoreAndDelete.test.ts +11 -11
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +7 -7
- package/test/integration/WebRtcConnectionManagement.test.ts +26 -19
- package/test/integration/WebRtcConnectorRpc.test.ts +6 -8
- package/test/integration/WebSocket.test.ts +4 -2
- package/test/integration/WebSocketConnectionManagement.test.ts +30 -17
- package/test/integration/WebSocketConnectorRpc.test.ts +2 -3
- package/test/unit/DuplicateDetector.test.ts +3 -4
- package/test/unit/LocalDataStore.test.ts +6 -8
- package/test/unit/RandomContactList.test.ts +25 -74
- package/test/unit/RecursiveFinder.test.ts +8 -12
- package/test/unit/Router.test.ts +18 -21
- package/test/unit/SortedContactList.test.ts +62 -112
- package/test/unit/WebSocketConnector.test.ts +64 -0
- package/test/unit/WebSocketServer.test.ts +24 -12
- package/test/utils/mock/RecursiveFinder.ts +2 -2
- package/test/utils/mock/Router.ts +9 -11
- package/test/utils/mock/Transport.ts +2 -2
- package/test/utils/utils.ts +40 -49
- package/dist/src/dht/DhtPeer.js.map +0 -1
- package/dist/src/helpers/browser/isBrowser.d.ts +0 -1
- package/dist/src/helpers/browser/isBrowser.js +0 -6
- package/dist/src/helpers/browser/isBrowser.js.map +0 -1
- package/dist/src/helpers/browser/isNodeJS.d.ts +0 -1
- package/dist/src/helpers/browser/isNodeJS.js +0 -6
- package/dist/src/helpers/browser/isNodeJS.js.map +0 -1
- package/src/helpers/browser/isBrowser.ts +0 -1
- package/src/helpers/browser/isNodeJS.ts +0 -1
- package/test/integration/DhtWithMockConnectionLatencies.test.ts +0 -46
- package/test/integration/DhtWithMockConnections.test.ts +0 -46
- package/test/integration/DhtWithRealConnectionLatencies.test.ts +0 -47
- /package/test/unit/{webrtcReplaceInternalIpWithExternalIp.ts → webrtcReplaceInternalIpWithExternalIp.test.ts} +0 -0
|
@@ -4,7 +4,7 @@ import { Simulator } from '../../src/connection/Simulator/Simulator'
|
|
|
4
4
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
5
5
|
import { Any } from '../../src/proto/google/protobuf/any'
|
|
6
6
|
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
7
|
-
import {
|
|
7
|
+
import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
8
8
|
import { waitForCondition } from '@streamr/utils'
|
|
9
9
|
|
|
10
10
|
describe('Storing data in DHT with two peers', () => {
|
|
@@ -48,13 +48,13 @@ describe('Storing data in DHT with two peers', () => {
|
|
|
48
48
|
|
|
49
49
|
const successfulStorers1 = await otherNode.storeDataToDht(dataKey1.value, data1)
|
|
50
50
|
const successfulStorers2 = await entryPoint.storeDataToDht(dataKey2.value, data2)
|
|
51
|
-
expect(successfulStorers1[0].
|
|
52
|
-
expect(successfulStorers2[0].
|
|
51
|
+
expect(successfulStorers1[0].kademliaId).toStrictEqual(entryPoint.getPeerDescriptor().kademliaId)
|
|
52
|
+
expect(successfulStorers2[0].kademliaId).toStrictEqual(otherNode.getPeerDescriptor().kademliaId)
|
|
53
53
|
|
|
54
54
|
const foundData1 = await otherNode.getDataFromDht(dataKey1.value)
|
|
55
55
|
const foundData2 = await entryPoint.getDataFromDht(dataKey2.value)
|
|
56
|
-
expect(
|
|
57
|
-
expect(
|
|
56
|
+
expect(areEqualPeerDescriptors(otherNode.getPeerDescriptor(), Any.unpack(foundData1[0]!.data!, PeerDescriptor))).toBeTrue()
|
|
57
|
+
expect(areEqualPeerDescriptors(entryPoint.getPeerDescriptor(), Any.unpack(foundData2[0]!.data!, PeerDescriptor))).toBeTrue()
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
it('Can store on one peer DHT', async () => {
|
|
@@ -63,9 +63,9 @@ describe('Storing data in DHT with two peers', () => {
|
|
|
63
63
|
const dataKey = PeerID.fromString('data-to-store')
|
|
64
64
|
const data = Any.pack(entryPoint.getPeerDescriptor(), PeerDescriptor)
|
|
65
65
|
const successfulStorers = await entryPoint.storeDataToDht(dataKey.value, data)
|
|
66
|
-
expect(successfulStorers[0].
|
|
66
|
+
expect(successfulStorers[0].kademliaId).toStrictEqual(entryPoint.getPeerDescriptor().kademliaId)
|
|
67
67
|
|
|
68
68
|
const foundData = await entryPoint.getDataFromDht(dataKey.value)
|
|
69
|
-
expect(
|
|
69
|
+
expect(areEqualPeerDescriptors(entryPoint.getPeerDescriptor(), Any.unpack(foundData[0]!.data!, PeerDescriptor))).toBeTrue()
|
|
70
70
|
}, 60000)
|
|
71
71
|
})
|
|
@@ -6,7 +6,19 @@ import { PeerID } from '../../src/helpers/PeerID'
|
|
|
6
6
|
import { ConnectionType } from '../../src/connection/IConnection'
|
|
7
7
|
import { ITransport } from '../../src/transport/ITransport'
|
|
8
8
|
import * as Err from '../../src/helpers/errors'
|
|
9
|
-
import { SimulatorTransport } from '../../src/
|
|
9
|
+
import { SimulatorTransport } from '../../src/connection/Simulator/SimulatorTransport'
|
|
10
|
+
import { DefaultConnectorFacade } from '../../src/connection/ConnectorFacade'
|
|
11
|
+
import { MetricsContext } from '@streamr/utils'
|
|
12
|
+
|
|
13
|
+
const createConnectionManager = (ownPeerDescriptor: PeerDescriptor, transport: ITransport) => {
|
|
14
|
+
return new ConnectionManager({
|
|
15
|
+
createConnectorFacade: () => new DefaultConnectorFacade({
|
|
16
|
+
transport,
|
|
17
|
+
createOwnPeerDescriptor: () => ownPeerDescriptor
|
|
18
|
+
}),
|
|
19
|
+
metricsContext: new MetricsContext()
|
|
20
|
+
})
|
|
21
|
+
}
|
|
10
22
|
|
|
11
23
|
describe('WebRTC Connection Management', () => {
|
|
12
24
|
|
|
@@ -17,32 +29,27 @@ describe('WebRTC Connection Management', () => {
|
|
|
17
29
|
|
|
18
30
|
const peerDescriptor1: PeerDescriptor = {
|
|
19
31
|
kademliaId: PeerID.fromString('peer1').value,
|
|
20
|
-
nodeName: 'peer1',
|
|
21
32
|
type: NodeType.NODEJS,
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
const peerDescriptor2: PeerDescriptor = {
|
|
25
36
|
kademliaId: PeerID.fromString('peer2').value,
|
|
26
|
-
nodeName: 'peer2',
|
|
27
37
|
type: NodeType.NODEJS,
|
|
28
38
|
}
|
|
29
39
|
|
|
30
|
-
let connectorTransport1:
|
|
31
|
-
let connectorTransport2:
|
|
40
|
+
let connectorTransport1: SimulatorTransport
|
|
41
|
+
let connectorTransport2: SimulatorTransport
|
|
32
42
|
|
|
33
43
|
beforeEach(async () => {
|
|
34
|
-
|
|
35
44
|
simulator = new Simulator(LatencyType.FIXED, 500)
|
|
36
|
-
|
|
37
45
|
connectorTransport1 = new SimulatorTransport(peerDescriptor1, simulator)
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
await connectorTransport1.start()
|
|
47
|
+
manager1 = createConnectionManager(peerDescriptor1, connectorTransport1)
|
|
40
48
|
connectorTransport2 = new SimulatorTransport(peerDescriptor2, simulator)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
await manager1.start(
|
|
44
|
-
await manager2.start(
|
|
45
|
-
|
|
49
|
+
await connectorTransport2.start()
|
|
50
|
+
manager2 = createConnectionManager(peerDescriptor2, connectorTransport2)
|
|
51
|
+
await manager1.start()
|
|
52
|
+
await manager2.start()
|
|
46
53
|
})
|
|
47
54
|
|
|
48
55
|
afterEach(async () => {
|
|
@@ -138,26 +145,26 @@ describe('WebRTC Connection Management', () => {
|
|
|
138
145
|
})
|
|
139
146
|
|
|
140
147
|
const connectedPromise1 = new Promise<void>((resolve, _reject) => {
|
|
141
|
-
manager1.on('connected', (
|
|
148
|
+
manager1.on('connected', () => {
|
|
142
149
|
//expect(message.messageType).toBe(MessageType.RPC)
|
|
143
150
|
resolve()
|
|
144
151
|
})
|
|
145
152
|
})
|
|
146
153
|
|
|
147
154
|
const connectedPromise2 = new Promise<void>((resolve, _reject) => {
|
|
148
|
-
manager2.on('connected', (
|
|
155
|
+
manager2.on('connected', () => {
|
|
149
156
|
resolve()
|
|
150
157
|
})
|
|
151
158
|
})
|
|
152
159
|
|
|
153
160
|
const disconnectedPromise1 = new Promise<void>((resolve, _reject) => {
|
|
154
|
-
manager1.on('disconnected', (
|
|
161
|
+
manager1.on('disconnected', () => {
|
|
155
162
|
resolve()
|
|
156
163
|
})
|
|
157
164
|
})
|
|
158
165
|
|
|
159
166
|
const disconnectedPromise2 = new Promise<void>((resolve, _reject) => {
|
|
160
|
-
manager2.on('disconnected', (
|
|
167
|
+
manager2.on('disconnected', () => {
|
|
161
168
|
resolve()
|
|
162
169
|
})
|
|
163
170
|
})
|
|
@@ -186,7 +193,7 @@ describe('WebRTC Connection Management', () => {
|
|
|
186
193
|
}
|
|
187
194
|
|
|
188
195
|
const disconnectedPromise1 = new Promise<void>((resolve, _reject) => {
|
|
189
|
-
manager1.on('disconnected', (
|
|
196
|
+
manager1.on('disconnected', () => {
|
|
190
197
|
resolve()
|
|
191
198
|
})
|
|
192
199
|
})
|
|
@@ -11,8 +11,6 @@ import {
|
|
|
11
11
|
import { Empty } from '../../src/proto/google/protobuf/empty'
|
|
12
12
|
import { generateId } from '../utils/utils'
|
|
13
13
|
import { IWebRtcConnectorService } from '../../src/proto/packages/dht/protos/DhtRpc.server'
|
|
14
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
15
|
-
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
16
14
|
import { waitForCondition } from '@streamr/utils'
|
|
17
15
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
18
16
|
|
|
@@ -45,25 +43,25 @@ describe('WebRTC rpc messages', () => {
|
|
|
45
43
|
rpcCommunicator1 = new RpcCommunicator()
|
|
46
44
|
const serverFunctions: IWebRtcConnectorService = {
|
|
47
45
|
|
|
48
|
-
requestConnection: async (
|
|
46
|
+
requestConnection: async (): Promise<Empty> => {
|
|
49
47
|
requestConnectionCounter += 1
|
|
50
48
|
const res: Empty = {}
|
|
51
49
|
return res
|
|
52
50
|
},
|
|
53
51
|
|
|
54
|
-
rtcOffer: async (
|
|
52
|
+
rtcOffer: async (): Promise<Empty> => {
|
|
55
53
|
rtcOfferCounter += 1
|
|
56
54
|
const res: Empty = {}
|
|
57
55
|
return res
|
|
58
56
|
},
|
|
59
57
|
|
|
60
|
-
rtcAnswer: async (
|
|
58
|
+
rtcAnswer: async (): Promise<Empty> => {
|
|
61
59
|
rtcAnswerCounter += 1
|
|
62
60
|
const res: Empty = {}
|
|
63
61
|
return res
|
|
64
62
|
},
|
|
65
63
|
|
|
66
|
-
iceCandidate: async (
|
|
64
|
+
iceCandidate: async (): Promise<Empty> => {
|
|
67
65
|
iceCandidateCounter += 1
|
|
68
66
|
const res: Empty = {}
|
|
69
67
|
return res
|
|
@@ -76,11 +74,11 @@ describe('WebRTC rpc messages', () => {
|
|
|
76
74
|
rpcCommunicator2.registerRpcNotification(IceCandidate, 'iceCandidate', serverFunctions.iceCandidate)
|
|
77
75
|
rpcCommunicator2.registerRpcNotification(WebRtcConnectionRequest, 'requestConnection', serverFunctions.requestConnection)
|
|
78
76
|
|
|
79
|
-
rpcCommunicator1.on('outgoingMessage', (message: RpcMessage
|
|
77
|
+
rpcCommunicator1.on('outgoingMessage', (message: RpcMessage) => {
|
|
80
78
|
rpcCommunicator2.handleIncomingMessage(message)
|
|
81
79
|
})
|
|
82
80
|
|
|
83
|
-
rpcCommunicator2.on('outgoingMessage', (message: RpcMessage
|
|
81
|
+
rpcCommunicator2.on('outgoingMessage', (message: RpcMessage) => {
|
|
84
82
|
rpcCommunicator1.handleIncomingMessage(message)
|
|
85
83
|
})
|
|
86
84
|
|
|
@@ -9,11 +9,13 @@ const logger = new Logger(module)
|
|
|
9
9
|
|
|
10
10
|
describe('WebSocket', () => {
|
|
11
11
|
|
|
12
|
-
const webSocketServer = new WebSocketServer(
|
|
12
|
+
const webSocketServer = new WebSocketServer({
|
|
13
|
+
portRange: { min: 9999, max: 9999 }
|
|
14
|
+
})
|
|
13
15
|
const clientWebSocket = new ClientWebSocket()
|
|
14
16
|
|
|
15
17
|
beforeAll(async () => {
|
|
16
|
-
await webSocketServer.start(
|
|
18
|
+
await webSocketServer.start()
|
|
17
19
|
})
|
|
18
20
|
|
|
19
21
|
it('Happy path', (done) => {
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
/* eslint-disable promise/no-nesting */
|
|
2
2
|
|
|
3
|
+
import { MetricsContext, waitForCondition } from '@streamr/utils'
|
|
3
4
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
5
|
+
import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../../src/connection/ConnectorFacade'
|
|
6
|
+
import { ConnectionType } from '../../src/connection/IConnection'
|
|
4
7
|
import { Simulator } from '../../src/connection/Simulator/Simulator'
|
|
5
|
-
import {
|
|
8
|
+
import { SimulatorTransport } from '../../src/exports'
|
|
6
9
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
7
|
-
import { ConnectionType } from '../../src/connection/IConnection'
|
|
8
|
-
import { ITransport } from '../../src/transport/ITransport'
|
|
9
10
|
import * as Err from '../../src/helpers/errors'
|
|
10
|
-
import {
|
|
11
|
+
import { Message, MessageType, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
11
12
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
12
13
|
|
|
14
|
+
const createConfig = (ownPeerDescriptor: PeerDescriptor, opts: Omit<DefaultConnectorFacadeConfig, 'createOwnPeerDescriptor'>) => {
|
|
15
|
+
return {
|
|
16
|
+
createConnectorFacade: () => new DefaultConnectorFacade({
|
|
17
|
+
createOwnPeerDescriptor: () => ownPeerDescriptor,
|
|
18
|
+
...opts
|
|
19
|
+
}),
|
|
20
|
+
metricsContext: new MetricsContext()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
13
24
|
describe('WebSocket Connection Management', () => {
|
|
14
25
|
|
|
15
26
|
const serviceId = 'test'
|
|
@@ -33,28 +44,30 @@ describe('WebSocket Connection Management', () => {
|
|
|
33
44
|
type: NodeType.NODEJS,
|
|
34
45
|
}
|
|
35
46
|
|
|
36
|
-
let connectorTransport1:
|
|
37
|
-
let connectorTransport2:
|
|
47
|
+
let connectorTransport1: SimulatorTransport
|
|
48
|
+
let connectorTransport2: SimulatorTransport
|
|
38
49
|
|
|
39
50
|
beforeEach(async () => {
|
|
40
51
|
|
|
41
|
-
connectorTransport1 = new
|
|
42
|
-
|
|
52
|
+
connectorTransport1 = new SimulatorTransport(wsServerConnectorPeerDescriptor, simulator)
|
|
53
|
+
await connectorTransport1.start()
|
|
54
|
+
connectorTransport2 = new SimulatorTransport(noWsServerConnectorPeerDescriptor, simulator)
|
|
55
|
+
await connectorTransport2.start()
|
|
43
56
|
|
|
44
|
-
const config1 = {
|
|
45
|
-
|
|
57
|
+
const config1 = createConfig(wsServerConnectorPeerDescriptor, {
|
|
58
|
+
transport: connectorTransport1,
|
|
46
59
|
websocketHost: '127.0.0.1',
|
|
47
|
-
websocketPortRange: { min: 12223, max: 12223 }
|
|
48
|
-
}
|
|
49
|
-
const config2 = {
|
|
50
|
-
|
|
51
|
-
}
|
|
60
|
+
websocketPortRange: { min: 12223, max: 12223 }
|
|
61
|
+
})
|
|
62
|
+
const config2 = createConfig(noWsServerConnectorPeerDescriptor, {
|
|
63
|
+
transport: connectorTransport2
|
|
64
|
+
})
|
|
52
65
|
|
|
53
66
|
wsServerManager = new ConnectionManager(config1)
|
|
54
67
|
noWsServerManager = new ConnectionManager(config2)
|
|
55
68
|
|
|
56
|
-
await wsServerManager.start(
|
|
57
|
-
await noWsServerManager.start(
|
|
69
|
+
await wsServerManager.start()
|
|
70
|
+
await noWsServerManager.start()
|
|
58
71
|
})
|
|
59
72
|
|
|
60
73
|
afterEach(async () => {
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
WebSocketConnectionResponse
|
|
9
9
|
} from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
10
10
|
import { MockWebSocketConnectorRpc } from '../utils/utils'
|
|
11
|
-
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
12
11
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
13
12
|
|
|
14
13
|
describe('WebSocketConnectorRpc', () => {
|
|
@@ -44,11 +43,11 @@ describe('WebSocketConnectorRpc', () => {
|
|
|
44
43
|
MockWebSocketConnectorRpc.requestConnection
|
|
45
44
|
)
|
|
46
45
|
|
|
47
|
-
rpcCommunicator1.on('outgoingMessage', (message: RpcMessage
|
|
46
|
+
rpcCommunicator1.on('outgoingMessage', (message: RpcMessage) => {
|
|
48
47
|
rpcCommunicator2.handleIncomingMessage(message)
|
|
49
48
|
})
|
|
50
49
|
|
|
51
|
-
rpcCommunicator2.on('outgoingMessage', (message: RpcMessage
|
|
50
|
+
rpcCommunicator2.on('outgoingMessage', (message: RpcMessage) => {
|
|
52
51
|
rpcCommunicator1.handleIncomingMessage(message)
|
|
53
52
|
})
|
|
54
53
|
|
|
@@ -3,25 +3,24 @@ import { DuplicateDetector } from '../../src/dht/routing/DuplicateDetector'
|
|
|
3
3
|
describe('Duplicate Detector', () => {
|
|
4
4
|
let detector: DuplicateDetector
|
|
5
5
|
const maxLimit = 10
|
|
6
|
-
const senderId = 'sender'
|
|
7
6
|
beforeEach(async () => {
|
|
8
7
|
detector = new DuplicateDetector(maxLimit, 100)
|
|
9
8
|
})
|
|
10
9
|
|
|
11
10
|
it('detects duplicates', async () => {
|
|
12
|
-
detector.add('test'
|
|
11
|
+
detector.add('test')
|
|
13
12
|
expect(detector.size()).toEqual(1)
|
|
14
13
|
expect(detector.isMostLikelyDuplicate('test')).toEqual(true)
|
|
15
14
|
})
|
|
16
15
|
|
|
17
16
|
it('resets on resetLimit', () => {
|
|
18
17
|
for (let i = 0; i < maxLimit; i++) {
|
|
19
|
-
detector.add(`test${i}
|
|
18
|
+
detector.add(`test${i}`)
|
|
20
19
|
}
|
|
21
20
|
for (let i = 0; i < maxLimit; i++) {
|
|
22
21
|
expect(detector.isMostLikelyDuplicate(`test${i}`)).toEqual(true)
|
|
23
22
|
}
|
|
24
|
-
detector.add('test10'
|
|
23
|
+
detector.add('test10')
|
|
25
24
|
expect(detector.size()).toEqual(10)
|
|
26
25
|
expect(detector.isMostLikelyDuplicate('test0')).toEqual(false)
|
|
27
26
|
expect(detector.isMostLikelyDuplicate('test10')).toEqual(true)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Any } from '../../src/proto/google/protobuf/any'
|
|
2
2
|
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
areEqualPeerDescriptors,
|
|
5
5
|
keyFromPeerDescriptor,
|
|
6
6
|
peerIdFromPeerDescriptor
|
|
7
7
|
} from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
@@ -13,13 +13,11 @@ describe('LocalDataStore', () => {
|
|
|
13
13
|
let localDataStore: LocalDataStore
|
|
14
14
|
const storer1: PeerDescriptor = {
|
|
15
15
|
kademliaId: new Uint8Array([1, 2, 3]),
|
|
16
|
-
type: NodeType.NODEJS
|
|
17
|
-
nodeName: 'storer1'
|
|
16
|
+
type: NodeType.NODEJS
|
|
18
17
|
}
|
|
19
18
|
const storer2: PeerDescriptor = {
|
|
20
19
|
kademliaId: new Uint8Array([3, 2, 1]),
|
|
21
|
-
type: NodeType.NODEJS
|
|
22
|
-
nodeName: 'storer2'
|
|
20
|
+
type: NodeType.NODEJS
|
|
23
21
|
}
|
|
24
22
|
const data1 = Any.pack(storer1, PeerDescriptor)
|
|
25
23
|
const data2 = Any.pack(storer2, PeerDescriptor)
|
|
@@ -39,7 +37,7 @@ describe('LocalDataStore', () => {
|
|
|
39
37
|
const fetchedData = localDataStore.getEntry(dataKey)
|
|
40
38
|
fetchedData.forEach((entry) => {
|
|
41
39
|
const fetchedDescriptor = Any.unpack(entry.data!, PeerDescriptor)
|
|
42
|
-
expect(
|
|
40
|
+
expect(areEqualPeerDescriptors(fetchedDescriptor, storer1)).toBeTrue()
|
|
43
41
|
})
|
|
44
42
|
})
|
|
45
43
|
|
|
@@ -52,7 +50,7 @@ describe('LocalDataStore', () => {
|
|
|
52
50
|
const fetchedData = localDataStore.getEntry(dataKey)
|
|
53
51
|
fetchedData.forEach((entry) => {
|
|
54
52
|
const fetchedDescriptor = Any.unpack(entry.data!, PeerDescriptor)
|
|
55
|
-
expect(
|
|
53
|
+
expect(areEqualPeerDescriptors(fetchedDescriptor, storer1)).toBeTrue()
|
|
56
54
|
})
|
|
57
55
|
})
|
|
58
56
|
|
|
@@ -66,7 +64,7 @@ describe('LocalDataStore', () => {
|
|
|
66
64
|
const fetchedData = localDataStore.getEntry(dataKey)
|
|
67
65
|
fetchedData.forEach((entry) => {
|
|
68
66
|
const fetchedDescriptor = Any.unpack(entry.data!, PeerDescriptor)
|
|
69
|
-
expect(
|
|
67
|
+
expect(areEqualPeerDescriptors(fetchedDescriptor, storer2)).toBeTrue()
|
|
70
68
|
})
|
|
71
69
|
})
|
|
72
70
|
|
|
@@ -1,92 +1,43 @@
|
|
|
1
1
|
import { RandomContactList } from '../../src/dht/contact/RandomContactList'
|
|
2
|
-
import type { ServiceInfo, MethodInfo } from '@protobuf-ts/runtime-rpc'
|
|
3
2
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
4
|
-
import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
5
|
-
import { IDhtRpcServiceClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
|
|
6
|
-
import { LeaveNotice, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
7
|
-
import type { FindDataRequest, FindDataResponse, PingResponse } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
8
|
-
import type { PingRequest } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
9
|
-
import type { ClosestPeersResponse } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
10
|
-
import type { ClosestPeersRequest } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
11
|
-
import { UnaryCall } from '@protobuf-ts/runtime-rpc'
|
|
12
|
-
import type { RpcOptions } from '@protobuf-ts/runtime-rpc'
|
|
13
|
-
import { DhtPeer } from '../../src/dht/DhtPeer'
|
|
14
|
-
import { IMessageType } from '@protobuf-ts/runtime'
|
|
15
|
-
import { Empty } from '../../src/proto/google/protobuf/empty'
|
|
16
3
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
methods: MethodInfo<any, any> [] = [
|
|
20
|
-
{ name: 'getClosestPeers', O: {} as IMessageType<ClosestPeersResponse> } as MethodInfo<any, any>,
|
|
21
|
-
{ name: 'ping', O: {} as IMessageType<PingResponse> } as MethodInfo<any, any>,
|
|
22
|
-
{ name: 'findData', O: {} as IMessageType<FindDataRequest> } as MethodInfo<any, any>,
|
|
23
|
-
{ name: 'leaveNotice', O: {} as IMessageType<Empty> } as MethodInfo<any, any>
|
|
24
|
-
]
|
|
25
|
-
options = {}
|
|
26
|
-
|
|
27
|
-
// eslint-disable-next-line class-methods-use-this
|
|
28
|
-
getClosestPeers(_input: ClosestPeersRequest, _options?: RpcOptions): UnaryCall<ClosestPeersRequest, ClosestPeersResponse> {
|
|
29
|
-
return {} as UnaryCall<ClosestPeersRequest, ClosestPeersResponse>
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// eslint-disable-next-line class-methods-use-this
|
|
33
|
-
ping(_input: PingRequest, _options?: RpcOptions): UnaryCall <PingRequest, PingResponse> {
|
|
34
|
-
return {} as UnaryCall<PingRequest, PingResponse>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// eslint-disable-next-line class-methods-use-this
|
|
38
|
-
findData(_input: FindDataRequest, _options?: RpcOptions): UnaryCall<FindDataRequest, FindDataResponse> {
|
|
39
|
-
return {} as UnaryCall<FindDataRequest, FindDataResponse>
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// eslint-disable-next-line class-methods-use-this
|
|
43
|
-
leaveNotice(_input: LeaveNotice, _options?: RpcOptions): UnaryCall<LeaveNotice, Empty> {
|
|
44
|
-
return {} as UnaryCall<LeaveNotice, Empty>
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const getId = (descriptor: PeerDescriptor): PeerID => {
|
|
49
|
-
return PeerID.fromValue(descriptor.kademliaId)
|
|
4
|
+
const createItem = (kademliaId: Uint8Array): { getPeerId: () => PeerID } => {
|
|
5
|
+
return { getPeerId: () => PeerID.fromValue(kademliaId) }
|
|
50
6
|
}
|
|
51
7
|
|
|
52
8
|
describe('RandomContactList', () => {
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const descriptor4: PeerDescriptor = { kademliaId: new Uint8Array([0, 0, 0, 4]), type: NodeType.NODEJS }
|
|
59
|
-
const peer1 = new DhtPeer(descriptor0, descriptor1, toProtoRpcClient(new MockRpcClient()), serviceId)
|
|
60
|
-
const peer2 = new DhtPeer(descriptor0, descriptor2, toProtoRpcClient(new MockRpcClient()), serviceId)
|
|
61
|
-
const peer3 = new DhtPeer(descriptor0, descriptor3, toProtoRpcClient(new MockRpcClient()), serviceId)
|
|
62
|
-
const peer4 = new DhtPeer(descriptor0, descriptor4, toProtoRpcClient(new MockRpcClient()), serviceId)
|
|
9
|
+
const item0 = createItem(new Uint8Array([0, 0, 0, 0]))
|
|
10
|
+
const item1 = createItem(new Uint8Array([0, 0, 0, 1]))
|
|
11
|
+
const item2 = createItem(new Uint8Array([0, 0, 0, 2]))
|
|
12
|
+
const item3 = createItem(new Uint8Array([0, 0, 0, 3]))
|
|
13
|
+
const item4 = createItem(new Uint8Array([0, 0, 0, 4]))
|
|
63
14
|
|
|
64
15
|
it('adds contacts correctly', () => {
|
|
65
|
-
const list = new RandomContactList(
|
|
66
|
-
list.addContact(
|
|
67
|
-
list.addContact(
|
|
68
|
-
list.addContact(
|
|
69
|
-
list.addContact(
|
|
70
|
-
list.addContact(
|
|
71
|
-
list.addContact(
|
|
16
|
+
const list = new RandomContactList(item0.getPeerId(), 5, 1)
|
|
17
|
+
list.addContact(item1)
|
|
18
|
+
list.addContact(item2)
|
|
19
|
+
list.addContact(item3)
|
|
20
|
+
list.addContact(item3)
|
|
21
|
+
list.addContact(item4)
|
|
22
|
+
list.addContact(item4)
|
|
72
23
|
expect(list.getSize()).toEqual(4)
|
|
73
24
|
expect(list.getContacts()).toEqual(
|
|
74
|
-
[
|
|
25
|
+
[item1, item2, item3, item4]
|
|
75
26
|
)
|
|
76
27
|
})
|
|
77
28
|
|
|
78
29
|
it('removes contacts correctly', () => {
|
|
79
|
-
const list = new RandomContactList(
|
|
80
|
-
list.addContact(
|
|
81
|
-
list.addContact(
|
|
82
|
-
list.addContact(
|
|
83
|
-
list.addContact(
|
|
84
|
-
list.removeContact(
|
|
85
|
-
expect(list.getContact(
|
|
86
|
-
expect(list.getContact(
|
|
87
|
-
expect(list.getContact(
|
|
30
|
+
const list = new RandomContactList(item0.getPeerId(), 5, 1)
|
|
31
|
+
list.addContact(item1)
|
|
32
|
+
list.addContact(item2)
|
|
33
|
+
list.addContact(item3)
|
|
34
|
+
list.addContact(item4)
|
|
35
|
+
list.removeContact(item2.getPeerId())
|
|
36
|
+
expect(list.getContact(item1.getPeerId())).toBeTruthy()
|
|
37
|
+
expect(list.getContact(item3.getPeerId())).toBeTruthy()
|
|
38
|
+
expect(list.getContact(item4.getPeerId())).toBeTruthy()
|
|
88
39
|
expect(list.getContacts()).toEqual(
|
|
89
|
-
[
|
|
40
|
+
[item1, item3, item4]
|
|
90
41
|
)
|
|
91
42
|
expect(list.getSize()).toEqual(3)
|
|
92
43
|
})
|
|
@@ -13,28 +13,25 @@ import {
|
|
|
13
13
|
createRecursiveFindRequest
|
|
14
14
|
} from '../utils/utils'
|
|
15
15
|
import { RecursiveFinder } from '../../src/dht/find/RecursiveFinder'
|
|
16
|
-
import {
|
|
16
|
+
import { RemoteDhtNode } from '../../src/dht/RemoteDhtNode'
|
|
17
17
|
import { LocalDataStore } from '../../src/dht/store/LocalDataStore'
|
|
18
18
|
import { v4 } from 'uuid'
|
|
19
19
|
import { MockRouter } from '../utils/mock/Router'
|
|
20
20
|
import { MockTransport } from '../utils/mock/Transport'
|
|
21
|
-
import {
|
|
21
|
+
import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
22
22
|
|
|
23
23
|
describe('RecursiveFinder', () => {
|
|
24
24
|
|
|
25
25
|
let recursiveFinder: RecursiveFinder
|
|
26
|
-
let connections: Map<PeerIDKey,
|
|
26
|
+
let connections: Map<PeerIDKey, RemoteDhtNode>
|
|
27
27
|
|
|
28
|
-
const peerId1 = PeerID.fromString('peerid')
|
|
29
28
|
const peerDescriptor1: PeerDescriptor = {
|
|
30
|
-
kademliaId:
|
|
31
|
-
type: NodeType.NODEJS
|
|
32
|
-
nodeName: 'peerid'
|
|
29
|
+
kademliaId: PeerID.fromString('peerid').value,
|
|
30
|
+
type: NodeType.NODEJS
|
|
33
31
|
}
|
|
34
32
|
const peerDescriptor2: PeerDescriptor = {
|
|
35
33
|
kademliaId: PeerID.fromString('destination').value,
|
|
36
|
-
type: NodeType.NODEJS
|
|
37
|
-
nodeName: 'destination'
|
|
34
|
+
type: NodeType.NODEJS
|
|
38
35
|
}
|
|
39
36
|
const recursiveFindRequest = createRecursiveFindRequest(FindMode.NODE)
|
|
40
37
|
const message: Message = {
|
|
@@ -61,7 +58,6 @@ describe('RecursiveFinder', () => {
|
|
|
61
58
|
connections = new Map()
|
|
62
59
|
recursiveFinder = new RecursiveFinder({
|
|
63
60
|
ownPeerDescriptor: peerDescriptor1,
|
|
64
|
-
ownPeerId: peerId1,
|
|
65
61
|
router: new MockRouter(),
|
|
66
62
|
connections,
|
|
67
63
|
serviceId: 'RecursiveFinder',
|
|
@@ -84,11 +80,11 @@ describe('RecursiveFinder', () => {
|
|
|
84
80
|
|
|
85
81
|
it('startRecursiveFind with mode Node returns self if no peers', async () => {
|
|
86
82
|
const res = await recursiveFinder.startRecursiveFind(PeerID.fromString('find').value)
|
|
87
|
-
expect(
|
|
83
|
+
expect(areEqualPeerDescriptors(res.closestNodes[0], peerDescriptor1)).toEqual(true)
|
|
88
84
|
})
|
|
89
85
|
|
|
90
86
|
it('RecursiveFinder server throws if payload is not recursiveFindRequest', async () => {
|
|
91
|
-
const rpcWrapper = createWrappedClosestPeersRequest(peerDescriptor1
|
|
87
|
+
const rpcWrapper = createWrappedClosestPeersRequest(peerDescriptor1)
|
|
92
88
|
const badMessage: Message = {
|
|
93
89
|
serviceId: 'unknown',
|
|
94
90
|
messageId: v4(),
|