@streamr/dht 100.0.0-testnet-three.6 → 100.1.0
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/README.md +1 -1
- package/dist/package.json +12 -8
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.js +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/{ConnectionLockHandler.d.ts → ConnectionLockStates.d.ts} +3 -3
- package/dist/src/connection/{ConnectionLockHandler.js → ConnectionLockStates.js} +17 -9
- package/dist/src/connection/ConnectionLockStates.js.map +1 -0
- package/dist/src/connection/ConnectionManager.d.ts +9 -7
- package/dist/src/connection/ConnectionManager.js +16 -18
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.js +1 -1
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.js +6 -13
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +2 -2
- package/dist/src/connection/ManagedConnection.js +8 -8
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/connectivityChecker.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.js +8 -8
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.d.ts +2 -2
- package/dist/src/connection/connectivityRequestHandler.js +10 -11
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +1 -0
- package/dist/src/connection/webrtc/WebrtcConnector.js +13 -8
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +2 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +4 -6
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +28 -0
- package/dist/src/connection/websocket/{ClientWebsocket.js → AbstractWebsocketClientConnection.js} +42 -68
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js.map +1 -0
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.d.ts +7 -0
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.js +39 -0
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketConnector.js +26 -23
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServer.js +25 -35
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
- package/dist/src/connection/websocket/{ServerWebsocket.d.ts → WebsocketServerConnection.d.ts} +4 -5
- package/dist/src/connection/websocket/{ServerWebsocket.js → WebsocketServerConnection.js} +18 -51
- package/dist/src/connection/websocket/WebsocketServerConnection.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +15 -8
- package/dist/src/dht/DhtNode.js +62 -31
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +5 -1
- package/dist/src/dht/DhtNodeRpcLocal.js +10 -0
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +3 -0
- package/dist/src/dht/DhtNodeRpcRemote.js +16 -1
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +2 -2
- package/dist/src/dht/ExternalApiRpcLocal.js +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +15 -3
- package/dist/src/dht/PeerManager.js +54 -40
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/RingContactList.d.ts +31 -0
- package/dist/src/dht/contact/RingContactList.js +133 -0
- package/dist/src/dht/contact/RingContactList.js.map +1 -0
- package/dist/src/dht/contact/SortedContactList.d.ts +2 -1
- package/dist/src/dht/contact/SortedContactList.js +19 -17
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/contact/ringIdentifiers.d.ts +16 -0
- package/dist/src/dht/contact/ringIdentifiers.js +54 -0
- package/dist/src/dht/contact/ringIdentifiers.js.map +1 -0
- package/dist/src/dht/discovery/DiscoverySession.js +3 -1
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +6 -2
- package/dist/src/dht/discovery/PeerDiscovery.js +41 -4
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.d.ts +29 -0
- package/dist/src/dht/discovery/RingDiscoverySession.js +125 -0
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +0 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +0 -1
- package/dist/src/dht/routing/Router.js +0 -1
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +0 -1
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.js +2 -2
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.js +2 -2
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/LocalDataStore.js +2 -2
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.js +2 -2
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/dist/src/exports.d.ts +3 -2
- package/dist/src/exports.js +3 -3
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptor.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptor.js +2 -1
- package/dist/src/helpers/createPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/version.d.ts +6 -0
- package/dist/src/helpers/version.js +38 -0
- package/dist/src/helpers/version.js.map +1 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +16 -6
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +11 -4
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +98 -87
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +45 -49
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +10 -4
- package/dist/src/transport/RoutingRpcCommunicator.js +0 -2
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/karma.config.js +4 -1
- package/package.json +12 -8
- package/protos/DhtRpc.proto +21 -21
- package/src/connection/ConnectionLockRpcLocal.ts +1 -1
- package/src/connection/ConnectionLockRpcRemote.ts +2 -2
- package/src/connection/{ConnectionLockHandler.ts → ConnectionLockStates.ts} +14 -6
- package/src/connection/ConnectionManager.ts +21 -22
- package/src/connection/ConnectorFacade.ts +1 -2
- package/src/connection/Handshaker.ts +7 -15
- package/src/connection/ManagedConnection.ts +8 -8
- package/src/connection/connectivityChecker.ts +9 -10
- package/src/connection/connectivityRequestHandler.ts +16 -16
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +18 -0
- package/src/connection/webrtc/NodeWebrtcConnection.ts +1 -1
- package/src/connection/webrtc/WebrtcConnector.ts +14 -8
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +5 -5
- package/src/connection/websocket/{ClientWebsocket.ts → AbstractWebsocketClientConnection.ts} +57 -70
- package/src/connection/websocket/BrowserWebsocketClientConnection.ts +44 -0
- package/src/connection/websocket/NodeWebsocketClientConnection.ts +39 -0
- package/src/connection/websocket/WebsocketConnector.ts +27 -28
- package/src/connection/websocket/WebsocketServer.ts +27 -42
- package/src/connection/websocket/{ServerWebsocket.ts → WebsocketServerConnection.ts} +15 -56
- package/src/dht/DhtNode.ts +85 -50
- package/src/dht/DhtNodeRpcLocal.ts +16 -0
- package/src/dht/DhtNodeRpcRemote.ts +19 -1
- package/src/dht/ExternalApiRpcLocal.ts +5 -5
- package/src/dht/ExternalApiRpcRemote.ts +4 -4
- package/src/dht/PeerManager.ts +70 -44
- package/src/dht/contact/RingContactList.ts +151 -0
- package/src/dht/contact/SortedContactList.ts +22 -18
- package/src/dht/contact/ringIdentifiers.ts +62 -0
- package/src/dht/discovery/DiscoverySession.ts +3 -1
- package/src/dht/discovery/PeerDiscovery.ts +45 -6
- package/src/dht/discovery/RingDiscoverySession.ts +162 -0
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +1 -1
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +1 -1
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +1 -3
- package/src/dht/routing/Router.ts +0 -2
- package/src/dht/routing/RouterRpcLocal.ts +0 -1
- package/src/dht/routing/RouterRpcRemote.ts +2 -2
- package/src/dht/routing/RoutingSession.ts +2 -2
- package/src/dht/store/LocalDataStore.ts +1 -1
- package/src/dht/store/StoreManager.ts +2 -2
- package/src/exports.ts +3 -2
- package/src/helpers/createPeerDescriptor.ts +2 -1
- package/src/helpers/version.ts +32 -0
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +22 -9
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +10 -4
- package/src/proto/packages/dht/protos/DhtRpc.ts +122 -100
- package/src/transport/RoutingRpcCommunicator.ts +1 -2
- package/test/benchmark/Find.test.ts +3 -4
- package/test/benchmark/KademliaCorrectness.test.ts +14 -8
- package/test/benchmark/RingCorrectness.test.ts +157 -0
- package/test/benchmark/WebsocketServerMemoryLeak.test.ts +2 -2
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +72 -0
- package/test/data/generateGroundTruthData.ts +2 -2
- package/test/end-to-end/memory-leak.test.ts +1 -2
- package/test/integration/ConnectionManager.test.ts +28 -10
- package/test/integration/ConnectivityChecking.test.ts +3 -15
- package/test/integration/DhtNodeExternalAPI.test.ts +6 -6
- package/test/integration/Find.test.ts +6 -6
- package/test/integration/Layer1-scale.test.ts +0 -1
- package/test/integration/ReplicateData.test.ts +4 -4
- package/test/integration/RouteMessage.test.ts +1 -6
- package/test/integration/RouterRpcRemote.test.ts +1 -3
- package/test/integration/SimultaneousConnections.test.ts +9 -10
- package/test/integration/Store.test.ts +4 -4
- package/test/integration/StoreAndDelete.test.ts +5 -5
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +5 -5
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +3 -3
- package/test/integration/WebrtcConnectionManagement.test.ts +3 -9
- package/test/integration/Websocket.test.ts +2 -2
- package/test/integration/WebsocketConnectionManagement.test.ts +1 -6
- package/test/integration/rpc-connections-over-webrpc.test.ts +1 -2
- package/test/unit/PeerManager.test.ts +44 -10
- package/test/unit/RecursiveOperationManager.test.ts +14 -8
- package/test/unit/RecursiveOperationSession.test.ts +1 -1
- package/test/unit/Router.test.ts +0 -3
- package/test/unit/RoutingSession.test.ts +1 -2
- package/test/unit/connectivityRequestHandler.test.ts +5 -9
- package/test/unit/createPeerDescriptor.test.ts +12 -6
- package/test/unit/version.test.ts +18 -0
- package/test/utils/utils.ts +60 -47
- package/tsconfig.browser.json +2 -1
- package/tsconfig.jest.json +4 -2
- package/tsconfig.node.json +4 -2
- package/dist/src/connection/ConnectionLockHandler.js.map +0 -1
- package/dist/src/connection/websocket/ClientWebsocket.d.ts +0 -17
- package/dist/src/connection/websocket/ClientWebsocket.js.map +0 -1
- package/dist/src/connection/websocket/ServerWebsocket.js.map +0 -1
- package/dist/src/helpers/MapWithTtl.d.ts +0 -14
- package/dist/src/helpers/MapWithTtl.js +0 -60
- package/dist/src/helpers/MapWithTtl.js.map +0 -1
- package/dist/src/helpers/versionCompatibility.d.ts +0 -2
- package/dist/src/helpers/versionCompatibility.js +0 -18
- package/dist/src/helpers/versionCompatibility.js.map +0 -1
- package/src/helpers/MapWithTtl.ts +0 -71
- package/src/helpers/versionCompatibility.ts +0 -13
- package/test/unit/versionCompatibility.test.ts +0 -16
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
3
|
+
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
|
+
import { createMockRingNode } from '../utils/utils'
|
|
5
|
+
import { execSync } from 'child_process'
|
|
6
|
+
import fs from 'fs'
|
|
7
|
+
import { DhtAddress, getDhtAddressFromRaw, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
8
|
+
import { Logger } from '@streamr/utils'
|
|
9
|
+
import { getRingIdRawFromPeerDescriptor } from '../../src/dht/contact/ringIdentifiers'
|
|
10
|
+
|
|
11
|
+
const logger = new Logger(module)
|
|
12
|
+
|
|
13
|
+
describe('Ring correctness', () => {
|
|
14
|
+
let entryPoint: DhtNode
|
|
15
|
+
let nodes: DhtNode[]
|
|
16
|
+
const simulator = new Simulator()
|
|
17
|
+
|
|
18
|
+
const NUM_NODES = 900
|
|
19
|
+
const nodeIndicesById: Record<DhtAddress, number> = {}
|
|
20
|
+
|
|
21
|
+
const regions: Array<number> = []
|
|
22
|
+
for (let i = 0; i < (NUM_NODES + 1); i++) {
|
|
23
|
+
regions.push(i)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Shuffle the regions
|
|
27
|
+
for (let i = regions.length - 1; i > 0; i--) {
|
|
28
|
+
const j = Math.floor(Math.random() * (i + 1))
|
|
29
|
+
const temp = regions[i]
|
|
30
|
+
regions[i] = regions[j]
|
|
31
|
+
regions[j] = temp
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!fs.existsSync('test/data/nodeids.json')) {
|
|
35
|
+
console.log('gound truth data does not exist yet, generating..')
|
|
36
|
+
execSync('npm run prepare-kademlia-simulation')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const dhtIds: Array<{ type: string, data: Array<number> }> = JSON.parse(fs.readFileSync('test/data/nodeids.json').toString())
|
|
40
|
+
const groundTruth: Record<string, Array<{ name: string, distance: number, id: { type: string, data: Array<number> } }>>
|
|
41
|
+
= JSON.parse(fs.readFileSync('test/data/orderedneighbors.json').toString())
|
|
42
|
+
|
|
43
|
+
beforeEach(async () => {
|
|
44
|
+
jest.setTimeout(60000)
|
|
45
|
+
nodes = []
|
|
46
|
+
entryPoint = await createMockRingNode(simulator, getDhtAddressFromRaw(Uint8Array.from(dhtIds[0].data)), regions[0])
|
|
47
|
+
nodes.push(entryPoint)
|
|
48
|
+
nodeIndicesById[entryPoint.getNodeId()] = 0
|
|
49
|
+
|
|
50
|
+
for (let i = 1; i < NUM_NODES; i++) {
|
|
51
|
+
const node = await createMockRingNode(simulator, getDhtAddressFromRaw(Uint8Array.from(dhtIds[i].data)), regions[i + 1])
|
|
52
|
+
nodeIndicesById[node.getNodeId()] = i
|
|
53
|
+
nodes.push(node)
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
afterEach(async () => {
|
|
58
|
+
await Promise.all([
|
|
59
|
+
entryPoint.stop(),
|
|
60
|
+
...nodes.map((node) => node.stop())
|
|
61
|
+
])
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('Can find correct neighbors', async () => {
|
|
65
|
+
await entryPoint.joinDht([entryPoint.getLocalPeerDescriptor()])
|
|
66
|
+
|
|
67
|
+
//await Promise.all(
|
|
68
|
+
// nodes.map((node) => node.joinDht([entryPoint.getLocalPeerDescriptor()]))
|
|
69
|
+
//)
|
|
70
|
+
|
|
71
|
+
for (let i = 1; i < NUM_NODES; i++) {
|
|
72
|
+
// time to join the network
|
|
73
|
+
const startTimestamp = Date.now()
|
|
74
|
+
await nodes[i].joinDht([entryPoint.getLocalPeerDescriptor()])
|
|
75
|
+
const endTimestamp = Date.now()
|
|
76
|
+
logger.info('Node ' + i + ' joined in ' + (endTimestamp - startTimestamp) + ' ms')
|
|
77
|
+
const ringStartTimestamp = Date.now()
|
|
78
|
+
await nodes[i].joinRing()
|
|
79
|
+
const ringEndTimestamp = Date.now()
|
|
80
|
+
logger.info('Node ' + i + ' joined ring in ' + (ringEndTimestamp - ringStartTimestamp) + ' ms')
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/*
|
|
85
|
+
for (let i = 1; i < NUM_NODES; i++) {
|
|
86
|
+
// time to join the network
|
|
87
|
+
const ringStartTimestamp = Date.now()
|
|
88
|
+
await nodes[i].joinRing()
|
|
89
|
+
const ringEndTimestamp = Date.now()
|
|
90
|
+
logger.info('Node ' + i + ' joined ring in ' + (ringEndTimestamp - ringStartTimestamp) + ' ms')
|
|
91
|
+
}*/
|
|
92
|
+
|
|
93
|
+
for (let i = 1; i < NUM_NODES; i++) {
|
|
94
|
+
logger.info('Node ' + i + ', own region: ' + nodes[i].getLocalPeerDescriptor().region
|
|
95
|
+
+ '. Regions of closest ring peers, left: '
|
|
96
|
+
+ nodes[i].getClosestRingContactsTo(
|
|
97
|
+
getRingIdRawFromPeerDescriptor(nodes[i].getLocalPeerDescriptor()), 10).left.map((p) => p.region)
|
|
98
|
+
+ ', right: ' + nodes[i].getClosestRingContactsTo(getRingIdRawFromPeerDescriptor(
|
|
99
|
+
nodes[i].getLocalPeerDescriptor()), 10).right.map((p) => p.region)
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let minimumCorrectNeighbors = Number.MAX_SAFE_INTEGER
|
|
104
|
+
let sumCorrectNeighbors = 0
|
|
105
|
+
let sumKbucketSize = 1
|
|
106
|
+
|
|
107
|
+
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
108
|
+
let groundTruthString = 'groundTruthNeighb: '
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
110
|
+
for (let j = 0; j < groundTruth[i + ''].length; j++) {
|
|
111
|
+
groundTruthString += groundTruth[i + ''][j].name + ','
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const kademliaNeighbors = nodes[i].getClosestContacts(8).map((p) => getNodeIdFromPeerDescriptor(p))
|
|
115
|
+
|
|
116
|
+
let kadString = 'kademliaNeighbors: '
|
|
117
|
+
kademliaNeighbors.forEach((neighbor) => {
|
|
118
|
+
kadString += nodeIndicesById[neighbor] + ','
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
let correctNeighbors = 0
|
|
122
|
+
try {
|
|
123
|
+
for (let j = 0; j < groundTruth[i + ''].length; j++) {
|
|
124
|
+
if (groundTruth[i + ''][j].name != (nodeIndicesById[kademliaNeighbors[j]] + '')) {
|
|
125
|
+
break
|
|
126
|
+
}
|
|
127
|
+
correctNeighbors++
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
console.error('Node ' + getNodeIdFromPeerDescriptor(nodes[i].getLocalPeerDescriptor()) + ' had only '
|
|
131
|
+
+ kademliaNeighbors.length + ' kademlia neighbors')
|
|
132
|
+
}
|
|
133
|
+
if (correctNeighbors === 0) {
|
|
134
|
+
console.log('No correct neighbors found for node ' + i)
|
|
135
|
+
console.log(groundTruthString)
|
|
136
|
+
console.log(kadString)
|
|
137
|
+
}
|
|
138
|
+
if (correctNeighbors < minimumCorrectNeighbors) {
|
|
139
|
+
console.log('NEW MIN', i, correctNeighbors)
|
|
140
|
+
minimumCorrectNeighbors = correctNeighbors
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (i > 0) {
|
|
144
|
+
sumKbucketSize += nodes[i].getNeighborCount()
|
|
145
|
+
sumCorrectNeighbors += correctNeighbors
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const avgKbucketSize = sumKbucketSize / (NUM_NODES - 1)
|
|
150
|
+
const avgCorrectNeighbors = sumCorrectNeighbors / (NUM_NODES - 1)
|
|
151
|
+
|
|
152
|
+
console.log('----------- Simulation results ------------------')
|
|
153
|
+
console.log('Minimum correct neighbors: ' + minimumCorrectNeighbors)
|
|
154
|
+
console.log('Average correct neighbors: ' + avgCorrectNeighbors)
|
|
155
|
+
console.log('Average Kbucket size: ' + avgKbucketSize)
|
|
156
|
+
}, 240000)
|
|
157
|
+
})
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { wait } from '@streamr/utils'
|
|
4
4
|
import { WebsocketServer } from '../../src/connection/websocket/WebsocketServer'
|
|
5
|
-
import {
|
|
5
|
+
import { WebsocketClientConnection } from '../../src/connection/websocket/NodeWebsocketClientConnection'
|
|
6
6
|
|
|
7
7
|
// This 'test' is meant to be run manually using the following command:
|
|
8
8
|
// node --inspect ../../../../node_modules/.bin/jest WebsocketServerMemoryLeak.test.ts
|
|
@@ -26,7 +26,7 @@ describe('WebsocketServermemoryLeak', () => {
|
|
|
26
26
|
expect(port).toEqual(19792)
|
|
27
27
|
|
|
28
28
|
for (let i = 0; i < 10000; i++) {
|
|
29
|
-
const clientWebsocket:
|
|
29
|
+
const clientWebsocket: WebsocketClientConnection = new WebsocketClientConnection()
|
|
30
30
|
clientWebsocket.on('connected', () => {
|
|
31
31
|
console.log('clientWebsocket connected ' + i)
|
|
32
32
|
})
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ConnectivityResponse, PeerDescriptor } from '../../../src/proto/packages/dht/protos/DhtRpc'
|
|
2
|
+
import { createPeerDescriptor } from '../../../src/helpers/createPeerDescriptor'
|
|
3
|
+
import { NatType } from '../../../src/connection/ConnectionManager'
|
|
4
|
+
import { ipv4ToNumber, Logger } from '@streamr/utils'
|
|
5
|
+
import { RingContactList } from '../../../src/dht/contact/RingContactList'
|
|
6
|
+
import { getRingIdRawFromPeerDescriptor } from '../../../src/dht/contact/ringIdentifiers'
|
|
7
|
+
import { getRandomRegion } from '../../../src/connection/simulator/pings'
|
|
8
|
+
|
|
9
|
+
const logger = new Logger(module)
|
|
10
|
+
|
|
11
|
+
function ipv4ToString(ip: number): string {
|
|
12
|
+
return [
|
|
13
|
+
(ip >>> 24) & 0xFF,
|
|
14
|
+
(ip >>> 16) & 0xFF,
|
|
15
|
+
(ip >>> 8) & 0xFF,
|
|
16
|
+
ip & 0xFF
|
|
17
|
+
].join('.')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class MockNode {
|
|
21
|
+
private readonly peerDescriptor: PeerDescriptor
|
|
22
|
+
|
|
23
|
+
constructor(_region: number, ipAddress: string) {
|
|
24
|
+
|
|
25
|
+
const connectivityResponse: ConnectivityResponse = {
|
|
26
|
+
host: 'localhost',
|
|
27
|
+
natType: NatType.UNKNOWN,
|
|
28
|
+
ipAddress: ipv4ToNumber(ipAddress),
|
|
29
|
+
version: '0.0.0'
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
this.peerDescriptor = createPeerDescriptor(connectivityResponse, getRandomRegion())
|
|
33
|
+
logger.info(ipv4ToString(this.peerDescriptor.ipAddress!))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public getPeerDescriptor(): PeerDescriptor {
|
|
37
|
+
return this.peerDescriptor
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// populate with mock ip addresses
|
|
42
|
+
const mockData: Array< [number, string] > = [
|
|
43
|
+
[0, '5.2.4.2'],
|
|
44
|
+
[0, '6.23.2.4'],
|
|
45
|
+
[0, '7.2.4.2'],
|
|
46
|
+
[0, '8.23.2.4'],
|
|
47
|
+
[0, '9.3.2.4'],
|
|
48
|
+
[0, '10.3.2.4'],
|
|
49
|
+
[0, '24.23.2.4'],
|
|
50
|
+
[0, '31.23.2.4'],
|
|
51
|
+
[0, '33.2.4.2'],
|
|
52
|
+
[0, '35.3.2.4'],
|
|
53
|
+
[0, '37.23.2.4'],
|
|
54
|
+
[0, '39.2.4.2'],
|
|
55
|
+
[0, '42.3.2.4'],
|
|
56
|
+
[0, '46.2.4.2'],
|
|
57
|
+
[0, '48.3.2.4'],
|
|
58
|
+
[0, '50.23.2.4']
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
const mockNodes: MockNode[] = mockData.map(([region, ipAddress]) => new MockNode(region, ipAddress))
|
|
62
|
+
const referenceNode = mockNodes[5]
|
|
63
|
+
const ringContactList: RingContactList<MockNode> = new RingContactList<MockNode>(
|
|
64
|
+
getRingIdRawFromPeerDescriptor(referenceNode.getPeerDescriptor()),
|
|
65
|
+
false
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
mockNodes.forEach((node) => ringContactList.addContact(node))
|
|
69
|
+
|
|
70
|
+
ringContactList.getClosestContacts().left.forEach((node) => logger.info(ipv4ToString(node.getPeerDescriptor().ipAddress!)))
|
|
71
|
+
logger.info('reference node: ' + ipv4ToString(referenceNode.getPeerDescriptor().ipAddress!))
|
|
72
|
+
ringContactList.getClosestContacts().right.forEach((node) => logger.info(ipv4ToString(node.getPeerDescriptor().ipAddress!)))
|
|
@@ -3,8 +3,8 @@ import crypto from 'crypto'
|
|
|
3
3
|
import KBucket from 'k-bucket'
|
|
4
4
|
import { DhtAddressRaw } from '../../src/identifiers'
|
|
5
5
|
|
|
6
|
-
const ID_LENGTH =
|
|
7
|
-
const NUM_NODES =
|
|
6
|
+
const ID_LENGTH = 20
|
|
7
|
+
const NUM_NODES = 900
|
|
8
8
|
const NUM_NEAREST = 10
|
|
9
9
|
|
|
10
10
|
const generateId = function(): DhtAddressRaw {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import LeakDetector from 'jest-leak-detector'
|
|
2
2
|
import { waitForCondition } from '@streamr/utils'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
|
-
import { Message
|
|
4
|
+
import { Message } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
6
6
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
7
7
|
import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
@@ -48,7 +48,6 @@ describe('memory leak', () => {
|
|
|
48
48
|
const msg: Message = {
|
|
49
49
|
serviceId: 'mock-service-id',
|
|
50
50
|
targetDescriptor: receiver.getLocalPeerDescriptor(),
|
|
51
|
-
messageType: MessageType.RPC,
|
|
52
51
|
messageId: 'mock-message-id',
|
|
53
52
|
body: {
|
|
54
53
|
oneofKind: 'rpcMessage',
|
|
@@ -6,10 +6,12 @@ import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
|
6
6
|
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
7
7
|
import { createPeerDescriptor } from '../../src/helpers/createPeerDescriptor'
|
|
8
8
|
import { createRandomDhtAddress, getRawFromDhtAddress } from '../../src/identifiers'
|
|
9
|
-
import { ConnectivityResponse, Message,
|
|
9
|
+
import { ConnectivityResponse, Message, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
10
10
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
11
11
|
import { TransportEvents } from '../../src/transport/ITransport'
|
|
12
12
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
13
|
+
import { getRandomRegion } from '../../src/connection/simulator/pings'
|
|
14
|
+
import { range } from 'lodash'
|
|
13
15
|
|
|
14
16
|
const SERVICE_ID = 'demo'
|
|
15
17
|
|
|
@@ -40,7 +42,7 @@ describe('ConnectionManager', () => {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
beforeEach(() => {
|
|
43
|
-
createLocalPeerDescriptor = jest.fn().mockImplementation((response) => createPeerDescriptor(response))
|
|
45
|
+
createLocalPeerDescriptor = jest.fn().mockImplementation((response) => createPeerDescriptor(response, getRandomRegion()))
|
|
44
46
|
})
|
|
45
47
|
|
|
46
48
|
beforeAll(async () => {
|
|
@@ -85,6 +87,27 @@ describe('ConnectionManager', () => {
|
|
|
85
87
|
await connectionManager.stop()
|
|
86
88
|
}, 15000)
|
|
87
89
|
|
|
90
|
+
it('Succesfully connectivityChecks if at least one entry point is online', async () => {
|
|
91
|
+
// Create offline PeerDescriptors
|
|
92
|
+
const entryPoints = range(4).map((i) => {
|
|
93
|
+
return createMockPeerDescriptor({
|
|
94
|
+
websocket: { host: '127.0.0.1', port: 12345 + i, tls: false }
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
entryPoints.push(createMockPeerDescriptor({
|
|
98
|
+
websocket: { host: '127.0.0.1', port: 9998, tls: false }
|
|
99
|
+
}))
|
|
100
|
+
const connectionManager = createConnectionManager({
|
|
101
|
+
transport: mockTransport,
|
|
102
|
+
websocketPortRange: { min: 9998, max: 9998 },
|
|
103
|
+
entryPoints
|
|
104
|
+
})
|
|
105
|
+
await connectionManager.start()
|
|
106
|
+
expect(createLocalPeerDescriptor.mock.calls[0][0].host).toEqual('127.0.0.1')
|
|
107
|
+
|
|
108
|
+
await connectionManager.stop()
|
|
109
|
+
}, 20000)
|
|
110
|
+
|
|
88
111
|
it('Can probe connectivity in open internet', async () => {
|
|
89
112
|
const connectionManager1 = createConnectionManager({
|
|
90
113
|
transport: mockTransport,
|
|
@@ -134,7 +157,6 @@ describe('ConnectionManager', () => {
|
|
|
134
157
|
|
|
135
158
|
const msg: Message = {
|
|
136
159
|
serviceId: SERVICE_ID,
|
|
137
|
-
messageType: MessageType.RPC,
|
|
138
160
|
messageId: '1',
|
|
139
161
|
body: {
|
|
140
162
|
oneofKind: 'rpcMessage',
|
|
@@ -144,7 +166,7 @@ describe('ConnectionManager', () => {
|
|
|
144
166
|
|
|
145
167
|
const promise = new Promise<void>((resolve, _reject) => {
|
|
146
168
|
connectionManager2.on('message', async (message: Message) => {
|
|
147
|
-
expect(message.
|
|
169
|
+
expect(message.body.oneofKind).toBe('rpcMessage')
|
|
148
170
|
resolve()
|
|
149
171
|
})
|
|
150
172
|
})
|
|
@@ -193,7 +215,6 @@ describe('ConnectionManager', () => {
|
|
|
193
215
|
|
|
194
216
|
const msg: Message = {
|
|
195
217
|
serviceId: SERVICE_ID,
|
|
196
|
-
messageType: MessageType.RPC,
|
|
197
218
|
messageId: '1',
|
|
198
219
|
body: {
|
|
199
220
|
oneofKind: 'rpcMessage',
|
|
@@ -217,7 +238,7 @@ describe('ConnectionManager', () => {
|
|
|
217
238
|
|
|
218
239
|
const promise = new Promise<void>((resolve, _reject) => {
|
|
219
240
|
connectionManager2.on('message', async (message: Message) => {
|
|
220
|
-
expect(message.
|
|
241
|
+
expect(message.body.oneofKind).toBe('rpcMessage')
|
|
221
242
|
resolve()
|
|
222
243
|
})
|
|
223
244
|
})
|
|
@@ -244,7 +265,6 @@ describe('ConnectionManager', () => {
|
|
|
244
265
|
|
|
245
266
|
const msg: Message = {
|
|
246
267
|
serviceId: SERVICE_ID,
|
|
247
|
-
messageType: MessageType.RPC,
|
|
248
268
|
messageId: '1',
|
|
249
269
|
body: {
|
|
250
270
|
oneofKind: 'rpcMessage',
|
|
@@ -254,7 +274,7 @@ describe('ConnectionManager', () => {
|
|
|
254
274
|
|
|
255
275
|
const dataPromise = new Promise<void>((resolve, _reject) => {
|
|
256
276
|
connectionManager4.on('message', async (message: Message) => {
|
|
257
|
-
expect(message.
|
|
277
|
+
expect(message.body.oneofKind).toBe('rpcMessage')
|
|
258
278
|
resolve()
|
|
259
279
|
})
|
|
260
280
|
})
|
|
@@ -309,7 +329,6 @@ describe('ConnectionManager', () => {
|
|
|
309
329
|
peerDescriptor.nodeId = new Uint8Array([12, 12, 12, 12])
|
|
310
330
|
const msg: Message = {
|
|
311
331
|
serviceId: SERVICE_ID,
|
|
312
|
-
messageType: MessageType.RPC,
|
|
313
332
|
messageId: '1',
|
|
314
333
|
targetDescriptor: peerDescriptor,
|
|
315
334
|
body: {
|
|
@@ -360,7 +379,6 @@ describe('ConnectionManager', () => {
|
|
|
360
379
|
|
|
361
380
|
const msg: Message = {
|
|
362
381
|
serviceId: SERVICE_ID,
|
|
363
|
-
messageType: MessageType.RPC,
|
|
364
382
|
messageId: '1',
|
|
365
383
|
targetDescriptor: {
|
|
366
384
|
// This is not the correct nodeId of peerDescriptor2
|
|
@@ -4,7 +4,7 @@ import { DefaultConnectorFacade } from '../../src/connection/ConnectorFacade'
|
|
|
4
4
|
import { MockTransport } from '../utils/mock/Transport'
|
|
5
5
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
6
|
import { sendConnectivityRequest } from '../../src/connection/connectivityChecker'
|
|
7
|
-
import {
|
|
7
|
+
import { LOCAL_PROTOCOL_VERSION } from '../../src/helpers/version'
|
|
8
8
|
|
|
9
9
|
describe('ConnectivityChecking', () => {
|
|
10
10
|
|
|
@@ -46,19 +46,7 @@ describe('ConnectivityChecking', () => {
|
|
|
46
46
|
tls: false,
|
|
47
47
|
selfSigned: false
|
|
48
48
|
}
|
|
49
|
-
const response = await sendConnectivityRequest(request, server.getLocalPeerDescriptor()
|
|
50
|
-
expect(response.version).toEqual(
|
|
49
|
+
const response = await sendConnectivityRequest(request, server.getLocalPeerDescriptor())
|
|
50
|
+
expect(response.version).toEqual(LOCAL_PROTOCOL_VERSION)
|
|
51
51
|
})
|
|
52
|
-
|
|
53
|
-
it('connectivityCheck with incompatible version', async () => {
|
|
54
|
-
const request = {
|
|
55
|
-
host: HOST,
|
|
56
|
-
port: PORT,
|
|
57
|
-
tls: false,
|
|
58
|
-
selfSigned: false
|
|
59
|
-
}
|
|
60
|
-
await expect(sendConnectivityRequest(request, server.getLocalPeerDescriptor(), '0.0.1'))
|
|
61
|
-
.toReject()
|
|
62
|
-
})
|
|
63
|
-
|
|
64
52
|
})
|
|
@@ -25,22 +25,22 @@ describe('DhtNodeExternalApi', () => {
|
|
|
25
25
|
simulator.stop()
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
it('
|
|
28
|
+
it('fetch data happy path', async () => {
|
|
29
29
|
const entry = createMockDataEntry()
|
|
30
30
|
await dhtNode1.storeDataToDht(getDhtAddressFromRaw(entry.key), entry.data!)
|
|
31
|
-
const foundData = await remote.
|
|
31
|
+
const foundData = await remote.fetchDataFromDhtViaPeer(getDhtAddressFromRaw(entry.key), dhtNode1.getLocalPeerDescriptor())
|
|
32
32
|
expectEqualData(foundData[0], entry)
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
it('
|
|
36
|
-
const foundData = await remote.
|
|
35
|
+
it('fetch data returns empty array if no data found', async () => {
|
|
36
|
+
const foundData = await remote.fetchDataFromDhtViaPeer(createRandomDhtAddress(), dhtNode1.getLocalPeerDescriptor())
|
|
37
37
|
expect(foundData).toEqual([])
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
it('external store data happy path', async () => {
|
|
41
41
|
const entry = createMockDataEntry()
|
|
42
|
-
await remote.
|
|
43
|
-
const foundData = await remote.
|
|
42
|
+
await remote.storeDataToDhtViaPeer(getDhtAddressFromRaw(entry.key), entry.data!, dhtNode1.getLocalPeerDescriptor())
|
|
43
|
+
const foundData = await remote.fetchDataFromDhtViaPeer(getDhtAddressFromRaw(entry.key), dhtNode1.getLocalPeerDescriptor())
|
|
44
44
|
expectEqualData(foundData[0], entry)
|
|
45
45
|
expect(getDhtAddressFromRaw(foundData[0].creator)).toEqual(getNodeIdFromPeerDescriptor(remote.getLocalPeerDescriptor()))
|
|
46
46
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import { PeerDescriptor
|
|
4
|
-
import { createMockConnectionDhtNode,
|
|
3
|
+
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
|
+
import { createMockConnectionDhtNode, waitForStableTopology } from '../utils/utils'
|
|
5
5
|
import { getDhtAddressFromRaw, getNodeIdFromPeerDescriptor, getRawFromDhtAddress } from '../../src/identifiers'
|
|
6
6
|
|
|
7
7
|
const NUM_NODES = 100
|
|
@@ -25,7 +25,7 @@ describe('Find correctness', () => {
|
|
|
25
25
|
}
|
|
26
26
|
await entryPoint.joinDht([entrypointDescriptor])
|
|
27
27
|
await Promise.all(nodes.map((node) => node.joinDht([entrypointDescriptor])))
|
|
28
|
-
await
|
|
28
|
+
await waitForStableTopology(nodes, 20)
|
|
29
29
|
}, 90000)
|
|
30
30
|
|
|
31
31
|
afterEach(async () => {
|
|
@@ -37,9 +37,9 @@ describe('Find correctness', () => {
|
|
|
37
37
|
|
|
38
38
|
it('Entrypoint can find a node from the network (exact match)', async () => {
|
|
39
39
|
const targetId = getRawFromDhtAddress(nodes[45].getNodeId())
|
|
40
|
-
const
|
|
41
|
-
expect(
|
|
42
|
-
expect(getDhtAddressFromRaw(targetId)).toEqual(getNodeIdFromPeerDescriptor(
|
|
40
|
+
const closestNodes = await entryPoint.findClosestNodesFromDht(getDhtAddressFromRaw(targetId))
|
|
41
|
+
expect(closestNodes.length).toBeGreaterThanOrEqual(5)
|
|
42
|
+
expect(getDhtAddressFromRaw(targetId)).toEqual(getNodeIdFromPeerDescriptor(closestNodes[0]))
|
|
43
43
|
}, 30000)
|
|
44
44
|
|
|
45
45
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
|
-
import { createMockConnectionDhtNode,
|
|
4
|
+
import { createMockConnectionDhtNode, waitForStableTopology } from '../utils/utils'
|
|
5
5
|
import { SortedContactList } from '../../src/dht/contact/SortedContactList'
|
|
6
6
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
7
7
|
import { DhtAddress, createRandomDhtAddress, getDhtAddressFromRaw, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
@@ -72,7 +72,7 @@ describe('Replicate data from node to node in DHT', () => {
|
|
|
72
72
|
}
|
|
73
73
|
})
|
|
74
74
|
)
|
|
75
|
-
await
|
|
75
|
+
await waitForStableTopology(nodes)
|
|
76
76
|
|
|
77
77
|
const data = getDataEntries(closest[0])
|
|
78
78
|
expect(data).toHaveLength(1)
|
|
@@ -87,7 +87,7 @@ describe('Replicate data from node to node in DHT', () => {
|
|
|
87
87
|
}
|
|
88
88
|
})
|
|
89
89
|
)
|
|
90
|
-
await
|
|
90
|
+
await waitForStableTopology(nodes)
|
|
91
91
|
|
|
92
92
|
const randomIndex = Math.floor(Math.random() * nodes.length)
|
|
93
93
|
const storerDescriptors = await nodes[randomIndex].storeDataToDht(getDhtAddressFromRaw(DATA.key), DATA.data!)
|
|
@@ -99,7 +99,7 @@ describe('Replicate data from node to node in DHT', () => {
|
|
|
99
99
|
}))
|
|
100
100
|
|
|
101
101
|
const randomNonStoppedNode = sample(nodes.filter((n) => !stoppedNodeIds.includes(n.getNodeId())))!
|
|
102
|
-
const data = await randomNonStoppedNode.
|
|
102
|
+
const data = await randomNonStoppedNode.fetchDataFromDht(getDhtAddressFromRaw(DATA.key))
|
|
103
103
|
expect(data).toHaveLength(1)
|
|
104
104
|
expectEqualData(data[0], DATA)
|
|
105
105
|
}, 180000)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DhtNode, Events as DhtNodeEvents } from '../../src/dht/DhtNode'
|
|
2
|
-
import { Message,
|
|
2
|
+
import { Message, NodeType, PeerDescriptor, RouteMessageWrapper } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
3
3
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
4
4
|
import { Logger, runAndWaitForEvents3, waitForCondition } from '@streamr/utils'
|
|
5
5
|
import { createMockConnectionDhtNode, createWrappedClosestPeersRequest } from '../utils/utils'
|
|
@@ -64,7 +64,6 @@ describe('Route Message With Mock Connections', () => {
|
|
|
64
64
|
const message: Message = {
|
|
65
65
|
serviceId: 'unknown',
|
|
66
66
|
messageId: v4(),
|
|
67
|
-
messageType: MessageType.RPC,
|
|
68
67
|
body: {
|
|
69
68
|
oneofKind: 'rpcMessage',
|
|
70
69
|
rpcMessage: rpcWrapper
|
|
@@ -98,7 +97,6 @@ describe('Route Message With Mock Connections', () => {
|
|
|
98
97
|
const message: Message = {
|
|
99
98
|
serviceId: 'unknown',
|
|
100
99
|
messageId: v4(),
|
|
101
|
-
messageType: MessageType.RPC,
|
|
102
100
|
body: {
|
|
103
101
|
oneofKind: 'rpcMessage',
|
|
104
102
|
rpcMessage: rpcWrapper
|
|
@@ -136,7 +134,6 @@ describe('Route Message With Mock Connections', () => {
|
|
|
136
134
|
const message: Message = {
|
|
137
135
|
serviceId: 'nonexisting_service',
|
|
138
136
|
messageId: v4(),
|
|
139
|
-
messageType: MessageType.RPC,
|
|
140
137
|
body: {
|
|
141
138
|
oneofKind: 'rpcMessage',
|
|
142
139
|
rpcMessage: rpcWrapper
|
|
@@ -171,7 +168,6 @@ describe('Route Message With Mock Connections', () => {
|
|
|
171
168
|
const closestPeersRequestMessage: Message = {
|
|
172
169
|
serviceId: 'unknown',
|
|
173
170
|
messageId: v4(),
|
|
174
|
-
messageType: MessageType.RPC,
|
|
175
171
|
body: {
|
|
176
172
|
oneofKind: 'rpcMessage',
|
|
177
173
|
rpcMessage: closestPeersRequest
|
|
@@ -202,7 +198,6 @@ describe('Route Message With Mock Connections', () => {
|
|
|
202
198
|
const requestMessage: Message = {
|
|
203
199
|
serviceId: 'layer0',
|
|
204
200
|
messageId: v4(),
|
|
205
|
-
messageType: MessageType.RPC,
|
|
206
201
|
body: {
|
|
207
202
|
oneofKind: 'rpcMessage',
|
|
208
203
|
rpcMessage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RpcCommunicator } from '@streamr/proto-rpc'
|
|
2
2
|
import { RouterRpcRemote } from '../../src/dht/routing/RouterRpcRemote'
|
|
3
|
-
import { Message,
|
|
3
|
+
import { Message, RouteMessageAck, RouteMessageWrapper } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { RouterRpcClient } from '../../src/proto/packages/dht/protos/DhtRpc.client'
|
|
5
5
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
6
6
|
import { createMockPeerDescriptor, createWrappedClosestPeersRequest, mockRouterRpc } from '../utils/utils'
|
|
@@ -34,7 +34,6 @@ describe('RemoteRouter', () => {
|
|
|
34
34
|
const routed: Message = {
|
|
35
35
|
serviceId: SERVICE_ID,
|
|
36
36
|
messageId: 'routed',
|
|
37
|
-
messageType: MessageType.RPC,
|
|
38
37
|
body: {
|
|
39
38
|
oneofKind: 'rpcMessage',
|
|
40
39
|
rpcMessage: rpcWrapper
|
|
@@ -58,7 +57,6 @@ describe('RemoteRouter', () => {
|
|
|
58
57
|
const routed: Message = {
|
|
59
58
|
serviceId: SERVICE_ID,
|
|
60
59
|
messageId: 'routed',
|
|
61
|
-
messageType: MessageType.RPC,
|
|
62
60
|
body: {
|
|
63
61
|
oneofKind: 'rpcMessage',
|
|
64
62
|
rpcMessage: rpcWrapper
|