@streamr/dht 100.0.0-pretestnet.3 → 100.0.0-pretestnet.4
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/ConnectionLockRpcLocal.js +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.js +3 -3
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +4 -8
- package/dist/src/connection/ConnectionManager.js +30 -31
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.d.ts +0 -4
- package/dist/src/connection/ConnectivityChecker.js +13 -18
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +6 -3
- package/dist/src/connection/ConnectorFacade.js +33 -23
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +6 -6
- package/dist/src/connection/Handshaker.js +10 -13
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +7 -10
- package/dist/src/connection/ManagedConnection.js +43 -79
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +16 -15
- 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/webrtc/NodeWebrtcConnection.js +8 -9
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +6 -6
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +4 -4
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/ClientWebsocket.js +3 -0
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/ServerWebsocket.js +2 -0
- package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +5 -5
- package/dist/src/connection/websocket/WebsocketConnector.js +37 -35
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -1
- package/dist/src/dht/DhtNode.js +18 -15
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.js +2 -2
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.js +4 -4
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.js +1 -1
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.js +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/find/FindRpcLocal.js +2 -2
- package/dist/src/dht/find/FindRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/FindRpcRemote.js +3 -3
- package/dist/src/dht/routing/FindRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/Router.js +3 -3
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.js +4 -4
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.js +6 -6
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.js +1 -1
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/StoreRpcLocal.js +1 -1
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.js +3 -3
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +7 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +21 -12
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +20 -7
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/package.json +5 -5
- package/protos/DhtRpc.proto +9 -5
- package/src/connection/ConnectionLockRpcLocal.ts +2 -2
- package/src/connection/ConnectionLockRpcRemote.ts +4 -5
- package/src/connection/ConnectionManager.ts +30 -36
- package/src/connection/ConnectivityChecker.ts +13 -15
- package/src/connection/ConnectorFacade.ts +36 -25
- package/src/connection/Handshaker.ts +15 -18
- package/src/connection/ManagedConnection.ts +63 -87
- package/src/connection/ManagedWebrtcConnection.ts +4 -2
- package/src/connection/simulator/SimulatorConnection.ts +17 -16
- package/src/connection/simulator/SimulatorConnector.ts +12 -13
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +2 -2
- package/src/connection/webrtc/NodeWebrtcConnection.ts +9 -10
- package/src/connection/webrtc/WebrtcConnector.ts +7 -6
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +5 -5
- package/src/connection/websocket/ClientWebsocket.ts +3 -0
- package/src/connection/websocket/ServerWebsocket.ts +2 -0
- package/src/connection/websocket/WebsocketConnector.ts +63 -39
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +2 -2
- package/src/connection/websocket/WebsocketConnectorRpcRemote.ts +2 -2
- package/src/dht/DhtNode.ts +24 -16
- package/src/dht/DhtNodeRpcLocal.ts +3 -3
- package/src/dht/DhtNodeRpcRemote.ts +5 -5
- package/src/dht/discovery/DiscoverySession.ts +2 -2
- package/src/dht/discovery/PeerDiscovery.ts +2 -2
- package/src/dht/find/FindRpcLocal.ts +3 -3
- package/src/dht/routing/FindRpcRemote.ts +4 -4
- package/src/dht/routing/Router.ts +10 -5
- package/src/dht/routing/RouterRpcLocal.ts +5 -5
- package/src/dht/routing/RouterRpcRemote.ts +7 -8
- package/src/dht/routing/RoutingSession.ts +2 -2
- package/src/dht/store/StoreRpcLocal.ts +2 -2
- package/src/dht/store/StoreRpcRemote.ts +4 -4
- package/src/helpers/peerIdFromPeerDescriptor.ts +6 -0
- package/src/proto/packages/dht/protos/DhtRpc.ts +25 -17
- package/test/benchmark/Find.test.ts +2 -2
- package/test/benchmark/KademliaCorrectness.test.ts +2 -2
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +4 -3
- package/test/integration/ConnectionLocking.test.ts +7 -4
- package/test/integration/ConnectionManager.test.ts +72 -4
- package/test/integration/Find.test.ts +3 -6
- package/test/integration/MigrateData.test.ts +4 -4
- package/test/integration/MultipleEntryPointJoining.test.ts +2 -2
- package/test/integration/ScaleDownDht.test.ts +4 -4
- package/test/integration/Store.test.ts +3 -6
- package/test/integration/StoreAndDelete.test.ts +3 -6
- package/test/integration/WebrtcConnectionManagement.test.ts +1 -1
- package/test/utils/utils.ts +8 -2
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Message, PeerDescriptor, RouteMessageAck, RouteMessageWrapper } from '../../proto/packages/dht/protos/DhtRpc'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
areEqualPeerDescriptors,
|
|
4
|
+
getNodeIdFromPeerDescriptor,
|
|
5
|
+
keyFromPeerDescriptor,
|
|
6
|
+
peerIdFromPeerDescriptor
|
|
7
|
+
} from '../../helpers/peerIdFromPeerDescriptor'
|
|
3
8
|
import { RoutingMode, RoutingSession, RoutingSessionEvents } from './RoutingSession'
|
|
4
9
|
import { Logger, executeSafePromise, raceEvents3, withTimeout } from '@streamr/utils'
|
|
5
10
|
import { RoutingRpcCommunicator } from '../../transport/RoutingRpcCommunicator'
|
|
@@ -128,8 +133,8 @@ export class Router implements IRouter {
|
|
|
128
133
|
if (this.stopped) {
|
|
129
134
|
return createRouteMessageAck(routedMessage, RoutingErrors.STOPPED)
|
|
130
135
|
}
|
|
131
|
-
logger.trace(`Routing message ${routedMessage.requestId} from ${
|
|
132
|
-
+ `to ${
|
|
136
|
+
logger.trace(`Routing message ${routedMessage.requestId} from ${getNodeIdFromPeerDescriptor(routedMessage.sourcePeer!)} `
|
|
137
|
+
+ `to ${getNodeIdFromPeerDescriptor(routedMessage.destinationPeer!)}`)
|
|
133
138
|
const session = this.createRoutingSession(routedMessage, mode)
|
|
134
139
|
const contacts = session.findMoreContacts()
|
|
135
140
|
if (contacts.length > 0) {
|
|
@@ -158,8 +163,8 @@ export class Router implements IRouter {
|
|
|
158
163
|
return createRouteMessageAck(routedMessage)
|
|
159
164
|
} else {
|
|
160
165
|
if (areEqualPeerDescriptors(routedMessage.sourcePeer!, this.localPeerDescriptor)) {
|
|
161
|
-
logger.
|
|
162
|
-
`Failed to send (routeMessage: ${this.serviceId}) to ${
|
|
166
|
+
logger.debug(
|
|
167
|
+
`Failed to send (routeMessage: ${this.serviceId}) to ${getNodeIdFromPeerDescriptor(routedMessage.destinationPeer!)}`
|
|
163
168
|
)
|
|
164
169
|
}
|
|
165
170
|
logger.trace('noCandidatesFound sessionId: ' + session.sessionId)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger } from '@streamr/utils'
|
|
2
2
|
import { ConnectionManager } from '../../connection/ConnectionManager'
|
|
3
|
-
import { areEqualPeerDescriptors,
|
|
3
|
+
import { areEqualPeerDescriptors, getNodeIdFromPeerDescriptor } from '../../helpers/peerIdFromPeerDescriptor'
|
|
4
4
|
import { PeerDescriptor, RouteMessageAck, RouteMessageWrapper } from '../../proto/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { IRouterRpc } from '../../proto/packages/dht/protos/DhtRpc.server'
|
|
6
6
|
import { DuplicateDetector } from './DuplicateDetector'
|
|
@@ -35,8 +35,8 @@ export class RouterRpcLocal implements IRouterRpc {
|
|
|
35
35
|
|
|
36
36
|
async routeMessage(routedMessage: RouteMessageWrapper): Promise<RouteMessageAck> {
|
|
37
37
|
if (this.config.duplicateRequestDetector.isMostLikelyDuplicate(routedMessage.requestId)) {
|
|
38
|
-
logger.trace(`Routing message ${routedMessage.requestId} from ${
|
|
39
|
-
+ `to ${
|
|
38
|
+
logger.trace(`Routing message ${routedMessage.requestId} from ${getNodeIdFromPeerDescriptor(routedMessage.sourcePeer!)} `
|
|
39
|
+
+ `to ${getNodeIdFromPeerDescriptor(routedMessage.destinationPeer!)} is likely a duplicate`)
|
|
40
40
|
return createRouteMessageAck(routedMessage, 'message given to routeMessage() service is likely a duplicate')
|
|
41
41
|
}
|
|
42
42
|
logger.trace(`Processing received routeMessage ${routedMessage.requestId}`)
|
|
@@ -54,8 +54,8 @@ export class RouterRpcLocal implements IRouterRpc {
|
|
|
54
54
|
|
|
55
55
|
async forwardMessage(forwardMessage: RouteMessageWrapper): Promise<RouteMessageAck> {
|
|
56
56
|
if (this.config.duplicateRequestDetector.isMostLikelyDuplicate(forwardMessage.requestId)) {
|
|
57
|
-
logger.trace(`Forwarding message ${forwardMessage.requestId} from ${
|
|
58
|
-
+ `to ${
|
|
57
|
+
logger.trace(`Forwarding message ${forwardMessage.requestId} from ${getNodeIdFromPeerDescriptor(forwardMessage.sourcePeer!)} `
|
|
58
|
+
+ `to ${getNodeIdFromPeerDescriptor(forwardMessage.destinationPeer!)} is likely a duplicate`)
|
|
59
59
|
return createRouteMessageAck(forwardMessage, 'message given to forwardMessage() service is likely a duplicate')
|
|
60
60
|
}
|
|
61
61
|
logger.trace(`Processing received forward routeMessage ${forwardMessage.requestId}`)
|
|
@@ -2,8 +2,7 @@ import { RouteMessageWrapper } from '../../proto/packages/dht/protos/DhtRpc'
|
|
|
2
2
|
import { v4 } from 'uuid'
|
|
3
3
|
import {
|
|
4
4
|
areEqualPeerDescriptors,
|
|
5
|
-
|
|
6
|
-
peerIdFromPeerDescriptor
|
|
5
|
+
getNodeIdFromPeerDescriptor
|
|
7
6
|
} from '../../helpers/peerIdFromPeerDescriptor'
|
|
8
7
|
import { IRouterRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client'
|
|
9
8
|
import { Remote } from '../contact/Remote'
|
|
@@ -38,9 +37,9 @@ export class RouterRpcRemote extends Remote<IRouterRpcClient> {
|
|
|
38
37
|
} catch (err) {
|
|
39
38
|
const previousPeer = getPreviousPeer(params)
|
|
40
39
|
const fromNode = previousPeer
|
|
41
|
-
?
|
|
42
|
-
:
|
|
43
|
-
logger.trace(`Failed to send routeMessage from ${fromNode} to ${
|
|
40
|
+
? getNodeIdFromPeerDescriptor(previousPeer)
|
|
41
|
+
: getNodeIdFromPeerDescriptor(params.sourcePeer!)
|
|
42
|
+
logger.trace(`Failed to send routeMessage from ${fromNode} to ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())} with: ${err}`)
|
|
44
43
|
return false
|
|
45
44
|
}
|
|
46
45
|
return true
|
|
@@ -64,10 +63,10 @@ export class RouterRpcRemote extends Remote<IRouterRpcClient> {
|
|
|
64
63
|
} catch (err) {
|
|
65
64
|
const previousPeer = getPreviousPeer(params)
|
|
66
65
|
const fromNode = previousPeer
|
|
67
|
-
?
|
|
68
|
-
:
|
|
66
|
+
? getNodeIdFromPeerDescriptor(previousPeer)
|
|
67
|
+
: getNodeIdFromPeerDescriptor(params.sourcePeer!)
|
|
69
68
|
logger.trace(
|
|
70
|
-
`Failed to send forwardMessage from ${fromNode} to ${
|
|
69
|
+
`Failed to send forwardMessage from ${fromNode} to ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())} with: ${err}`
|
|
71
70
|
)
|
|
72
71
|
return false
|
|
73
72
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DhtNodeRpcRemote } from '../DhtNodeRpcRemote'
|
|
2
2
|
import { SortedContactList } from '../contact/SortedContactList'
|
|
3
3
|
import { PeerID, PeerIDKey } from '../../helpers/PeerID'
|
|
4
|
-
import {
|
|
4
|
+
import { getNodeIdFromPeerDescriptor } from '../../helpers/peerIdFromPeerDescriptor'
|
|
5
5
|
import { Logger } from '@streamr/utils'
|
|
6
6
|
import EventEmitter from 'eventemitter3'
|
|
7
7
|
import { v4 } from 'uuid'
|
|
@@ -197,7 +197,7 @@ export class RoutingSession extends EventEmitter<RoutingSessionEvents> {
|
|
|
197
197
|
while ((this.ongoingRequests.size < this.parallelism) && (uncontacted.length > 0) && !this.stopped) {
|
|
198
198
|
const nextPeer = uncontacted.shift()
|
|
199
199
|
// eslint-disable-next-line max-len
|
|
200
|
-
logger.trace(`Sending routeMessage request to contact: ${
|
|
200
|
+
logger.trace(`Sending routeMessage request to contact: ${getNodeIdFromPeerDescriptor(nextPeer!.getPeerDescriptor())} (sessionId=${this.sessionId})`)
|
|
201
201
|
this.contactList.setContacted(nextPeer!.getPeerId())
|
|
202
202
|
this.ongoingRequests.add(nextPeer!.getPeerId().toKey())
|
|
203
203
|
setImmediate(async () => {
|
|
@@ -10,7 +10,7 @@ import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
|
10
10
|
import { StoreRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client'
|
|
11
11
|
import { RoutingRpcCommunicator } from '../../transport/RoutingRpcCommunicator'
|
|
12
12
|
import { IFinder } from '../find/Finder'
|
|
13
|
-
import { areEqualPeerDescriptors,
|
|
13
|
+
import { areEqualPeerDescriptors, getNodeIdFromPeerDescriptor, peerIdFromPeerDescriptor } from '../../helpers/peerIdFromPeerDescriptor'
|
|
14
14
|
import { Logger } from '@streamr/utils'
|
|
15
15
|
import { LocalDataStore } from './LocalDataStore'
|
|
16
16
|
import { IStoreRpc } from '../../proto/packages/dht/protos/DhtRpc.server'
|
|
@@ -224,7 +224,7 @@ export class StoreRpcLocal implements IStoreRpc {
|
|
|
224
224
|
if (response.deleted) {
|
|
225
225
|
logger.trace('remote.deleteData() returned success')
|
|
226
226
|
} else {
|
|
227
|
-
logger.trace('could not delete data from ' +
|
|
227
|
+
logger.trace('could not delete data from ' + getNodeIdFromPeerDescriptor(closestNodes[i]))
|
|
228
228
|
}
|
|
229
229
|
successfulNodes.push(closestNodes[i])
|
|
230
230
|
} catch (e) {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
StoreDataRequest,
|
|
9
9
|
StoreDataResponse
|
|
10
10
|
} from '../../proto/packages/dht/protos/DhtRpc'
|
|
11
|
-
import {
|
|
11
|
+
import { getNodeIdFromPeerDescriptor } from '../../helpers/peerIdFromPeerDescriptor'
|
|
12
12
|
|
|
13
13
|
export class StoreRpcRemote extends Remote<IStoreRpcClient> {
|
|
14
14
|
|
|
@@ -17,8 +17,8 @@ export class StoreRpcRemote extends Remote<IStoreRpcClient> {
|
|
|
17
17
|
try {
|
|
18
18
|
return await this.getClient().storeData(request, options)
|
|
19
19
|
} catch (err) {
|
|
20
|
-
const to =
|
|
21
|
-
const from =
|
|
20
|
+
const to = getNodeIdFromPeerDescriptor(this.getPeerDescriptor())
|
|
21
|
+
const from = getNodeIdFromPeerDescriptor(this.getLocalPeerDescriptor())
|
|
22
22
|
throw Error(
|
|
23
23
|
`Could not store data to ${to} from ${from} ${err}`
|
|
24
24
|
)
|
|
@@ -31,7 +31,7 @@ export class StoreRpcRemote extends Remote<IStoreRpcClient> {
|
|
|
31
31
|
return await this.getClient().deleteData(request, options)
|
|
32
32
|
} catch (err) {
|
|
33
33
|
throw Error(
|
|
34
|
-
`Could not call delete data to ${
|
|
34
|
+
`Could not call delete data to ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())} ${err}`
|
|
35
35
|
)
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { binaryToHex } from '@streamr/utils'
|
|
1
2
|
import { PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc'
|
|
2
3
|
import { PeerID, PeerIDKey } from './PeerID'
|
|
3
4
|
|
|
@@ -5,6 +6,11 @@ export const peerIdFromPeerDescriptor = (peerDescriptor: PeerDescriptor): PeerID
|
|
|
5
6
|
return PeerID.fromValue(peerDescriptor.kademliaId)
|
|
6
7
|
}
|
|
7
8
|
|
|
9
|
+
// TODO could move getNodeIdFromPeerDescriptor (and NodeID) from trackerless-network
|
|
10
|
+
export const getNodeIdFromPeerDescriptor = (peerDescriptor: PeerDescriptor): string => {
|
|
11
|
+
return binaryToHex(peerDescriptor.kademliaId)
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
export const keyFromPeerDescriptor = (peerDescriptor: PeerDescriptor): PeerIDKey => {
|
|
9
15
|
return PeerID.fromValue(peerDescriptor.kademliaId).toKey()
|
|
10
16
|
}
|
|
@@ -354,30 +354,26 @@ export interface ConnectivityResponse {
|
|
|
354
354
|
*/
|
|
355
355
|
export interface HandshakeRequest {
|
|
356
356
|
/**
|
|
357
|
-
* @generated from protobuf field:
|
|
357
|
+
* @generated from protobuf field: dht.PeerDescriptor sourcePeerDescriptor = 1;
|
|
358
358
|
*/
|
|
359
|
-
|
|
359
|
+
sourcePeerDescriptor?: PeerDescriptor;
|
|
360
360
|
/**
|
|
361
|
-
* @generated from protobuf field: dht.PeerDescriptor
|
|
361
|
+
* @generated from protobuf field: optional dht.PeerDescriptor targetPeerDescriptor = 2;
|
|
362
362
|
*/
|
|
363
|
-
|
|
363
|
+
targetPeerDescriptor?: PeerDescriptor;
|
|
364
364
|
}
|
|
365
365
|
/**
|
|
366
366
|
* @generated from protobuf message dht.HandshakeResponse
|
|
367
367
|
*/
|
|
368
368
|
export interface HandshakeResponse {
|
|
369
369
|
/**
|
|
370
|
-
* @generated from protobuf field:
|
|
370
|
+
* @generated from protobuf field: dht.PeerDescriptor sourcePeerDescriptor = 1;
|
|
371
371
|
*/
|
|
372
|
-
|
|
372
|
+
sourcePeerDescriptor?: PeerDescriptor;
|
|
373
373
|
/**
|
|
374
|
-
* @generated from protobuf field: dht.
|
|
374
|
+
* @generated from protobuf field: optional dht.HandshakeError error = 2;
|
|
375
375
|
*/
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* @generated from protobuf field: optional string responseError = 3;
|
|
379
|
-
*/
|
|
380
|
-
responseError?: string;
|
|
376
|
+
error?: HandshakeError;
|
|
381
377
|
}
|
|
382
378
|
/**
|
|
383
379
|
* @generated from protobuf message dht.Message
|
|
@@ -619,6 +615,19 @@ export enum RpcResponseError {
|
|
|
619
615
|
*/
|
|
620
616
|
UNKNOWN_RPC_METHOD = 3
|
|
621
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* @generated from protobuf enum dht.HandshakeError
|
|
620
|
+
*/
|
|
621
|
+
export enum HandshakeError {
|
|
622
|
+
/**
|
|
623
|
+
* @generated from protobuf enum value: DUPLICATE_CONNECTION = 0;
|
|
624
|
+
*/
|
|
625
|
+
DUPLICATE_CONNECTION = 0,
|
|
626
|
+
/**
|
|
627
|
+
* @generated from protobuf enum value: INVALID_TARGET_PEER_DESCRIPTOR = 1;
|
|
628
|
+
*/
|
|
629
|
+
INVALID_TARGET_PEER_DESCRIPTOR = 1
|
|
630
|
+
}
|
|
622
631
|
// Wraps all messages
|
|
623
632
|
|
|
624
633
|
/**
|
|
@@ -966,8 +975,8 @@ export const ConnectivityResponse = new ConnectivityResponse$Type();
|
|
|
966
975
|
class HandshakeRequest$Type extends MessageType$<HandshakeRequest> {
|
|
967
976
|
constructor() {
|
|
968
977
|
super("dht.HandshakeRequest", [
|
|
969
|
-
{ no: 1, name: "
|
|
970
|
-
{ no: 2, name: "
|
|
978
|
+
{ no: 1, name: "sourcePeerDescriptor", kind: "message", T: () => PeerDescriptor },
|
|
979
|
+
{ no: 2, name: "targetPeerDescriptor", kind: "message", T: () => PeerDescriptor }
|
|
971
980
|
]);
|
|
972
981
|
}
|
|
973
982
|
}
|
|
@@ -979,9 +988,8 @@ export const HandshakeRequest = new HandshakeRequest$Type();
|
|
|
979
988
|
class HandshakeResponse$Type extends MessageType$<HandshakeResponse> {
|
|
980
989
|
constructor() {
|
|
981
990
|
super("dht.HandshakeResponse", [
|
|
982
|
-
{ no: 1, name: "
|
|
983
|
-
{ no: 2, name: "
|
|
984
|
-
{ no: 3, name: "responseError", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ }
|
|
991
|
+
{ no: 1, name: "sourcePeerDescriptor", kind: "message", T: () => PeerDescriptor },
|
|
992
|
+
{ no: 2, name: "error", kind: "enum", opt: true, T: () => ["dht.HandshakeError", HandshakeError] }
|
|
985
993
|
]);
|
|
986
994
|
}
|
|
987
995
|
}
|
|
@@ -6,7 +6,7 @@ import { createMockConnectionDhtNode } from '../utils/utils'
|
|
|
6
6
|
import { execSync } from 'child_process'
|
|
7
7
|
import fs from 'fs'
|
|
8
8
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
9
|
-
import {
|
|
9
|
+
import { getNodeIdFromPeerDescriptor, peerIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
10
10
|
import { Logger, wait } from '@streamr/utils'
|
|
11
11
|
import { debugVars } from '../../src/helpers/debugHelpers'
|
|
12
12
|
|
|
@@ -70,7 +70,7 @@ describe('Find correctness', () => {
|
|
|
70
70
|
debugVars['waiting'] = false
|
|
71
71
|
logger.info('waiting over')
|
|
72
72
|
|
|
73
|
-
nodes.forEach((node) => logger.info(
|
|
73
|
+
nodes.forEach((node) => logger.info(getNodeIdFromPeerDescriptor(node.getLocalPeerDescriptor()) + ': connections:' +
|
|
74
74
|
node.getNumberOfConnections() + ', kbucket: ' + node.getBucketSize()
|
|
75
75
|
+ ', localLocked: ' + node.getNumberOfLocalLockedConnections()
|
|
76
76
|
+ ', remoteLocked: ' + node.getNumberOfRemoteLockedConnections()
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
4
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
5
|
-
import {
|
|
5
|
+
import { getNodeIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
6
6
|
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
7
7
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
8
8
|
import { execSync } from 'child_process'
|
|
@@ -88,7 +88,7 @@ describe('Kademlia correctness', () => {
|
|
|
88
88
|
correctNeighbors++
|
|
89
89
|
}
|
|
90
90
|
} catch (e) {
|
|
91
|
-
console.error('Node ' +
|
|
91
|
+
console.error('Node ' + getNodeIdFromPeerDescriptor(nodes[i].getLocalPeerDescriptor()) + ' had only '
|
|
92
92
|
+ kademliaNeighbors.length + ' kademlia neighbors')
|
|
93
93
|
}
|
|
94
94
|
if (correctNeighbors === 0) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { waitForEvent3 } from '@streamr/utils'
|
|
4
|
-
import { ConnectionManager
|
|
4
|
+
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
5
|
+
import { TransportEvents } from '../../src/transport/ITransport'
|
|
5
6
|
|
|
6
7
|
describe('Layer0MixedConnectionTypes', () => {
|
|
7
8
|
|
|
@@ -74,8 +75,8 @@ describe('Layer0MixedConnectionTypes', () => {
|
|
|
74
75
|
it('2 non-server peers join first', async () => {
|
|
75
76
|
|
|
76
77
|
const promise = Promise.all([
|
|
77
|
-
waitForEvent3<
|
|
78
|
-
waitForEvent3<
|
|
78
|
+
waitForEvent3<TransportEvents>((node3.getTransport() as ConnectionManager), 'connected'),
|
|
79
|
+
waitForEvent3<TransportEvents>((node4.getTransport() as ConnectionManager), 'connected'),
|
|
79
80
|
])
|
|
80
81
|
|
|
81
82
|
node3.joinDht([epPeerDescriptor])
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MetricsContext, waitForCondition } from '@streamr/utils'
|
|
2
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
3
3
|
import { DefaultConnectorFacade } from '../../src/connection/ConnectorFacade'
|
|
4
|
-
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
4
|
+
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
5
5
|
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
6
6
|
import { ITransport } from '../../src/exports'
|
|
7
7
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
8
8
|
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
9
|
+
import { getRandomRegion } from '../../dist/src/connection/simulator/pings'
|
|
9
10
|
|
|
10
11
|
const createConnectionManager = (localPeerDescriptor: PeerDescriptor, transport: ITransport) => {
|
|
11
12
|
return new ConnectionManager({
|
|
@@ -21,11 +22,13 @@ describe('Connection Locking', () => {
|
|
|
21
22
|
|
|
22
23
|
const mockPeerDescriptor1: PeerDescriptor = {
|
|
23
24
|
kademliaId: PeerID.fromString('mock1').value,
|
|
24
|
-
type: NodeType.NODEJS
|
|
25
|
+
type: NodeType.NODEJS,
|
|
26
|
+
region: getRandomRegion()
|
|
25
27
|
}
|
|
26
28
|
const mockPeerDescriptor2: PeerDescriptor = {
|
|
27
29
|
kademliaId: PeerID.fromString('mock2').value,
|
|
28
|
-
type: NodeType.NODEJS
|
|
30
|
+
type: NodeType.NODEJS,
|
|
31
|
+
region: getRandomRegion()
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
let mockConnectorTransport1: ConnectionManager
|
|
@@ -37,7 +40,7 @@ describe('Connection Locking', () => {
|
|
|
37
40
|
let simulator: Simulator
|
|
38
41
|
|
|
39
42
|
beforeEach(async () => {
|
|
40
|
-
simulator = new Simulator()
|
|
43
|
+
simulator = new Simulator(LatencyType.REAL)
|
|
41
44
|
mockConnectorTransport1 = new SimulatorTransport(mockPeerDescriptor1, simulator)
|
|
42
45
|
await mockConnectorTransport1.start()
|
|
43
46
|
mockConnectorTransport2 = new SimulatorTransport(mockPeerDescriptor2, simulator)
|
|
@@ -4,9 +4,12 @@ import { PeerID } from '../../src/helpers/PeerID'
|
|
|
4
4
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
5
5
|
import { createPeerDescriptor } from '../../src/dht/DhtNode'
|
|
6
6
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
7
|
-
import { Logger, MetricsContext } from '@streamr/utils'
|
|
7
|
+
import { Logger, MetricsContext, waitForEvent3 } from '@streamr/utils'
|
|
8
8
|
import { SimulatorTransport } from '../../src/exports'
|
|
9
9
|
import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../../src/connection/ConnectorFacade'
|
|
10
|
+
import { MarkOptional } from 'ts-essentials'
|
|
11
|
+
import { createRandomKademliaId } from '../../src/helpers/kademliaId'
|
|
12
|
+
import { TransportEvents } from '../../src/transport/ITransport'
|
|
10
13
|
|
|
11
14
|
const logger = new Logger(module)
|
|
12
15
|
|
|
@@ -39,7 +42,7 @@ describe('ConnectionManager', () => {
|
|
|
39
42
|
|
|
40
43
|
let createLocalPeerDescriptor: jest.Mock<PeerDescriptor, [ConnectivityResponse]>
|
|
41
44
|
|
|
42
|
-
const createConnectionManager = (opts:
|
|
45
|
+
const createConnectionManager = (opts: MarkOptional<DefaultConnectorFacadeConfig, 'createLocalPeerDescriptor'>) => {
|
|
43
46
|
return new ConnectionManager({
|
|
44
47
|
createConnectorFacade: () => new DefaultConnectorFacade({
|
|
45
48
|
createLocalPeerDescriptor,
|
|
@@ -183,7 +186,7 @@ describe('ConnectionManager', () => {
|
|
|
183
186
|
const connectionManager1 = createConnectionManager({
|
|
184
187
|
transport: mockConnectorTransport1,
|
|
185
188
|
websocketHost: '127.0.0.1',
|
|
186
|
-
websocketPortRange: { min: 9997, max: 9997 }
|
|
189
|
+
websocketPortRange: { min: 9997, max: 9997 },
|
|
187
190
|
})
|
|
188
191
|
|
|
189
192
|
await connectionManager1.start()
|
|
@@ -332,13 +335,78 @@ describe('ConnectionManager', () => {
|
|
|
332
335
|
await connectionManager1.stop()
|
|
333
336
|
})
|
|
334
337
|
|
|
338
|
+
it('Cannot send to a WebSocketServer if kademliaIds do not match', async () => {
|
|
339
|
+
|
|
340
|
+
const peerDescriptor1 = {
|
|
341
|
+
kademliaId: createRandomKademliaId(),
|
|
342
|
+
type: NodeType.NODEJS,
|
|
343
|
+
websocket: {
|
|
344
|
+
host: '127.0.0.1',
|
|
345
|
+
port: 10002,
|
|
346
|
+
tls: false
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const peerDescriptor2 = {
|
|
351
|
+
kademliaId: createRandomKademliaId(),
|
|
352
|
+
type: NodeType.NODEJS,
|
|
353
|
+
websocket: {
|
|
354
|
+
host: '127.0.0.1',
|
|
355
|
+
port: 10003,
|
|
356
|
+
tls: false
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const connectionManager1 = createConnectionManager({
|
|
360
|
+
transport: mockTransport,
|
|
361
|
+
websocketHost: '127.0.0.1',
|
|
362
|
+
websocketPortRange: { min: 10002, max: 10002 },
|
|
363
|
+
createLocalPeerDescriptor: () => peerDescriptor1
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
await connectionManager1.start()
|
|
367
|
+
|
|
368
|
+
const connectionManager2 = createConnectionManager({
|
|
369
|
+
transport: mockTransport,
|
|
370
|
+
websocketHost: '127.0.0.1',
|
|
371
|
+
websocketPortRange: { min: 10003, max: 10003 },
|
|
372
|
+
createLocalPeerDescriptor: () => peerDescriptor2
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
await connectionManager2.start()
|
|
376
|
+
|
|
377
|
+
const msg: Message = {
|
|
378
|
+
serviceId,
|
|
379
|
+
messageType: MessageType.RPC,
|
|
380
|
+
messageId: '1',
|
|
381
|
+
targetDescriptor: {
|
|
382
|
+
// This is not the correct kademliaId of peerDescriptor2
|
|
383
|
+
kademliaId: new Uint8Array([1, 2, 3, 4]),
|
|
384
|
+
type: NodeType.NODEJS,
|
|
385
|
+
websocket: peerDescriptor2.websocket
|
|
386
|
+
},
|
|
387
|
+
body: {
|
|
388
|
+
oneofKind: 'rpcMessage',
|
|
389
|
+
rpcMessage: RpcMessage.create()
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
await Promise.all([
|
|
393
|
+
waitForEvent3<TransportEvents>(connectionManager1, 'disconnected'),
|
|
394
|
+
expect(connectionManager1.send(msg))
|
|
395
|
+
.rejects
|
|
396
|
+
.toThrow()
|
|
397
|
+
])
|
|
398
|
+
|
|
399
|
+
await connectionManager1.stop()
|
|
400
|
+
await connectionManager2.stop()
|
|
401
|
+
}, 10000)
|
|
402
|
+
|
|
335
403
|
it('Failed autocertification', async () => {
|
|
336
404
|
const connectionManager1 = createConnectionManager({
|
|
337
405
|
transport: mockTransport,
|
|
338
406
|
websocketHost: '127.0.0.1',
|
|
339
407
|
autoCertifierUrl: 'https://localhost:12333',
|
|
340
408
|
websocketServerEnableTls: true,
|
|
341
|
-
websocketPortRange: { min:
|
|
409
|
+
websocketPortRange: { min: 10004, max: 10004 }
|
|
342
410
|
})
|
|
343
411
|
|
|
344
412
|
await connectionManager1.start()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import {
|
|
3
|
+
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { createMockConnectionDhtNode, waitConnectionManagersReadyForTesting } from '../utils/utils'
|
|
5
5
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
6
6
|
import { peerIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
@@ -10,7 +10,7 @@ describe('Find correctness', () => {
|
|
|
10
10
|
let entryPoint: DhtNode
|
|
11
11
|
let nodes: DhtNode[]
|
|
12
12
|
let entrypointDescriptor: PeerDescriptor
|
|
13
|
-
const simulator = new Simulator(LatencyType.
|
|
13
|
+
const simulator = new Simulator(LatencyType.REAL)
|
|
14
14
|
const NUM_NODES = 100
|
|
15
15
|
const K = 2
|
|
16
16
|
|
|
@@ -19,10 +19,7 @@ describe('Find correctness', () => {
|
|
|
19
19
|
const entryPointId = '0'
|
|
20
20
|
entryPoint = await createMockConnectionDhtNode(entryPointId, simulator, undefined, K)
|
|
21
21
|
nodes.push(entryPoint)
|
|
22
|
-
entrypointDescriptor =
|
|
23
|
-
kademliaId: entryPoint.getNodeId().value,
|
|
24
|
-
type: NodeType.NODEJS
|
|
25
|
-
}
|
|
22
|
+
entrypointDescriptor = entryPoint.getLocalPeerDescriptor()
|
|
26
23
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
27
24
|
const nodeId = `${i}`
|
|
28
25
|
const node = await createMockConnectionDhtNode(nodeId, simulator, undefined, K, 20, 60000)
|
|
@@ -7,7 +7,7 @@ import { execSync } from 'child_process'
|
|
|
7
7
|
import fs from 'fs'
|
|
8
8
|
import { Logger } from '@streamr/utils'
|
|
9
9
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
10
|
-
import { keyFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
10
|
+
import { getNodeIdFromPeerDescriptor, keyFromPeerDescriptor, peerIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
11
11
|
import { Any } from '../../src/proto/google/protobuf/any'
|
|
12
12
|
import { SortedContactList } from '../../src/dht/contact/SortedContactList'
|
|
13
13
|
import { Contact } from '../../src/dht/contact/Contact'
|
|
@@ -91,7 +91,7 @@ describe('Migrating data from node to node in DHT', () => {
|
|
|
91
91
|
|
|
92
92
|
logger.info('Nodes sorted according to distance to data are: ')
|
|
93
93
|
closest.forEach((contact) => {
|
|
94
|
-
logger.info(
|
|
94
|
+
logger.info(getNodeIdFromPeerDescriptor(contact.getPeerDescriptor()))
|
|
95
95
|
})
|
|
96
96
|
|
|
97
97
|
logger.info('node 0 joining to the DHT')
|
|
@@ -115,7 +115,7 @@ describe('Migrating data from node to node in DHT', () => {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// eslint-disable-next-line max-len
|
|
118
|
-
logger.info(
|
|
118
|
+
logger.info(peerIdFromPeerDescriptor(contact.getPeerDescriptor()) + ' ' + getNodeIdFromPeerDescriptor(node.getLocalPeerDescriptor()) + hasDataMarker)
|
|
119
119
|
})
|
|
120
120
|
|
|
121
121
|
logger.info(NUM_NODES + ' nodes joining layer0 DHT')
|
|
@@ -143,7 +143,7 @@ describe('Migrating data from node to node in DHT', () => {
|
|
|
143
143
|
hasDataMarker = '<-'
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
logger.info(
|
|
146
|
+
logger.info(getNodeIdFromPeerDescriptor(node.getLocalPeerDescriptor()) + hasDataMarker)
|
|
147
147
|
})
|
|
148
148
|
|
|
149
149
|
const closestNode = nodesById.get(PeerID.fromValue(closest[0].getPeerDescriptor().kademliaId).toKey())!
|
|
@@ -14,7 +14,7 @@ describe('multiple entry point joining', () => {
|
|
|
14
14
|
let entryPoints: PeerDescriptor[]
|
|
15
15
|
|
|
16
16
|
beforeEach(async () => {
|
|
17
|
-
simulator = new Simulator(LatencyType.
|
|
17
|
+
simulator = new Simulator(LatencyType.REAL)
|
|
18
18
|
|
|
19
19
|
node1 = await createMockConnectionDhtNode('node1', simulator)
|
|
20
20
|
node2 = await createMockConnectionDhtNode('node2', simulator)
|
|
@@ -67,7 +67,7 @@ describe('multiple entry point joining', () => {
|
|
|
67
67
|
let entryPoints: PeerDescriptor[]
|
|
68
68
|
|
|
69
69
|
beforeEach(async () => {
|
|
70
|
-
simulator = new Simulator(LatencyType.
|
|
70
|
+
simulator = new Simulator(LatencyType.REAL)
|
|
71
71
|
|
|
72
72
|
entryPoint1 = await createMockConnectionDhtNode('entryPoint1', simulator)
|
|
73
73
|
entryPoint2 = await createMockConnectionDhtNode('entryPoint2', simulator)
|
|
@@ -2,7 +2,7 @@ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator
|
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
5
|
-
import { areEqualPeerDescriptors,
|
|
5
|
+
import { areEqualPeerDescriptors, getNodeIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
6
6
|
import { Logger } from '@streamr/utils'
|
|
7
7
|
|
|
8
8
|
const logger = new Logger(module)
|
|
@@ -11,7 +11,7 @@ describe('Scaling down a Dht network', () => {
|
|
|
11
11
|
let entryPoint: DhtNode
|
|
12
12
|
let nodes: DhtNode[]
|
|
13
13
|
let entrypointDescriptor: PeerDescriptor
|
|
14
|
-
const simulator = new Simulator(LatencyType.
|
|
14
|
+
const simulator = new Simulator(LatencyType.REAL)
|
|
15
15
|
const NUM_NODES = 80
|
|
16
16
|
const MAX_CONNECTIONS = 15
|
|
17
17
|
const K = 2
|
|
@@ -54,8 +54,8 @@ describe('Scaling down a Dht network', () => {
|
|
|
54
54
|
const nodeIsCleaned = nodes.every((node) =>
|
|
55
55
|
node.getAllConnectionPeerDescriptors().every((peer) => {
|
|
56
56
|
if (areEqualPeerDescriptors(peer, stoppingPeerDescriptor)) {
|
|
57
|
-
logger.error(
|
|
58
|
-
+
|
|
57
|
+
logger.error(getNodeIdFromPeerDescriptor(node.getLocalPeerDescriptor()) + ', '
|
|
58
|
+
+ getNodeIdFromPeerDescriptor(stoppingPeerDescriptor) + ' cleaning up failed')
|
|
59
59
|
}
|
|
60
60
|
return !areEqualPeerDescriptors(peer, stoppingPeerDescriptor)
|
|
61
61
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import {
|
|
3
|
+
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { createMockConnectionDhtNode, waitConnectionManagersReadyForTesting } from '../utils/utils'
|
|
5
5
|
import { PeerID } from '../../src/helpers/PeerID'
|
|
6
6
|
import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
@@ -10,7 +10,7 @@ describe('Storing data in DHT', () => {
|
|
|
10
10
|
let entryPoint: DhtNode
|
|
11
11
|
let nodes: DhtNode[]
|
|
12
12
|
let entrypointDescriptor: PeerDescriptor
|
|
13
|
-
const simulator = new Simulator(LatencyType.
|
|
13
|
+
const simulator = new Simulator(LatencyType.REAL)
|
|
14
14
|
const NUM_NODES = 100
|
|
15
15
|
const MAX_CONNECTIONS = 20
|
|
16
16
|
const K = 4
|
|
@@ -27,10 +27,7 @@ describe('Storing data in DHT', () => {
|
|
|
27
27
|
undefined, K, MAX_CONNECTIONS)
|
|
28
28
|
nodes.push(entryPoint)
|
|
29
29
|
nodeIndicesById[entryPoint.getNodeId().toKey()] = 0
|
|
30
|
-
entrypointDescriptor =
|
|
31
|
-
kademliaId: entryPoint.getNodeId().value,
|
|
32
|
-
type: NodeType.NODEJS
|
|
33
|
-
}
|
|
30
|
+
entrypointDescriptor = entryPoint.getLocalPeerDescriptor()
|
|
34
31
|
nodes.push(entryPoint)
|
|
35
32
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
36
33
|
const nodeId = `${i}`
|