@streamr/trackerless-network 0.0.1-tatum.6 → 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/package.json +10 -8
- package/dist/src/NetworkNode.js +1 -1
- package/dist/src/NetworkNode.js.map +1 -1
- package/dist/src/NetworkStack.d.ts +1 -3
- package/dist/src/NetworkStack.js +18 -47
- package/dist/src/NetworkStack.js.map +1 -1
- package/dist/src/identifiers.js +2 -2
- package/dist/src/identifiers.js.map +1 -1
- package/dist/src/logic/{StreamNodeServer.d.ts → DeliveryRpcLocal.d.ts} +6 -5
- package/dist/src/logic/{StreamNodeServer.js → DeliveryRpcLocal.js} +5 -5
- package/dist/src/logic/{StreamNodeServer.js.map → DeliveryRpcLocal.js.map} +1 -1
- package/dist/src/logic/{RemoteRandomGraphNode.d.ts → DeliveryRpcRemote.d.ts} +2 -2
- package/dist/src/logic/{RemoteRandomGraphNode.js → DeliveryRpcRemote.js} +5 -5
- package/dist/src/logic/DeliveryRpcRemote.js.map +1 -0
- package/dist/src/logic/{StreamPartEntryPointDiscovery.d.ts → EntryPointDiscovery.d.ts} +8 -10
- package/dist/src/logic/{StreamPartEntryPointDiscovery.js → EntryPointDiscovery.js} +14 -36
- package/dist/src/logic/EntryPointDiscovery.js.map +1 -0
- package/dist/src/logic/ILayer0.d.ts +3 -6
- package/dist/src/logic/NodeList.d.ts +10 -10
- package/dist/src/logic/NodeList.js.map +1 -1
- package/dist/src/logic/RandomGraphNode.d.ts +8 -12
- package/dist/src/logic/RandomGraphNode.js +41 -40
- package/dist/src/logic/RandomGraphNode.js.map +1 -1
- package/dist/src/logic/StreamrNode.d.ts +9 -12
- package/dist/src/logic/StreamrNode.js +53 -63
- package/dist/src/logic/StreamrNode.js.map +1 -1
- package/dist/src/logic/createRandomGraphNode.d.ts +6 -1
- package/dist/src/logic/createRandomGraphNode.js +17 -23
- package/dist/src/logic/createRandomGraphNode.js.map +1 -1
- package/dist/src/logic/formStreamPartDeliveryServiceId.d.ts +2 -0
- package/dist/src/logic/formStreamPartDeliveryServiceId.js +8 -0
- package/dist/src/logic/formStreamPartDeliveryServiceId.js.map +1 -0
- package/dist/src/logic/inspect/Inspector.d.ts +3 -2
- package/dist/src/logic/inspect/Inspector.js +5 -5
- package/dist/src/logic/inspect/Inspector.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/{HandshakerServer.d.ts → HandshakeRpcLocal.d.ts} +10 -10
- package/dist/src/logic/neighbor-discovery/{HandshakerServer.js → HandshakeRpcLocal.js} +13 -13
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -0
- package/dist/src/logic/neighbor-discovery/{RemoteHandshaker.d.ts → HandshakeRpcRemote.d.ts} +1 -1
- package/dist/src/logic/neighbor-discovery/{RemoteHandshaker.js → HandshakeRpcRemote.js} +8 -7
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -0
- package/dist/src/logic/neighbor-discovery/Handshaker.d.ts +8 -7
- package/dist/src/logic/neighbor-discovery/Handshaker.js +23 -24
- package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.d.ts +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.d.ts +3 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +5 -5
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/{NeighborUpdateManagerServer.d.ts → NeighborUpdateRpcLocal.d.ts} +6 -6
- package/dist/src/logic/neighbor-discovery/{NeighborUpdateManagerServer.js → NeighborUpdateRpcLocal.js} +9 -9
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +1 -0
- package/dist/src/logic/neighbor-discovery/{RemoteNeighborUpdateManager.d.ts → NeighborUpdateRpcRemote.d.ts} +1 -1
- package/dist/src/logic/neighbor-discovery/{RemoteNeighborUpdateManager.js → NeighborUpdateRpcRemote.js} +5 -5
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js.map +1 -0
- package/dist/src/logic/propagation/Propagation.js +2 -2
- package/dist/src/logic/propagation/Propagation.js.map +1 -1
- package/dist/src/logic/proxy/{ProxyStreamConnectionClient.d.ts → ProxyClient.d.ts} +6 -9
- package/dist/src/logic/proxy/{ProxyStreamConnectionClient.js → ProxyClient.js} +23 -21
- package/dist/src/logic/proxy/ProxyClient.js.map +1 -0
- package/dist/src/logic/proxy/{ProxyStreamConnectionServer.d.ts → ProxyConnectionRpcLocal.d.ts} +5 -5
- package/dist/src/logic/proxy/{ProxyStreamConnectionServer.js → ProxyConnectionRpcLocal.js} +6 -6
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -0
- package/dist/src/logic/proxy/{RemoteProxyServer.d.ts → ProxyConnectionRpcRemote.d.ts} +1 -1
- package/dist/src/logic/proxy/{RemoteProxyServer.js → ProxyConnectionRpcRemote.js} +4 -4
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.js.map +1 -0
- package/dist/src/logic/temporary-connection/{TemporaryConnectionRpcServer.d.ts → TemporaryConnectionRpcLocal.d.ts} +5 -4
- package/dist/src/logic/temporary-connection/{TemporaryConnectionRpcServer.js → TemporaryConnectionRpcLocal.js} +6 -6
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +1 -0
- package/dist/src/logic/temporary-connection/{RemoteTemporaryConnectionRpcServer.d.ts → TemporaryConnectionRpcRemote.d.ts} +1 -1
- package/dist/src/logic/temporary-connection/{RemoteTemporaryConnectionRpcServer.js → TemporaryConnectionRpcRemote.js} +4 -4
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js.map +1 -0
- 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/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.d.ts +4 -4
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js +7 -7
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js.map +1 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.d.ts +10 -10
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js +7 -7
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js.map +1 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.server.d.ts +2 -2
- package/dist/test/benchmark/first-message.js +10 -13
- package/dist/test/benchmark/first-message.js.map +1 -1
- package/dist/test/utils/utils.d.ts +5 -5
- package/dist/test/utils/utils.js +14 -13
- package/dist/test/utils/utils.js.map +1 -1
- package/package.json +10 -8
- package/protos/NetworkRpc.proto +5 -5
- package/src/NetworkNode.ts +1 -1
- package/src/NetworkStack.ts +20 -62
- package/src/identifiers.ts +3 -3
- package/src/logic/{StreamNodeServer.ts → DeliveryRpcLocal.ts} +8 -7
- package/src/logic/{RemoteRandomGraphNode.ts → DeliveryRpcRemote.ts} +3 -3
- package/src/logic/{StreamPartEntryPointDiscovery.ts → EntryPointDiscovery.ts} +18 -42
- package/src/logic/ILayer0.ts +3 -6
- package/src/logic/NodeList.ts +12 -12
- package/src/logic/RandomGraphNode.ts +61 -62
- package/src/logic/StreamrNode.ts +59 -73
- package/src/logic/createRandomGraphNode.ts +28 -26
- package/src/logic/formStreamPartDeliveryServiceId.ts +5 -0
- package/src/logic/inspect/Inspector.ts +8 -7
- package/src/logic/neighbor-discovery/{HandshakerServer.ts → HandshakeRpcLocal.ts} +20 -20
- package/src/logic/neighbor-discovery/{RemoteHandshaker.ts → HandshakeRpcRemote.ts} +6 -5
- package/src/logic/neighbor-discovery/Handshaker.ts +38 -38
- package/src/logic/neighbor-discovery/NeighborFinder.ts +2 -2
- package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +13 -10
- package/src/logic/neighbor-discovery/{NeighborUpdateManagerServer.ts → NeighborUpdateRpcLocal.ts} +15 -15
- package/src/logic/neighbor-discovery/{RemoteNeighborUpdateManager.ts → NeighborUpdateRpcRemote.ts} +2 -2
- package/src/logic/propagation/Propagation.ts +2 -2
- package/src/logic/proxy/{ProxyStreamConnectionClient.ts → ProxyClient.ts} +27 -27
- package/src/logic/proxy/{ProxyStreamConnectionServer.ts → ProxyConnectionRpcLocal.ts} +10 -11
- package/src/logic/proxy/{RemoteProxyServer.ts → ProxyConnectionRpcRemote.ts} +1 -1
- package/src/logic/temporary-connection/{TemporaryConnectionRpcServer.ts → TemporaryConnectionRpcLocal.ts} +11 -10
- package/src/logic/temporary-connection/{RemoteTemporaryConnectionRpcServer.ts → TemporaryConnectionRpcRemote.ts} +1 -1
- package/src/proto/packages/dht/protos/DhtRpc.ts +1 -6
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.client.ts +8 -8
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.server.ts +2 -2
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.ts +14 -14
- package/test/benchmark/first-message.ts +10 -13
- package/test/end-to-end/inspect.test.ts +12 -12
- package/test/end-to-end/proxy-and-full-node.test.ts +13 -14
- package/test/end-to-end/proxy-connections.test.ts +9 -11
- package/test/end-to-end/proxy-key-exchange.test.ts +12 -13
- package/test/end-to-end/random-graph-with-real-connections.test.ts +7 -7
- package/test/end-to-end/webrtc-full-node-network.test.ts +8 -8
- package/test/end-to-end/websocket-full-node-network.test.ts +8 -10
- package/test/integration/{RemoteRandomGraphNode.test.ts → DeliveryRpcRemote.test.ts} +17 -14
- package/test/integration/{RemoteHandshaker.test.ts → HandshakeRpcRemote.test.ts} +10 -9
- package/test/integration/Handshakes.test.ts +23 -20
- package/test/integration/Inspect.test.ts +3 -2
- package/test/integration/{RemoteNeighborUpdateManager.test.ts → NeighborUpdateRpcRemote.test.ts} +12 -10
- package/test/integration/NetworkNode.test.ts +9 -8
- package/test/integration/NetworkRpc.test.ts +5 -7
- package/test/integration/NetworkStack.test.ts +13 -15
- package/test/integration/Propagation.test.ts +2 -2
- package/test/integration/RandomGraphNode-Layer1Node-Latencies.test.ts +10 -8
- package/test/integration/RandomGraphNode-Layer1Node.test.ts +17 -17
- package/test/integration/StreamrNode.test.ts +5 -3
- package/test/integration/joining-streams-on-offline-peers.test.ts +16 -18
- package/test/integration/stream-without-default-entrypoints.test.ts +11 -13
- package/test/unit/{StreamNodeServer.test.ts → DeliveryRpcLocal.test.ts} +8 -8
- package/test/unit/{StreamPartEntrypointDiscovery.test.ts → EntrypointDiscovery.test.ts} +23 -40
- package/test/unit/{HandshakerServer.test.ts → HandshakeRpcLocal.test.ts} +26 -24
- package/test/unit/Handshaker.test.ts +10 -8
- package/test/unit/Inspector.test.ts +4 -3
- package/test/unit/NeighborFinder.test.ts +5 -5
- package/test/unit/NodeList.test.ts +22 -13
- package/test/unit/{RemoteProxyServer.test.ts → ProxyConnectionRpcRemote.test.ts} +4 -4
- package/test/unit/RandomGraphNode.test.ts +6 -5
- package/test/unit/StreamMessageTranslator.test.ts +10 -9
- package/test/unit/StreamrNode.test.ts +8 -8
- package/test/utils/mock/MockLayer0.ts +7 -26
- package/test/utils/mock/MockLayer1.ts +3 -8
- package/test/utils/mock/MockNeighborFinder.ts +1 -2
- package/test/utils/mock/MockNeighborUpdateManager.ts +1 -2
- package/test/utils/mock/Transport.ts +2 -2
- package/test/utils/utils.ts +13 -12
- package/dist/src/logic/RemoteRandomGraphNode.js.map +0 -1
- package/dist/src/logic/StreamPartEntryPointDiscovery.js.map +0 -1
- package/dist/src/logic/neighbor-discovery/HandshakerServer.js.map +0 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManagerServer.js.map +0 -1
- package/dist/src/logic/neighbor-discovery/RemoteHandshaker.js.map +0 -1
- package/dist/src/logic/neighbor-discovery/RemoteNeighborUpdateManager.js.map +0 -1
- package/dist/src/logic/proxy/ProxyStreamConnectionClient.js.map +0 -1
- package/dist/src/logic/proxy/ProxyStreamConnectionServer.js.map +0 -1
- package/dist/src/logic/proxy/RemoteProxyServer.js.map +0 -1
- package/dist/src/logic/temporary-connection/RemoteTemporaryConnectionRpcServer.js.map +0 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcServer.js.map +0 -1
|
@@ -1,42 +1,38 @@
|
|
|
1
1
|
import { NodeType, PeerDescriptor, Simulator, SimulatorTransport, LatencyType } from '@streamr/dht'
|
|
2
2
|
import { NetworkStack } from '../../src/NetworkStack'
|
|
3
|
-
import { streamPartIdToDataKey } from '../../src/logic/
|
|
3
|
+
import { streamPartIdToDataKey } from '../../src/logic/EntryPointDiscovery'
|
|
4
4
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
5
5
|
import { Any } from '../../src/proto/google/protobuf/any'
|
|
6
6
|
import { createStreamMessage } from '../utils/utils'
|
|
7
7
|
import { waitForCondition } from '@streamr/utils'
|
|
8
8
|
import { randomEthereumAddress } from '@streamr/test-utils'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const STREAM_PART_ID = StreamPartIDUtils.parse('stream#0')
|
|
11
|
+
|
|
12
|
+
describe('Joining stream parts on offline nodes', () => {
|
|
12
13
|
|
|
13
14
|
const entryPointPeerDescriptor: PeerDescriptor = {
|
|
14
15
|
kademliaId: new Uint8Array([1, 2, 3]),
|
|
15
|
-
nodeName: 'entrypoint',
|
|
16
16
|
type: NodeType.NODEJS
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const node1PeerDescriptor: PeerDescriptor = {
|
|
20
20
|
kademliaId: new Uint8Array([1, 1, 1]),
|
|
21
|
-
nodeName: 'node1',
|
|
22
21
|
type: NodeType.NODEJS
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
const node2PeerDescriptor: PeerDescriptor = {
|
|
26
25
|
kademliaId: new Uint8Array([2, 2, 2]),
|
|
27
|
-
nodeName: 'node2',
|
|
28
26
|
type: NodeType.NODEJS
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
const offlineDescriptor1: PeerDescriptor = {
|
|
32
30
|
kademliaId: new Uint8Array([3, 3, 3]),
|
|
33
|
-
nodeName: 'offline',
|
|
34
31
|
type: NodeType.NODEJS
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
const offlineDescriptor2: PeerDescriptor = {
|
|
38
35
|
kademliaId: new Uint8Array([4, 4, 4]),
|
|
39
|
-
nodeName: 'offline',
|
|
40
36
|
type: NodeType.NODEJS
|
|
41
37
|
}
|
|
42
38
|
|
|
@@ -50,28 +46,30 @@ describe('Joining streams on offline nodes', () => {
|
|
|
50
46
|
const entryPointTransport = new SimulatorTransport(entryPointPeerDescriptor, simulator)
|
|
51
47
|
entryPoint = new NetworkStack({
|
|
52
48
|
layer0: {
|
|
53
|
-
|
|
49
|
+
transport: entryPointTransport,
|
|
54
50
|
peerDescriptor: entryPointPeerDescriptor,
|
|
55
51
|
entryPoints: [entryPointPeerDescriptor]
|
|
56
52
|
}
|
|
57
53
|
})
|
|
58
|
-
|
|
54
|
+
const node1Transport = new SimulatorTransport(node1PeerDescriptor, simulator)
|
|
59
55
|
node1 = new NetworkStack({
|
|
60
56
|
layer0: {
|
|
61
|
-
|
|
57
|
+
transport: node1Transport,
|
|
62
58
|
peerDescriptor: node1PeerDescriptor,
|
|
63
59
|
entryPoints: [entryPointPeerDescriptor]
|
|
64
60
|
}
|
|
65
61
|
})
|
|
66
|
-
|
|
62
|
+
const node2Transport = new SimulatorTransport(node2PeerDescriptor, simulator)
|
|
67
63
|
node2 = new NetworkStack({
|
|
68
64
|
layer0: {
|
|
69
|
-
|
|
65
|
+
transport: node2Transport,
|
|
70
66
|
peerDescriptor: node2PeerDescriptor,
|
|
71
67
|
entryPoints: [entryPointPeerDescriptor]
|
|
72
68
|
}
|
|
73
69
|
})
|
|
74
|
-
|
|
70
|
+
await entryPointTransport.start()
|
|
71
|
+
await node1Transport.start()
|
|
72
|
+
await node2Transport.start()
|
|
75
73
|
await entryPoint.start()
|
|
76
74
|
await node1.start()
|
|
77
75
|
await node2.start()
|
|
@@ -88,12 +86,12 @@ describe('Joining streams on offline nodes', () => {
|
|
|
88
86
|
let messageReceived = false
|
|
89
87
|
|
|
90
88
|
// store offline peer descriptors to DHT
|
|
91
|
-
await entryPoint.getLayer0DhtNode().storeDataToDht(streamPartIdToDataKey(
|
|
92
|
-
await entryPoint.getLayer0DhtNode().storeDataToDht(streamPartIdToDataKey(
|
|
89
|
+
await entryPoint.getLayer0DhtNode().storeDataToDht(streamPartIdToDataKey(STREAM_PART_ID), Any.pack(offlineDescriptor1, PeerDescriptor))
|
|
90
|
+
await entryPoint.getLayer0DhtNode().storeDataToDht(streamPartIdToDataKey(STREAM_PART_ID), Any.pack(offlineDescriptor2, PeerDescriptor))
|
|
93
91
|
|
|
94
|
-
node1.getStreamrNode().joinStreamPart(
|
|
92
|
+
node1.getStreamrNode().joinStreamPart(STREAM_PART_ID)
|
|
95
93
|
node1.getStreamrNode().on('newMessage', () => { messageReceived = true })
|
|
96
|
-
const msg = createStreamMessage(JSON.stringify({ hello: 'WORLD' }),
|
|
94
|
+
const msg = createStreamMessage(JSON.stringify({ hello: 'WORLD' }), STREAM_PART_ID, randomEthereumAddress())
|
|
97
95
|
node2.getStreamrNode().broadcast(msg)
|
|
98
96
|
await waitForCondition(() => messageReceived, 40000)
|
|
99
97
|
}, 60000)
|
|
@@ -4,13 +4,12 @@ import {
|
|
|
4
4
|
MessageRef,
|
|
5
5
|
StreamMessage,
|
|
6
6
|
StreamMessageType,
|
|
7
|
-
StreamPartIDUtils
|
|
8
|
-
toStreamID
|
|
7
|
+
StreamPartIDUtils
|
|
9
8
|
} from '@streamr/protocol'
|
|
10
9
|
import { EthereumAddress, hexToBinary, utf8ToBinary, waitForCondition } from '@streamr/utils'
|
|
11
10
|
import { range } from 'lodash'
|
|
12
11
|
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
13
|
-
import { streamPartIdToDataKey } from '../../src/logic/
|
|
12
|
+
import { streamPartIdToDataKey } from '../../src/logic/EntryPointDiscovery'
|
|
14
13
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
15
14
|
|
|
16
15
|
const STREAM_PART_ID = StreamPartIDUtils.parse('test#0')
|
|
@@ -22,14 +21,13 @@ describe('stream without default entrypoints', () => {
|
|
|
22
21
|
let numOfReceivedMessages: number
|
|
23
22
|
const entryPointPeerDescriptor: PeerDescriptor = {
|
|
24
23
|
kademliaId: new Uint8Array([1, 2, 3]),
|
|
25
|
-
nodeName: 'entrypoint',
|
|
26
24
|
type: NodeType.NODEJS
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
const streamMessage = new StreamMessage({
|
|
30
28
|
messageId: new MessageID(
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
StreamPartIDUtils.getStreamID(STREAM_PART_ID),
|
|
30
|
+
StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
33
31
|
666,
|
|
34
32
|
0,
|
|
35
33
|
'0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' as EthereumAddress,
|
|
@@ -49,23 +47,23 @@ describe('stream without default entrypoints', () => {
|
|
|
49
47
|
nodes = []
|
|
50
48
|
numOfReceivedMessages = 0
|
|
51
49
|
const entryPointTransport = new SimulatorTransport(entryPointPeerDescriptor, simulator)
|
|
50
|
+
await entryPointTransport.start()
|
|
52
51
|
entrypoint = createNetworkNode({
|
|
53
52
|
layer0: {
|
|
54
|
-
|
|
53
|
+
transport: entryPointTransport,
|
|
55
54
|
peerDescriptor: entryPointPeerDescriptor,
|
|
56
55
|
entryPoints: [entryPointPeerDescriptor]
|
|
57
56
|
}
|
|
58
57
|
})
|
|
59
58
|
await entrypoint.start()
|
|
60
|
-
await Promise.all(range(20).map(async (
|
|
61
|
-
const peerDescriptor = createMockPeerDescriptor(
|
|
62
|
-
nodeName: `${i}`
|
|
63
|
-
})
|
|
59
|
+
await Promise.all(range(20).map(async () => {
|
|
60
|
+
const peerDescriptor = createMockPeerDescriptor()
|
|
64
61
|
const transport = new SimulatorTransport(peerDescriptor, simulator)
|
|
62
|
+
await transport.start()
|
|
65
63
|
const node = createNetworkNode({
|
|
66
64
|
layer0: {
|
|
67
65
|
peerDescriptor,
|
|
68
|
-
|
|
66
|
+
transport,
|
|
69
67
|
entryPoints: [entryPointPeerDescriptor]
|
|
70
68
|
}
|
|
71
69
|
})
|
|
@@ -122,7 +120,7 @@ describe('stream without default entrypoints', () => {
|
|
|
122
120
|
}
|
|
123
121
|
await waitForCondition(async () => {
|
|
124
122
|
const entryPointData = await nodes[15].stack.getLayer0DhtNode().getDataFromDht(streamPartIdToDataKey(STREAM_PART_ID))
|
|
125
|
-
return entryPointData.
|
|
123
|
+
return entryPointData.length >= 7
|
|
126
124
|
}, 15000)
|
|
127
125
|
|
|
128
126
|
}, 90000)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ListeningRpcCommunicator } from '@streamr/dht'
|
|
2
2
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
3
3
|
import { randomEthereumAddress } from '@streamr/test-utils'
|
|
4
|
-
import {
|
|
4
|
+
import { DeliveryRpcLocal } from '../../src/logic/DeliveryRpcLocal'
|
|
5
5
|
import { LeaveStreamPartNotice } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
6
6
|
import { MockTransport } from '../utils/mock/Transport'
|
|
7
7
|
import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
|
|
8
8
|
|
|
9
|
-
describe('
|
|
9
|
+
describe('DeliveryRpcLocal', () => {
|
|
10
10
|
|
|
11
|
-
let
|
|
11
|
+
let rpcLocal: DeliveryRpcLocal
|
|
12
12
|
const peerDescriptor = createMockPeerDescriptor()
|
|
13
13
|
|
|
14
14
|
const mockSender = createMockPeerDescriptor()
|
|
@@ -30,19 +30,19 @@ describe('StreamNodeServer', () => {
|
|
|
30
30
|
mockOnLeaveNotice = jest.fn((_m) => {})
|
|
31
31
|
mockMarkForInspection = jest.fn((_m) => {})
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
rpcLocal = new DeliveryRpcLocal({
|
|
34
34
|
markAndCheckDuplicate: mockDuplicateCheck,
|
|
35
35
|
broadcast: mockBroadcast,
|
|
36
36
|
onLeaveNotice: mockOnLeaveNotice,
|
|
37
37
|
markForInspection: mockMarkForInspection,
|
|
38
38
|
ownPeerDescriptor: peerDescriptor,
|
|
39
|
-
|
|
39
|
+
streamPartId: StreamPartIDUtils.parse('stream#0'),
|
|
40
40
|
rpcCommunicator: new ListeningRpcCommunicator('random-graph-node', new MockTransport())
|
|
41
41
|
})
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
it('Server sendStreamMessage()', async () => {
|
|
45
|
-
await
|
|
45
|
+
await rpcLocal.sendStreamMessage(message, { incomingSourceDescriptor: mockSender } as any)
|
|
46
46
|
expect(mockDuplicateCheck).toHaveBeenCalledTimes(1)
|
|
47
47
|
expect(mockBroadcast).toHaveBeenCalledTimes(1)
|
|
48
48
|
expect(mockMarkForInspection).toHaveBeenCalledTimes(1)
|
|
@@ -50,9 +50,9 @@ describe('StreamNodeServer', () => {
|
|
|
50
50
|
|
|
51
51
|
it('Server leaveStreamPartNotice()', async () => {
|
|
52
52
|
const leaveNotice: LeaveStreamPartNotice = {
|
|
53
|
-
|
|
53
|
+
streamPartId: StreamPartIDUtils.parse('stream#0')
|
|
54
54
|
}
|
|
55
|
-
await
|
|
55
|
+
await rpcLocal.leaveStreamPartNotice(leaveNotice, { incomingSourceDescriptor: mockSender } as any)
|
|
56
56
|
expect(mockOnLeaveNotice).toHaveBeenCalledTimes(1)
|
|
57
57
|
})
|
|
58
58
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { PeerDescriptor,
|
|
1
|
+
import { PeerDescriptor, areEqualPeerDescriptors } from '@streamr/dht'
|
|
2
2
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
3
3
|
import { wait } from '@streamr/utils'
|
|
4
4
|
import { range } from 'lodash'
|
|
5
|
-
import {
|
|
6
|
-
import { StreamPartEntryPointDiscovery } from '../../src/logic/StreamPartEntryPointDiscovery'
|
|
5
|
+
import { EntryPointDiscovery } from '../../src/logic/EntryPointDiscovery'
|
|
7
6
|
import { Any } from '../../src/proto/google/protobuf/any'
|
|
8
7
|
import { DataEntry } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
9
8
|
import { MockLayer1 } from '../utils/mock/MockLayer1'
|
|
@@ -11,18 +10,14 @@ import { createMockPeerDescriptor } from '../utils/utils'
|
|
|
11
10
|
|
|
12
11
|
const STREAM_PART_ID = StreamPartIDUtils.parse('stream#0')
|
|
13
12
|
|
|
14
|
-
describe('
|
|
13
|
+
describe('EntryPointDiscovery', () => {
|
|
15
14
|
|
|
16
|
-
let entryPointDiscoveryWithData:
|
|
17
|
-
let entryPointDiscoveryWithoutData:
|
|
15
|
+
let entryPointDiscoveryWithData: EntryPointDiscovery
|
|
16
|
+
let entryPointDiscoveryWithoutData: EntryPointDiscovery
|
|
18
17
|
let storeCalled: number
|
|
19
18
|
|
|
20
|
-
const peerDescriptor = createMockPeerDescriptor(
|
|
21
|
-
|
|
22
|
-
})
|
|
23
|
-
const deletedPeerDescriptor = createMockPeerDescriptor({
|
|
24
|
-
nodeName: 'deleted'
|
|
25
|
-
})
|
|
19
|
+
const peerDescriptor = createMockPeerDescriptor()
|
|
20
|
+
const deletedPeerDescriptor = createMockPeerDescriptor()
|
|
26
21
|
|
|
27
22
|
const fakeData: DataEntry = {
|
|
28
23
|
data: Any.pack(peerDescriptor, PeerDescriptor),
|
|
@@ -42,32 +37,22 @@ describe('StreamPartEntryPointDiscovery', () => {
|
|
|
42
37
|
deleted: true
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
const fakeGetEntryPointData = async (
|
|
46
|
-
return
|
|
47
|
-
closestNodes: [peerDescriptor],
|
|
48
|
-
dataEntries: [fakeData, fakeDeletedData]
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const fakegetEntryPointDataViaNode = async (_key: Uint8Array, _node: PeerDescriptor): Promise<DataEntry[]> => {
|
|
53
|
-
return [fakeData]
|
|
40
|
+
const fakeGetEntryPointData = async (): Promise<DataEntry[]> => {
|
|
41
|
+
return [fakeData, fakeDeletedData]
|
|
54
42
|
}
|
|
55
43
|
|
|
56
|
-
const fakeStoreEntryPointData = async (
|
|
44
|
+
const fakeStoreEntryPointData = async (): Promise<PeerDescriptor[]> => {
|
|
57
45
|
storeCalled++
|
|
58
46
|
return [peerDescriptor]
|
|
59
47
|
}
|
|
60
48
|
|
|
61
|
-
const fakeEmptyGetEntryPointData = async (
|
|
62
|
-
return
|
|
63
|
-
closestNodes: [],
|
|
64
|
-
dataEntries: []
|
|
65
|
-
}
|
|
49
|
+
const fakeEmptyGetEntryPointData = async (): Promise<DataEntry[]> => {
|
|
50
|
+
return []
|
|
66
51
|
}
|
|
67
52
|
|
|
68
|
-
const fakeDeleteEntryPointData = async (
|
|
53
|
+
const fakeDeleteEntryPointData = async (): Promise<void> => {}
|
|
69
54
|
|
|
70
|
-
const
|
|
55
|
+
const addNodesToStreamPart = (layer1: MockLayer1, count: number) => {
|
|
71
56
|
range(count).forEach(() => {
|
|
72
57
|
layer1.addNewRandomPeerToKBucket()
|
|
73
58
|
layer1.addNewRandomPeerToKBucket()
|
|
@@ -80,26 +65,24 @@ describe('StreamPartEntryPointDiscovery', () => {
|
|
|
80
65
|
|
|
81
66
|
beforeEach(() => {
|
|
82
67
|
storeCalled = 0
|
|
83
|
-
layer1 = new MockLayer1(
|
|
84
|
-
entryPointDiscoveryWithData = new
|
|
68
|
+
layer1 = new MockLayer1()
|
|
69
|
+
entryPointDiscoveryWithData = new EntryPointDiscovery({
|
|
85
70
|
ownPeerDescriptor: peerDescriptor,
|
|
86
71
|
streamPartId: STREAM_PART_ID,
|
|
87
72
|
layer1,
|
|
88
73
|
getEntryPointData: fakeGetEntryPointData,
|
|
89
|
-
getEntryPointDataViaNode: fakegetEntryPointDataViaNode,
|
|
90
74
|
storeEntryPointData: fakeStoreEntryPointData,
|
|
91
75
|
deleteEntryPointData: fakeDeleteEntryPointData,
|
|
92
|
-
|
|
76
|
+
storeInterval: 2000
|
|
93
77
|
})
|
|
94
|
-
entryPointDiscoveryWithoutData = new
|
|
78
|
+
entryPointDiscoveryWithoutData = new EntryPointDiscovery({
|
|
95
79
|
ownPeerDescriptor: peerDescriptor,
|
|
96
80
|
streamPartId: STREAM_PART_ID,
|
|
97
81
|
layer1,
|
|
98
82
|
getEntryPointData: fakeEmptyGetEntryPointData,
|
|
99
|
-
getEntryPointDataViaNode: fakegetEntryPointDataViaNode,
|
|
100
83
|
storeEntryPointData: fakeStoreEntryPointData,
|
|
101
84
|
deleteEntryPointData: fakeDeleteEntryPointData,
|
|
102
|
-
|
|
85
|
+
storeInterval: 2000
|
|
103
86
|
})
|
|
104
87
|
})
|
|
105
88
|
|
|
@@ -116,14 +99,14 @@ describe('StreamPartEntryPointDiscovery', () => {
|
|
|
116
99
|
it('discoverEntryPointsFromDht does not have known entrypoints', async () => {
|
|
117
100
|
const res = await entryPointDiscoveryWithData.discoverEntryPointsFromDht(0)
|
|
118
101
|
expect(res.discoveredEntryPoints.length).toBe(1)
|
|
119
|
-
expect(
|
|
102
|
+
expect(areEqualPeerDescriptors(res.discoveredEntryPoints[0], peerDescriptor)).toBe(true)
|
|
120
103
|
})
|
|
121
104
|
|
|
122
105
|
it('discoverEntryPointsfromDht on an empty stream', async () => {
|
|
123
106
|
const res = await entryPointDiscoveryWithoutData.discoverEntryPointsFromDht(0)
|
|
124
107
|
expect(res.entryPointsFromDht).toEqual(true)
|
|
125
108
|
expect(res.discoveredEntryPoints.length).toBe(1)
|
|
126
|
-
expect(
|
|
109
|
+
expect(areEqualPeerDescriptors(res.discoveredEntryPoints[0], peerDescriptor)).toBe(true) // ownPeerDescriptor
|
|
127
110
|
})
|
|
128
111
|
|
|
129
112
|
it('store on empty stream', async () => {
|
|
@@ -132,7 +115,7 @@ describe('StreamPartEntryPointDiscovery', () => {
|
|
|
132
115
|
})
|
|
133
116
|
|
|
134
117
|
it('store on stream without saturated entrypoint count', async () => {
|
|
135
|
-
|
|
118
|
+
addNodesToStreamPart(layer1, 4)
|
|
136
119
|
await entryPointDiscoveryWithData.storeSelfAsEntryPointIfNecessary(0)
|
|
137
120
|
expect(storeCalled).toEqual(1)
|
|
138
121
|
})
|
|
@@ -142,7 +125,7 @@ describe('StreamPartEntryPointDiscovery', () => {
|
|
|
142
125
|
expect(storeCalled).toEqual(1)
|
|
143
126
|
await wait(4500)
|
|
144
127
|
await entryPointDiscoveryWithData.destroy()
|
|
145
|
-
// we have configured
|
|
128
|
+
// we have configured storeInterval to 2 seconds, i.e. after 4.5 seconds it should have been called 2 more items
|
|
146
129
|
expect(storeCalled).toEqual(3)
|
|
147
130
|
})
|
|
148
131
|
|
|
@@ -2,13 +2,16 @@ import { NodeType } from '@streamr/dht'
|
|
|
2
2
|
import { hexToBinary } from '@streamr/utils'
|
|
3
3
|
import { NodeID, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
4
4
|
import { NodeList } from '../../src/logic/NodeList'
|
|
5
|
-
import {
|
|
5
|
+
import { HandshakeRpcLocal } from '../../src/logic/neighbor-discovery/HandshakeRpcLocal'
|
|
6
6
|
import { InterleaveNotice, StreamPartHandshakeRequest } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
7
|
-
import { createMockPeerDescriptor,
|
|
7
|
+
import { createMockPeerDescriptor, createMockHandshakeRpcRemote, createMockDeliveryRpcRemote, mockConnectionLocker } from '../utils/utils'
|
|
8
|
+
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
const STREAM_PART_ID = StreamPartIDUtils.parse('stream#0')
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
describe('HandshakeRpcLocal', () => {
|
|
13
|
+
|
|
14
|
+
let rpcLocal: HandshakeRpcLocal
|
|
12
15
|
|
|
13
16
|
const ownPeerDescriptor = createMockPeerDescriptor()
|
|
14
17
|
|
|
@@ -22,28 +25,27 @@ describe('HandshakerServer', () => {
|
|
|
22
25
|
|
|
23
26
|
handshakeWithInterleaving = jest.fn()
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
ownPeerDescriptor,
|
|
28
|
+
rpcLocal = new HandshakeRpcLocal({
|
|
29
|
+
streamPartId: STREAM_PART_ID,
|
|
28
30
|
connectionLocker: mockConnectionLocker,
|
|
29
31
|
ongoingHandshakes,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
createRpcRemote: (_p) => createMockHandshakeRpcRemote(),
|
|
33
|
+
createDeliveryRpcRemote: (_p) => createMockDeliveryRpcRemote(),
|
|
32
34
|
handshakeWithInterleaving: async (_p, _t) => {
|
|
33
35
|
handshakeWithInterleaving()
|
|
34
36
|
return true
|
|
35
37
|
},
|
|
36
38
|
targetNeighbors,
|
|
37
|
-
|
|
39
|
+
maxNeighborCount: 4
|
|
38
40
|
})
|
|
39
41
|
})
|
|
40
42
|
|
|
41
43
|
it('handshake', async () => {
|
|
42
44
|
const req = StreamPartHandshakeRequest.create({
|
|
43
|
-
|
|
45
|
+
streamPartId: STREAM_PART_ID,
|
|
44
46
|
requestId: 'requestId'
|
|
45
47
|
})
|
|
46
|
-
const res = await
|
|
48
|
+
const res = await rpcLocal.handshake(req, {
|
|
47
49
|
incomingSourceDescriptor: createMockPeerDescriptor()
|
|
48
50
|
} as any)
|
|
49
51
|
expect(res.accepted).toEqual(true)
|
|
@@ -52,15 +54,15 @@ describe('HandshakerServer', () => {
|
|
|
52
54
|
})
|
|
53
55
|
|
|
54
56
|
it('handshake interleave', async () => {
|
|
55
|
-
targetNeighbors.add(
|
|
56
|
-
targetNeighbors.add(
|
|
57
|
-
targetNeighbors.add(
|
|
58
|
-
targetNeighbors.add(
|
|
57
|
+
targetNeighbors.add(createMockDeliveryRpcRemote())
|
|
58
|
+
targetNeighbors.add(createMockDeliveryRpcRemote())
|
|
59
|
+
targetNeighbors.add(createMockDeliveryRpcRemote())
|
|
60
|
+
targetNeighbors.add(createMockDeliveryRpcRemote())
|
|
59
61
|
const req = StreamPartHandshakeRequest.create({
|
|
60
|
-
|
|
62
|
+
streamPartId: STREAM_PART_ID,
|
|
61
63
|
requestId: 'requestId'
|
|
62
64
|
})
|
|
63
|
-
const res = await
|
|
65
|
+
const res = await rpcLocal.handshake(req, {
|
|
64
66
|
incomingSourceDescriptor: createMockPeerDescriptor()
|
|
65
67
|
} as any)
|
|
66
68
|
expect(res.accepted).toEqual(true)
|
|
@@ -73,10 +75,10 @@ describe('HandshakerServer', () => {
|
|
|
73
75
|
ongoingHandshakes.add('0x4444' as NodeID)
|
|
74
76
|
ongoingHandshakes.add('0x5555' as NodeID)
|
|
75
77
|
const req = StreamPartHandshakeRequest.create({
|
|
76
|
-
|
|
78
|
+
streamPartId: STREAM_PART_ID,
|
|
77
79
|
requestId: 'requestId'
|
|
78
80
|
})
|
|
79
|
-
const res = await
|
|
81
|
+
const res = await rpcLocal.handshake(req, {
|
|
80
82
|
incomingSourceDescriptor: createMockPeerDescriptor()
|
|
81
83
|
} as any)
|
|
82
84
|
expect(res.accepted).toEqual(false)
|
|
@@ -84,14 +86,14 @@ describe('HandshakerServer', () => {
|
|
|
84
86
|
|
|
85
87
|
it('handshakeWithInterleaving success', async () => {
|
|
86
88
|
const req: InterleaveNotice = {
|
|
87
|
-
|
|
89
|
+
streamPartId: STREAM_PART_ID,
|
|
88
90
|
interleaveTargetDescriptor: {
|
|
89
91
|
kademliaId: hexToBinary('0x2222'),
|
|
90
92
|
type: NodeType.NODEJS
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
}
|
|
94
|
-
await
|
|
96
|
+
await rpcLocal.interleaveNotice(req, {
|
|
95
97
|
incomingSourceDescriptor: createMockPeerDescriptor()
|
|
96
98
|
} as any)
|
|
97
99
|
expect(handshakeWithInterleaving).toHaveBeenCalledTimes(1)
|
|
@@ -99,13 +101,13 @@ describe('HandshakerServer', () => {
|
|
|
99
101
|
|
|
100
102
|
it('handshakeWithInterleaving success', async () => {
|
|
101
103
|
const req: InterleaveNotice = {
|
|
102
|
-
|
|
104
|
+
streamPartId: StreamPartIDUtils.parse('other-stream#0'),
|
|
103
105
|
interleaveTargetDescriptor: {
|
|
104
106
|
kademliaId: hexToBinary('0x2222'),
|
|
105
107
|
type: NodeType.NODEJS
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
|
-
await
|
|
110
|
+
await rpcLocal.interleaveNotice(req, {
|
|
109
111
|
incomingSourceDescriptor: createMockPeerDescriptor()
|
|
110
112
|
} as any)
|
|
111
113
|
expect(handshakeWithInterleaving).toHaveBeenCalledTimes(0)
|
|
@@ -3,15 +3,16 @@ import { range } from 'lodash'
|
|
|
3
3
|
import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
4
4
|
import { NodeList } from '../../src/logic/NodeList'
|
|
5
5
|
import { Handshaker } from '../../src/logic/neighbor-discovery/Handshaker'
|
|
6
|
-
import { createMockPeerDescriptor,
|
|
6
|
+
import { createMockPeerDescriptor, createMockDeliveryRpcRemote, mockConnectionLocker } from '../utils/utils'
|
|
7
|
+
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
7
8
|
|
|
8
9
|
describe('Handshaker', () => {
|
|
9
10
|
|
|
10
11
|
let handshaker: Handshaker
|
|
11
12
|
const peerDescriptor = createMockPeerDescriptor()
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
const
|
|
14
|
+
const maxNeighborCount = 4
|
|
15
|
+
const streamPartId = StreamPartIDUtils.parse('stream#0')
|
|
15
16
|
|
|
16
17
|
let targetNeighbors: NodeList
|
|
17
18
|
let nearbyNodeView: NodeList
|
|
@@ -20,10 +21,11 @@ describe('Handshaker', () => {
|
|
|
20
21
|
let simulator: Simulator
|
|
21
22
|
let simulatorTransport: SimulatorTransport
|
|
22
23
|
|
|
23
|
-
beforeEach(() => {
|
|
24
|
+
beforeEach(async () => {
|
|
24
25
|
simulator = new Simulator()
|
|
25
26
|
simulatorTransport = new SimulatorTransport(peerDescriptor, simulator)
|
|
26
|
-
|
|
27
|
+
await simulatorTransport.start()
|
|
28
|
+
const rpcCommunicator = new ListeningRpcCommunicator(streamPartId, simulatorTransport)
|
|
27
29
|
|
|
28
30
|
const nodeId = getNodeIdFromPeerDescriptor(peerDescriptor)
|
|
29
31
|
targetNeighbors = new NodeList(nodeId, 10)
|
|
@@ -32,13 +34,13 @@ describe('Handshaker', () => {
|
|
|
32
34
|
|
|
33
35
|
handshaker = new Handshaker({
|
|
34
36
|
ownPeerDescriptor: peerDescriptor,
|
|
35
|
-
|
|
37
|
+
streamPartId,
|
|
36
38
|
connectionLocker: mockConnectionLocker,
|
|
37
39
|
targetNeighbors,
|
|
38
40
|
nearbyNodeView,
|
|
39
41
|
randomNodeView,
|
|
40
42
|
rpcCommunicator,
|
|
41
|
-
|
|
43
|
+
maxNeighborCount
|
|
42
44
|
})
|
|
43
45
|
})
|
|
44
46
|
|
|
@@ -53,7 +55,7 @@ describe('Handshaker', () => {
|
|
|
53
55
|
})
|
|
54
56
|
|
|
55
57
|
it('attemptHandshakesOnContact with known nodes that cannot be connected to', async () => {
|
|
56
|
-
range(2).forEach(() => nearbyNodeView.add(
|
|
58
|
+
range(2).forEach(() => nearbyNodeView.add(createMockDeliveryRpcRemote()))
|
|
57
59
|
const res = await handshaker.attemptHandshakesOnContacts([])
|
|
58
60
|
expect(res.length).toEqual(2)
|
|
59
61
|
})
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ListeningRpcCommunicator
|
|
1
|
+
import { ListeningRpcCommunicator } from '@streamr/dht'
|
|
2
2
|
import { utf8ToBinary } from '@streamr/utils'
|
|
3
3
|
import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
4
4
|
import { Inspector } from '../../src/logic/inspect/Inspector'
|
|
5
5
|
import { MockTransport } from '../utils/mock/Transport'
|
|
6
6
|
import { createMockPeerDescriptor, createRandomNodeId, mockConnectionLocker } from '../utils/utils'
|
|
7
|
+
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
7
8
|
|
|
8
9
|
describe('Inspector', () => {
|
|
9
10
|
|
|
@@ -28,10 +29,10 @@ describe('Inspector', () => {
|
|
|
28
29
|
mockConnect = jest.fn(() => {})
|
|
29
30
|
inspector = new Inspector({
|
|
30
31
|
ownPeerDescriptor: inspectorDescriptor,
|
|
31
|
-
|
|
32
|
+
streamPartId: StreamPartIDUtils.parse('stream#0'),
|
|
32
33
|
rpcCommunicator: new ListeningRpcCommunicator('inspector', new MockTransport()),
|
|
33
34
|
connectionLocker: mockConnectionLocker,
|
|
34
|
-
openInspectConnection: async (
|
|
35
|
+
openInspectConnection: async () => mockConnect()
|
|
35
36
|
})
|
|
36
37
|
})
|
|
37
38
|
|
|
@@ -3,7 +3,7 @@ import { NodeList } from '../../src/logic/NodeList'
|
|
|
3
3
|
import { waitForCondition } from '@streamr/utils'
|
|
4
4
|
import { range } from 'lodash'
|
|
5
5
|
import { expect } from 'expect'
|
|
6
|
-
import {
|
|
6
|
+
import { createMockDeliveryRpcRemote, createRandomNodeId } from '../utils/utils'
|
|
7
7
|
import { NodeID, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
8
8
|
|
|
9
9
|
describe('NeighborFinder', () => {
|
|
@@ -13,12 +13,12 @@ describe('NeighborFinder', () => {
|
|
|
13
13
|
let nearbyNodeView: NodeList
|
|
14
14
|
let neighborFinder: NeighborFinder
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const minCount = 4
|
|
17
17
|
|
|
18
18
|
beforeEach(() => {
|
|
19
19
|
targetNeighbors = new NodeList(nodeId, 15)
|
|
20
20
|
nearbyNodeView = new NodeList(nodeId, 30)
|
|
21
|
-
range(30).forEach(() => nearbyNodeView.add(
|
|
21
|
+
range(30).forEach(() => nearbyNodeView.add(createMockDeliveryRpcRemote()))
|
|
22
22
|
const mockDoFindNeighbors = async (excluded: NodeID[]) => {
|
|
23
23
|
const target = nearbyNodeView.getRandom(excluded)
|
|
24
24
|
if (Math.random() < 0.5) {
|
|
@@ -32,7 +32,7 @@ describe('NeighborFinder', () => {
|
|
|
32
32
|
targetNeighbors,
|
|
33
33
|
nearbyNodeView,
|
|
34
34
|
doFindNeighbors: (excluded) => mockDoFindNeighbors(excluded),
|
|
35
|
-
|
|
35
|
+
minCount
|
|
36
36
|
})
|
|
37
37
|
})
|
|
38
38
|
|
|
@@ -42,7 +42,7 @@ describe('NeighborFinder', () => {
|
|
|
42
42
|
|
|
43
43
|
it('Finds target number of nodes', async () => {
|
|
44
44
|
neighborFinder.start()
|
|
45
|
-
await waitForCondition(() => targetNeighbors.size() >=
|
|
45
|
+
await waitForCondition(() => targetNeighbors.size() >= minCount, 10000)
|
|
46
46
|
expect(neighborFinder.isRunning()).toEqual(false)
|
|
47
47
|
})
|
|
48
48
|
})
|