@streamr/trackerless-network 0.0.1-tatum.5 → 0.0.1-tatum.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/EntryPointDiscovery.d.ts +35 -0
- package/dist/src/logic/EntryPointDiscovery.js +145 -0
- package/dist/src/logic/EntryPointDiscovery.js.map +1 -0
- package/dist/src/logic/ILayer0.d.ts +3 -6
- package/dist/src/logic/ILayer1.d.ts +2 -2
- package/dist/src/logic/NodeList.d.ts +10 -10
- package/dist/src/logic/NodeList.js +2 -2
- package/dist/src/logic/NodeList.js.map +1 -1
- package/dist/src/logic/RandomGraphNode.d.ts +8 -12
- package/dist/src/logic/RandomGraphNode.js +47 -46
- package/dist/src/logic/RandomGraphNode.js.map +1 -1
- package/dist/src/logic/StreamrNode.d.ts +9 -11
- package/dist/src/logic/StreamrNode.js +72 -75
- 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 +5 -5
- 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 +7 -7
- 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} +11 -11
- 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} +8 -12
- package/dist/src/logic/proxy/{ProxyStreamConnectionClient.js → ProxyClient.js} +28 -29
- package/dist/src/logic/proxy/ProxyClient.js.map +1 -0
- package/dist/src/logic/proxy/{ProxyStreamConnectionServer.d.ts → ProxyConnectionRpcLocal.d.ts} +5 -7
- package/dist/src/logic/proxy/{ProxyStreamConnectionServer.js → ProxyConnectionRpcLocal.js} +6 -12
- 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 -14
- 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/EntryPointDiscovery.ts +181 -0
- package/src/logic/ILayer0.ts +3 -6
- package/src/logic/ILayer1.ts +2 -5
- package/src/logic/NodeList.ts +12 -12
- package/src/logic/RandomGraphNode.ts +67 -69
- package/src/logic/StreamrNode.ts +78 -90
- 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 +6 -6
- package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +15 -12
- package/src/logic/neighbor-discovery/{NeighborUpdateManagerServer.ts → NeighborUpdateRpcLocal.ts} +17 -17
- 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} +33 -37
- package/src/logic/proxy/{ProxyStreamConnectionServer.ts → ProxyConnectionRpcLocal.ts} +10 -19
- 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 +10 -12
- 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/EntrypointDiscovery.test.ts +132 -0
- 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 +12 -11
- 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 +6 -13
- 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 -13
- package/dist/src/logic/RemoteRandomGraphNode.js.map +0 -1
- package/dist/src/logic/StreamPartEntryPointDiscovery.d.ts +0 -39
- package/dist/src/logic/StreamPartEntryPointDiscovery.js +0 -194
- 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
- package/src/logic/StreamPartEntryPointDiscovery.ts +0 -240
- package/test/unit/StreamPartEntrypointDiscovery.test.ts +0 -164
|
@@ -12,9 +12,10 @@ import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
|
12
12
|
import { ProxyDirection } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
13
13
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
14
14
|
|
|
15
|
+
const STREAM_PART_ID = StreamPartIDUtils.parse('proxy-test#0')
|
|
16
|
+
|
|
15
17
|
describe('proxy group key exchange', () => {
|
|
16
18
|
const proxyNodeDescriptor = createMockPeerDescriptor({
|
|
17
|
-
nodeName: 'proxyNode',
|
|
18
19
|
websocket: { host: '127.0.0.1', port: 23134, tls: false }
|
|
19
20
|
})
|
|
20
21
|
const publisherDescriptor = createMockPeerDescriptor()
|
|
@@ -23,8 +24,6 @@ describe('proxy group key exchange', () => {
|
|
|
23
24
|
const publisherUserId = toEthereumAddress('0x823A026e226EB47980c88616e01E1D3305Ef8Ecb')
|
|
24
25
|
const subscriberUserId = toEthereumAddress('0x73E6183bf9b79D30533bEC7B28e982e9Af649B23')
|
|
25
26
|
|
|
26
|
-
const streamPartId = StreamPartIDUtils.parse('proxy-test#0')
|
|
27
|
-
|
|
28
27
|
let proxyNode: NetworkNode
|
|
29
28
|
let publisher: NetworkNode
|
|
30
29
|
let subscriber: NetworkNode
|
|
@@ -40,8 +39,8 @@ describe('proxy group key exchange', () => {
|
|
|
40
39
|
}
|
|
41
40
|
})
|
|
42
41
|
await proxyNode.start()
|
|
43
|
-
proxyNode.setStreamPartEntryPoints(
|
|
44
|
-
proxyNode.stack.getStreamrNode()!.joinStreamPart(
|
|
42
|
+
proxyNode.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor])
|
|
43
|
+
proxyNode.stack.getStreamrNode()!.joinStreamPart(STREAM_PART_ID)
|
|
45
44
|
publisher = createNetworkNode({
|
|
46
45
|
layer0: {
|
|
47
46
|
entryPoints: [publisherDescriptor],
|
|
@@ -66,8 +65,8 @@ describe('proxy group key exchange', () => {
|
|
|
66
65
|
})
|
|
67
66
|
|
|
68
67
|
it('happy path request', async () => {
|
|
69
|
-
await publisher.setProxies(
|
|
70
|
-
await subscriber.setProxies(
|
|
68
|
+
await publisher.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.PUBLISH, publisherUserId)
|
|
69
|
+
await subscriber.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.SUBSCRIBE, subscriberUserId)
|
|
71
70
|
|
|
72
71
|
const requestContent = utf8ToBinary(new GroupKeyRequest({
|
|
73
72
|
recipient: publisherUserId,
|
|
@@ -79,8 +78,8 @@ describe('proxy group key exchange', () => {
|
|
|
79
78
|
}).serialize())
|
|
80
79
|
const request = new StreamMessage({
|
|
81
80
|
messageId: new MessageID(
|
|
82
|
-
StreamPartIDUtils.getStreamID(
|
|
83
|
-
StreamPartIDUtils.getStreamPartition(
|
|
81
|
+
StreamPartIDUtils.getStreamID(STREAM_PART_ID),
|
|
82
|
+
StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
84
83
|
Date.now(),
|
|
85
84
|
0,
|
|
86
85
|
subscriberUserId,
|
|
@@ -99,8 +98,8 @@ describe('proxy group key exchange', () => {
|
|
|
99
98
|
})
|
|
100
99
|
|
|
101
100
|
it('happy path response', async () => {
|
|
102
|
-
await publisher.setProxies(
|
|
103
|
-
await subscriber.setProxies(
|
|
101
|
+
await publisher.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.PUBLISH, publisherUserId)
|
|
102
|
+
await subscriber.setProxies(STREAM_PART_ID, [proxyNodeDescriptor], ProxyDirection.SUBSCRIBE, subscriberUserId)
|
|
104
103
|
|
|
105
104
|
const responseContent = utf8ToBinary(new GroupKeyResponse({
|
|
106
105
|
recipient: publisherUserId,
|
|
@@ -109,8 +108,8 @@ describe('proxy group key exchange', () => {
|
|
|
109
108
|
}).serialize())
|
|
110
109
|
const response = new StreamMessage({
|
|
111
110
|
messageId: new MessageID(
|
|
112
|
-
StreamPartIDUtils.getStreamID(
|
|
113
|
-
StreamPartIDUtils.getStreamPartition(
|
|
111
|
+
StreamPartIDUtils.getStreamID(STREAM_PART_ID),
|
|
112
|
+
StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
114
113
|
Date.now(),
|
|
115
114
|
0,
|
|
116
115
|
publisherUserId,
|
|
@@ -14,7 +14,7 @@ describe('random graph with real connections', () => {
|
|
|
14
14
|
websocket: { host: '127.0.0.1', port: 12221, tls: false }
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const streamPartId = StreamPartIDUtils.parse('random-graph#0')
|
|
18
18
|
let epDhtNode: DhtNode
|
|
19
19
|
let dhtNode1: DhtNode
|
|
20
20
|
let dhtNode2: DhtNode
|
|
@@ -41,7 +41,7 @@ describe('random graph with real connections', () => {
|
|
|
41
41
|
|
|
42
42
|
randomGraphNode1 = createRandomGraphNode(
|
|
43
43
|
{
|
|
44
|
-
|
|
44
|
+
streamPartId,
|
|
45
45
|
layer1: epDhtNode,
|
|
46
46
|
P2PTransport: epDhtNode.getTransport(),
|
|
47
47
|
connectionLocker: epDhtNode.getTransport() as ConnectionManager,
|
|
@@ -49,28 +49,28 @@ describe('random graph with real connections', () => {
|
|
|
49
49
|
}
|
|
50
50
|
)
|
|
51
51
|
randomGraphNode2 = createRandomGraphNode({
|
|
52
|
-
|
|
52
|
+
streamPartId,
|
|
53
53
|
layer1: dhtNode1,
|
|
54
54
|
P2PTransport: dhtNode1.getTransport(),
|
|
55
55
|
connectionLocker: dhtNode1.getTransport() as ConnectionManager,
|
|
56
56
|
ownPeerDescriptor: dhtNode1.getPeerDescriptor()
|
|
57
57
|
})
|
|
58
58
|
randomGraphNode3 = createRandomGraphNode({
|
|
59
|
-
|
|
59
|
+
streamPartId,
|
|
60
60
|
layer1: dhtNode2,
|
|
61
61
|
P2PTransport: dhtNode2.getTransport(),
|
|
62
62
|
connectionLocker: dhtNode2.getTransport() as ConnectionManager,
|
|
63
63
|
ownPeerDescriptor: dhtNode2.getPeerDescriptor()
|
|
64
64
|
})
|
|
65
65
|
randomGraphNode4 = createRandomGraphNode({
|
|
66
|
-
|
|
66
|
+
streamPartId,
|
|
67
67
|
layer1: dhtNode3,
|
|
68
68
|
P2PTransport: dhtNode3.getTransport(),
|
|
69
69
|
connectionLocker: dhtNode3.getTransport() as ConnectionManager,
|
|
70
70
|
ownPeerDescriptor: dhtNode3.getPeerDescriptor()
|
|
71
71
|
})
|
|
72
72
|
randomGraphNode5 = createRandomGraphNode({
|
|
73
|
-
|
|
73
|
+
streamPartId,
|
|
74
74
|
layer1: dhtNode4,
|
|
75
75
|
P2PTransport: dhtNode4.getTransport(),
|
|
76
76
|
connectionLocker: dhtNode4.getTransport() as ConnectionManager,
|
|
@@ -144,7 +144,7 @@ describe('random graph with real connections', () => {
|
|
|
144
144
|
|
|
145
145
|
const msg = createStreamMessage(
|
|
146
146
|
JSON.stringify({ hello: 'WORLD' }),
|
|
147
|
-
|
|
147
|
+
streamPartId,
|
|
148
148
|
randomEthereumAddress()
|
|
149
149
|
)
|
|
150
150
|
randomGraphNode1.broadcast(msg)
|
|
@@ -16,7 +16,7 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
16
16
|
region: getRandomRegion()
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const streamPartId = StreamPartIDUtils.parse('webrtc-network#0')
|
|
20
20
|
|
|
21
21
|
let entryPoint: NetworkStack
|
|
22
22
|
|
|
@@ -33,8 +33,8 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
33
33
|
}
|
|
34
34
|
})
|
|
35
35
|
await entryPoint.start()
|
|
36
|
-
entryPoint.getStreamrNode()!.setStreamPartEntryPoints(
|
|
37
|
-
entryPoint.getStreamrNode()!.joinStreamPart(
|
|
36
|
+
entryPoint.getStreamrNode()!.setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
37
|
+
entryPoint.getStreamrNode()!.joinStreamPart(streamPartId)
|
|
38
38
|
|
|
39
39
|
await Promise.all(range(NUM_OF_NODES).map(async () => {
|
|
40
40
|
const peerDescriptor = createMockPeerDescriptor()
|
|
@@ -46,8 +46,8 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
46
46
|
})
|
|
47
47
|
nodes.push(node)
|
|
48
48
|
await node.start()
|
|
49
|
-
node.getStreamrNode().setStreamPartEntryPoints(
|
|
50
|
-
node.getStreamrNode().joinStreamPart(
|
|
49
|
+
node.getStreamrNode().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
50
|
+
node.getStreamrNode().joinStreamPart(streamPartId)
|
|
51
51
|
}))
|
|
52
52
|
|
|
53
53
|
}, 90000)
|
|
@@ -62,13 +62,13 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
62
62
|
it('happy path', async () => {
|
|
63
63
|
await Promise.all(nodes.map((node) =>
|
|
64
64
|
waitForCondition(() => {
|
|
65
|
-
return node.getStreamrNode()!.getNeighbors(
|
|
65
|
+
return node.getStreamrNode()!.getNeighbors(streamPartId).length >= 3
|
|
66
66
|
}
|
|
67
67
|
, 120000)
|
|
68
68
|
))
|
|
69
69
|
let numOfMessagesReceived = 0
|
|
70
70
|
const successIds: string[] = []
|
|
71
|
-
nodes.
|
|
71
|
+
nodes.forEach((node) => {
|
|
72
72
|
node.getStreamrNode()!.on('newMessage', () => {
|
|
73
73
|
successIds.push(getNodeIdFromPeerDescriptor(node.getStreamrNode()!.getPeerDescriptor()))
|
|
74
74
|
numOfMessagesReceived += 1
|
|
@@ -76,7 +76,7 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
76
76
|
})
|
|
77
77
|
const msg = createStreamMessage(
|
|
78
78
|
JSON.stringify({ hello: 'WORLD' }),
|
|
79
|
-
|
|
79
|
+
streamPartId,
|
|
80
80
|
randomEthereumAddress()
|
|
81
81
|
)
|
|
82
82
|
entryPoint.getStreamrNode()!.broadcast(msg)
|
|
@@ -10,10 +10,9 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
10
10
|
|
|
11
11
|
const NUM_OF_NODES = 48
|
|
12
12
|
const epPeerDescriptor = createMockPeerDescriptor({
|
|
13
|
-
nodeName: 'entrypoint',
|
|
14
13
|
websocket: { host: '127.0.0.1', port: 15555, tls: false }
|
|
15
14
|
})
|
|
16
|
-
const
|
|
15
|
+
const streamPartId = StreamPartIDUtils.parse('websocket-network#0')
|
|
17
16
|
|
|
18
17
|
let entryPoint: NetworkStack
|
|
19
18
|
|
|
@@ -30,22 +29,21 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
30
29
|
}
|
|
31
30
|
})
|
|
32
31
|
await entryPoint.start()
|
|
33
|
-
entryPoint.getStreamrNode()!.setStreamPartEntryPoints(
|
|
34
|
-
entryPoint.getStreamrNode()!.joinStreamPart(
|
|
32
|
+
entryPoint.getStreamrNode()!.setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
33
|
+
entryPoint.getStreamrNode()!.joinStreamPart(streamPartId)
|
|
35
34
|
|
|
36
35
|
await Promise.all(range(NUM_OF_NODES).map(async (i) => {
|
|
37
36
|
const node = new NetworkStack({
|
|
38
37
|
layer0: {
|
|
39
38
|
entryPoints: [epPeerDescriptor],
|
|
40
39
|
websocketPortRange: { min: 15556 + i, max: 15556 + i },
|
|
41
|
-
nodeName: `${i}`,
|
|
42
40
|
numberOfNodesPerKBucket: 4
|
|
43
41
|
}
|
|
44
42
|
})
|
|
45
43
|
nodes.push(node)
|
|
46
44
|
await node.start()
|
|
47
|
-
node.getStreamrNode().setStreamPartEntryPoints(
|
|
48
|
-
node.getStreamrNode().joinStreamPart(
|
|
45
|
+
node.getStreamrNode().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
46
|
+
node.getStreamrNode().joinStreamPart(streamPartId)
|
|
49
47
|
}))
|
|
50
48
|
|
|
51
49
|
}, 120000)
|
|
@@ -60,13 +58,13 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
60
58
|
it('happy path', async () => {
|
|
61
59
|
await Promise.all(nodes.map((node) =>
|
|
62
60
|
waitForCondition(() => {
|
|
63
|
-
return node.getStreamrNode()!.getNeighbors(
|
|
61
|
+
return node.getStreamrNode()!.getNeighbors(streamPartId).length >= 4
|
|
64
62
|
}
|
|
65
63
|
, 120000)
|
|
66
64
|
))
|
|
67
65
|
let numOfMessagesReceived = 0
|
|
68
66
|
const successIds: string[] = []
|
|
69
|
-
nodes.
|
|
67
|
+
nodes.forEach((node) => {
|
|
70
68
|
node.getStreamrNode()!.on('newMessage', () => {
|
|
71
69
|
successIds.push(getNodeIdFromPeerDescriptor(node.getStreamrNode()!.getPeerDescriptor()))
|
|
72
70
|
numOfMessagesReceived += 1
|
|
@@ -75,7 +73,7 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
75
73
|
|
|
76
74
|
const msg = createStreamMessage(
|
|
77
75
|
JSON.stringify({ hello: 'WORLD' }),
|
|
78
|
-
|
|
76
|
+
streamPartId,
|
|
79
77
|
randomEthereumAddress()
|
|
80
78
|
)
|
|
81
79
|
entryPoint.getStreamrNode()!.broadcast(msg)
|
|
@@ -5,24 +5,25 @@ import {
|
|
|
5
5
|
SimulatorTransport,
|
|
6
6
|
NodeType
|
|
7
7
|
} from '@streamr/dht'
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { DeliveryRpcRemote } from '../../src/logic/DeliveryRpcRemote'
|
|
9
|
+
import { DeliveryRpcClient } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
10
10
|
import {
|
|
11
11
|
LeaveStreamPartNotice,
|
|
12
12
|
StreamMessage
|
|
13
13
|
} from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
14
14
|
import { Empty } from '../../src/proto/google/protobuf/empty'
|
|
15
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
16
15
|
import { waitForCondition } from '@streamr/utils'
|
|
17
16
|
import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
18
17
|
import { createStreamMessage } from '../utils/utils'
|
|
19
18
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
20
19
|
import { randomEthereumAddress } from '@streamr/test-utils'
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
const STREAM_PART_ID = StreamPartIDUtils.parse('test-stream#0')
|
|
22
|
+
|
|
23
|
+
describe('DeliveryRpcRemote', () => {
|
|
23
24
|
let mockServerRpc: ListeningRpcCommunicator
|
|
24
25
|
let clientRpc: ListeningRpcCommunicator
|
|
25
|
-
let
|
|
26
|
+
let rpcRemote: DeliveryRpcRemote
|
|
26
27
|
|
|
27
28
|
const clientNode: PeerDescriptor = {
|
|
28
29
|
kademliaId: new Uint8Array([1, 1, 1]),
|
|
@@ -39,11 +40,13 @@ describe('RemoteRandomGraphNode', () => {
|
|
|
39
40
|
let mockConnectionManager1: SimulatorTransport
|
|
40
41
|
let mockConnectionManager2: SimulatorTransport
|
|
41
42
|
|
|
42
|
-
beforeEach(() => {
|
|
43
|
+
beforeEach(async () => {
|
|
43
44
|
recvCounter = 0
|
|
44
45
|
simulator = new Simulator()
|
|
45
46
|
mockConnectionManager1 = new SimulatorTransport(serverNode, simulator)
|
|
47
|
+
await mockConnectionManager1.start()
|
|
46
48
|
mockConnectionManager2 = new SimulatorTransport(clientNode, simulator)
|
|
49
|
+
await mockConnectionManager2.start()
|
|
47
50
|
|
|
48
51
|
mockServerRpc = new ListeningRpcCommunicator('test', mockConnectionManager1)
|
|
49
52
|
clientRpc = new ListeningRpcCommunicator('test', mockConnectionManager2)
|
|
@@ -51,7 +54,7 @@ describe('RemoteRandomGraphNode', () => {
|
|
|
51
54
|
mockServerRpc.registerRpcNotification(
|
|
52
55
|
StreamMessage,
|
|
53
56
|
'sendStreamMessage',
|
|
54
|
-
async (
|
|
57
|
+
async (): Promise<Empty> => {
|
|
55
58
|
recvCounter += 1
|
|
56
59
|
return Empty
|
|
57
60
|
}
|
|
@@ -60,17 +63,17 @@ describe('RemoteRandomGraphNode', () => {
|
|
|
60
63
|
mockServerRpc.registerRpcNotification(
|
|
61
64
|
LeaveStreamPartNotice,
|
|
62
65
|
'leaveStreamPartNotice',
|
|
63
|
-
async (
|
|
66
|
+
async (): Promise<Empty> => {
|
|
64
67
|
recvCounter += 1
|
|
65
68
|
return Empty
|
|
66
69
|
}
|
|
67
70
|
)
|
|
68
71
|
|
|
69
|
-
|
|
72
|
+
rpcRemote = new DeliveryRpcRemote(
|
|
70
73
|
clientNode,
|
|
71
74
|
serverNode,
|
|
72
|
-
|
|
73
|
-
toProtoRpcClient(new
|
|
75
|
+
STREAM_PART_ID,
|
|
76
|
+
toProtoRpcClient(new DeliveryRpcClient(clientRpc.getRpcClientTransport()))
|
|
74
77
|
)
|
|
75
78
|
})
|
|
76
79
|
|
|
@@ -85,16 +88,16 @@ describe('RemoteRandomGraphNode', () => {
|
|
|
85
88
|
it('sendStreamMessage', async () => {
|
|
86
89
|
const msg = createStreamMessage(
|
|
87
90
|
JSON.stringify({ hello: 'WORLD' }),
|
|
88
|
-
|
|
91
|
+
STREAM_PART_ID,
|
|
89
92
|
randomEthereumAddress()
|
|
90
93
|
)
|
|
91
94
|
|
|
92
|
-
await
|
|
95
|
+
await rpcRemote.sendStreamMessage(msg)
|
|
93
96
|
await waitForCondition(() => recvCounter === 1)
|
|
94
97
|
})
|
|
95
98
|
|
|
96
99
|
it('leaveNotice', async () => {
|
|
97
|
-
|
|
100
|
+
rpcRemote.leaveStreamPartNotice()
|
|
98
101
|
await waitForCondition(() => recvCounter === 1)
|
|
99
102
|
})
|
|
100
103
|
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
StreamPartHandshakeRequest,
|
|
3
3
|
StreamPartHandshakeResponse
|
|
4
4
|
} from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
5
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
6
5
|
import {
|
|
7
6
|
ListeningRpcCommunicator,
|
|
8
7
|
NodeType,
|
|
@@ -14,12 +13,12 @@ import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
|
14
13
|
import {
|
|
15
14
|
HandshakeRpcClient,
|
|
16
15
|
} from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
17
|
-
import {
|
|
16
|
+
import { HandshakeRpcRemote } from '../../src/logic/neighbor-discovery/HandshakeRpcRemote'
|
|
18
17
|
|
|
19
|
-
describe('
|
|
18
|
+
describe('HandshakeRpcRemote', () => {
|
|
20
19
|
let mockServerRpc: ListeningRpcCommunicator
|
|
21
20
|
let clientRpc: ListeningRpcCommunicator
|
|
22
|
-
let
|
|
21
|
+
let rpcRemote: HandshakeRpcRemote
|
|
23
22
|
|
|
24
23
|
const clientNode: PeerDescriptor = {
|
|
25
24
|
kademliaId: new Uint8Array([1, 1, 1]),
|
|
@@ -34,11 +33,13 @@ describe('RemoteHandshaker', () => {
|
|
|
34
33
|
let mockConnectionManager1: SimulatorTransport
|
|
35
34
|
let mockConnectionManager2: SimulatorTransport
|
|
36
35
|
|
|
37
|
-
beforeEach(() => {
|
|
36
|
+
beforeEach(async () => {
|
|
38
37
|
Simulator.useFakeTimers()
|
|
39
38
|
simulator = new Simulator()
|
|
40
39
|
mockConnectionManager1 = new SimulatorTransport(serverNode, simulator)
|
|
40
|
+
await mockConnectionManager1.start()
|
|
41
41
|
mockConnectionManager2 = new SimulatorTransport(clientNode, simulator)
|
|
42
|
+
await mockConnectionManager2.start()
|
|
42
43
|
|
|
43
44
|
mockServerRpc = new ListeningRpcCommunicator('test', mockConnectionManager1)
|
|
44
45
|
clientRpc = new ListeningRpcCommunicator('test', mockConnectionManager2)
|
|
@@ -47,7 +48,7 @@ describe('RemoteHandshaker', () => {
|
|
|
47
48
|
StreamPartHandshakeRequest,
|
|
48
49
|
StreamPartHandshakeResponse,
|
|
49
50
|
'handshake',
|
|
50
|
-
async (msg: StreamPartHandshakeRequest
|
|
51
|
+
async (msg: StreamPartHandshakeRequest): Promise<StreamPartHandshakeResponse> => {
|
|
51
52
|
const res: StreamPartHandshakeResponse = {
|
|
52
53
|
requestId: msg.requestId,
|
|
53
54
|
accepted: true
|
|
@@ -56,10 +57,10 @@ describe('RemoteHandshaker', () => {
|
|
|
56
57
|
}
|
|
57
58
|
)
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
rpcRemote = new HandshakeRpcRemote(
|
|
60
61
|
clientNode,
|
|
61
62
|
serverNode,
|
|
62
|
-
'test-stream',
|
|
63
|
+
'test-stream-part',
|
|
63
64
|
toProtoRpcClient(new HandshakeRpcClient(clientRpc.getRpcClientTransport()))
|
|
64
65
|
)
|
|
65
66
|
})
|
|
@@ -74,7 +75,7 @@ describe('RemoteHandshaker', () => {
|
|
|
74
75
|
})
|
|
75
76
|
|
|
76
77
|
it('handshake', async () => {
|
|
77
|
-
const result = await
|
|
78
|
+
const result = await rpcRemote.handshake([])
|
|
78
79
|
expect(result.accepted).toEqual(true)
|
|
79
80
|
})
|
|
80
81
|
})
|
|
@@ -13,9 +13,9 @@ import {
|
|
|
13
13
|
import { NodeList } from '../../src/logic/NodeList'
|
|
14
14
|
import { mockConnectionLocker } from '../utils/utils'
|
|
15
15
|
import { StreamPartHandshakeRequest, StreamPartHandshakeResponse } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
16
|
-
import {
|
|
17
|
-
import { RemoteHandshaker } from '../../src/logic/neighbor-discovery/RemoteHandshaker'
|
|
16
|
+
import { HandshakeRpcRemote } from '../../src/logic/neighbor-discovery/HandshakeRpcRemote'
|
|
18
17
|
import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
18
|
+
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
19
19
|
|
|
20
20
|
describe('Handshakes', () => {
|
|
21
21
|
|
|
@@ -37,9 +37,9 @@ describe('Handshakes', () => {
|
|
|
37
37
|
let nodeView: NodeList
|
|
38
38
|
let targetNeighbors: NodeList
|
|
39
39
|
let handshaker: Handshaker
|
|
40
|
-
const
|
|
40
|
+
const streamPartId = StreamPartIDUtils.parse('stream#0')
|
|
41
41
|
|
|
42
|
-
const acceptHandshake = async (request: StreamPartHandshakeRequest
|
|
42
|
+
const acceptHandshake = async (request: StreamPartHandshakeRequest): Promise<StreamPartHandshakeResponse> => {
|
|
43
43
|
const response: StreamPartHandshakeResponse = {
|
|
44
44
|
requestId: request.requestId,
|
|
45
45
|
accepted: true
|
|
@@ -47,7 +47,7 @@ describe('Handshakes', () => {
|
|
|
47
47
|
return response
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const rejectHandshake = async (request: StreamPartHandshakeRequest
|
|
50
|
+
const rejectHandshake = async (request: StreamPartHandshakeRequest): Promise<StreamPartHandshakeResponse> => {
|
|
51
51
|
const response: StreamPartHandshakeResponse = {
|
|
52
52
|
requestId: request.requestId,
|
|
53
53
|
accepted: false
|
|
@@ -55,7 +55,7 @@ describe('Handshakes', () => {
|
|
|
55
55
|
return response
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const interleavingHandshake = async (request: StreamPartHandshakeRequest
|
|
58
|
+
const interleavingHandshake = async (request: StreamPartHandshakeRequest): Promise<StreamPartHandshakeResponse> => {
|
|
59
59
|
const response: StreamPartHandshakeResponse = {
|
|
60
60
|
requestId: request.requestId,
|
|
61
61
|
accepted: true,
|
|
@@ -69,29 +69,32 @@ describe('Handshakes', () => {
|
|
|
69
69
|
let simulatorTransport2: SimulatorTransport
|
|
70
70
|
let simulatorTransport3: SimulatorTransport
|
|
71
71
|
|
|
72
|
-
beforeEach(() => {
|
|
72
|
+
beforeEach(async () => {
|
|
73
73
|
Simulator.useFakeTimers()
|
|
74
74
|
simulator = new Simulator()
|
|
75
75
|
simulatorTransport1 = new SimulatorTransport(peerDescriptor1, simulator)
|
|
76
|
+
await simulatorTransport1.start()
|
|
76
77
|
simulatorTransport2 = new SimulatorTransport(peerDescriptor2, simulator)
|
|
78
|
+
await simulatorTransport2.start()
|
|
77
79
|
simulatorTransport3 = new SimulatorTransport(peerDescriptor3, simulator)
|
|
80
|
+
await simulatorTransport3.start()
|
|
78
81
|
|
|
79
|
-
rpcCommunicator1 = new ListeningRpcCommunicator(
|
|
80
|
-
rpcCommunicator2 = new ListeningRpcCommunicator(
|
|
81
|
-
rpcCommunicator3 = new ListeningRpcCommunicator(
|
|
82
|
+
rpcCommunicator1 = new ListeningRpcCommunicator(streamPartId, simulatorTransport1)
|
|
83
|
+
rpcCommunicator2 = new ListeningRpcCommunicator(streamPartId, simulatorTransport2)
|
|
84
|
+
rpcCommunicator3 = new ListeningRpcCommunicator(streamPartId, simulatorTransport3)
|
|
82
85
|
|
|
83
86
|
const handshakerNodeId = getNodeIdFromPeerDescriptor(peerDescriptor2)
|
|
84
87
|
nodeView = new NodeList(handshakerNodeId, 10)
|
|
85
88
|
targetNeighbors = new NodeList(handshakerNodeId, 4)
|
|
86
89
|
handshaker = new Handshaker({
|
|
87
90
|
ownPeerDescriptor: peerDescriptor2,
|
|
88
|
-
|
|
91
|
+
streamPartId,
|
|
89
92
|
nearbyNodeView: nodeView,
|
|
90
93
|
randomNodeView: nodeView,
|
|
91
94
|
targetNeighbors,
|
|
92
95
|
connectionLocker: mockConnectionLocker,
|
|
93
96
|
rpcCommunicator: rpcCommunicator2,
|
|
94
|
-
|
|
97
|
+
maxNeighborCount: 4
|
|
95
98
|
})
|
|
96
99
|
|
|
97
100
|
})
|
|
@@ -111,10 +114,10 @@ describe('Handshakes', () => {
|
|
|
111
114
|
rpcCommunicator1.registerRpcMethod(StreamPartHandshakeRequest, StreamPartHandshakeResponse, 'handshake', acceptHandshake)
|
|
112
115
|
// @ts-expect-error private
|
|
113
116
|
const res = await handshaker.handshakeWithTarget(
|
|
114
|
-
new
|
|
117
|
+
new HandshakeRpcRemote(
|
|
115
118
|
peerDescriptor2,
|
|
116
119
|
peerDescriptor1,
|
|
117
|
-
|
|
120
|
+
streamPartId,
|
|
118
121
|
toProtoRpcClient(new HandshakeRpcClient(rpcCommunicator2.getRpcClientTransport()))
|
|
119
122
|
)
|
|
120
123
|
)
|
|
@@ -126,10 +129,10 @@ describe('Handshakes', () => {
|
|
|
126
129
|
rpcCommunicator1.registerRpcMethod(StreamPartHandshakeRequest, StreamPartHandshakeResponse, 'handshake', acceptHandshake)
|
|
127
130
|
// @ts-expect-error private
|
|
128
131
|
const res = await handshaker.handshakeWithTarget(
|
|
129
|
-
new
|
|
132
|
+
new HandshakeRpcRemote(
|
|
130
133
|
peerDescriptor2,
|
|
131
134
|
peerDescriptor1,
|
|
132
|
-
|
|
135
|
+
streamPartId,
|
|
133
136
|
toProtoRpcClient(new HandshakeRpcClient(rpcCommunicator2.getRpcClientTransport()))
|
|
134
137
|
)
|
|
135
138
|
)
|
|
@@ -141,10 +144,10 @@ describe('Handshakes', () => {
|
|
|
141
144
|
rpcCommunicator1.registerRpcMethod(StreamPartHandshakeRequest, StreamPartHandshakeResponse, 'handshake', rejectHandshake)
|
|
142
145
|
// @ts-expect-error private
|
|
143
146
|
const res = await handshaker.handshakeWithTarget(
|
|
144
|
-
new
|
|
147
|
+
new HandshakeRpcRemote(
|
|
145
148
|
peerDescriptor2,
|
|
146
149
|
peerDescriptor1,
|
|
147
|
-
|
|
150
|
+
streamPartId,
|
|
148
151
|
toProtoRpcClient(new HandshakeRpcClient(rpcCommunicator2.getRpcClientTransport()))
|
|
149
152
|
)
|
|
150
153
|
)
|
|
@@ -157,10 +160,10 @@ describe('Handshakes', () => {
|
|
|
157
160
|
rpcCommunicator3.registerRpcMethod(StreamPartHandshakeRequest, StreamPartHandshakeResponse, 'handshake', acceptHandshake)
|
|
158
161
|
// @ts-expect-error private
|
|
159
162
|
const res = await handshaker.handshakeWithTarget(
|
|
160
|
-
new
|
|
163
|
+
new HandshakeRpcRemote(
|
|
161
164
|
peerDescriptor2,
|
|
162
165
|
peerDescriptor1,
|
|
163
|
-
|
|
166
|
+
streamPartId,
|
|
164
167
|
toProtoRpcClient(new HandshakeRpcClient(rpcCommunicator2.getRpcClientTransport()))
|
|
165
168
|
)
|
|
166
169
|
)
|
|
@@ -24,12 +24,13 @@ describe('inspect', () => {
|
|
|
24
24
|
let publishInterval: NodeJS.Timeout
|
|
25
25
|
|
|
26
26
|
const initiateNode = async (peerDescriptor: PeerDescriptor, simulator: Simulator): Promise<NetworkStack> => {
|
|
27
|
-
const
|
|
27
|
+
const transport = new SimulatorTransport(peerDescriptor, simulator)
|
|
28
|
+
await transport.start()
|
|
28
29
|
const node = new NetworkStack({
|
|
29
30
|
layer0: {
|
|
30
31
|
entryPoints: [publisherDescriptor],
|
|
31
32
|
peerDescriptor,
|
|
32
|
-
|
|
33
|
+
transport
|
|
33
34
|
}
|
|
34
35
|
})
|
|
35
36
|
await node.start()
|
package/test/integration/{RemoteNeighborUpdateManager.test.ts → NeighborUpdateRpcRemote.test.ts}
RENAMED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
1
|
import {
|
|
3
2
|
ListeningRpcCommunicator,
|
|
4
3
|
NodeType,
|
|
@@ -7,16 +6,17 @@ import {
|
|
|
7
6
|
SimulatorTransport
|
|
8
7
|
} from '@streamr/dht'
|
|
9
8
|
import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
10
|
-
import {
|
|
9
|
+
import { NeighborUpdateRpcRemote } from '../../src/logic/neighbor-discovery/NeighborUpdateRpcRemote'
|
|
11
10
|
import { NeighborUpdate } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
12
11
|
import {
|
|
13
12
|
NeighborUpdateRpcClient,
|
|
14
13
|
} from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
14
|
+
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
15
15
|
|
|
16
|
-
describe('
|
|
16
|
+
describe('NeighborUpdateRpcRemote', () => {
|
|
17
17
|
let mockServerRpc: ListeningRpcCommunicator
|
|
18
18
|
let clientRpc: ListeningRpcCommunicator
|
|
19
|
-
let
|
|
19
|
+
let rpcRemote: NeighborUpdateRpcRemote
|
|
20
20
|
|
|
21
21
|
const clientNode: PeerDescriptor = {
|
|
22
22
|
kademliaId: new Uint8Array([1, 1, 1]),
|
|
@@ -31,10 +31,12 @@ describe('RemoteNeighborUpdateManager', () => {
|
|
|
31
31
|
let mockConnectionManager1: SimulatorTransport
|
|
32
32
|
let mockConnectionManager2: SimulatorTransport
|
|
33
33
|
|
|
34
|
-
beforeEach(() => {
|
|
34
|
+
beforeEach(async () => {
|
|
35
35
|
simulator = new Simulator()
|
|
36
36
|
mockConnectionManager1 = new SimulatorTransport(serverNode, simulator)
|
|
37
|
+
await mockConnectionManager1.start()
|
|
37
38
|
mockConnectionManager2 = new SimulatorTransport(clientNode, simulator)
|
|
39
|
+
await mockConnectionManager2.start()
|
|
38
40
|
|
|
39
41
|
mockServerRpc = new ListeningRpcCommunicator('test', mockConnectionManager1)
|
|
40
42
|
clientRpc = new ListeningRpcCommunicator('test', mockConnectionManager2)
|
|
@@ -43,13 +45,13 @@ describe('RemoteNeighborUpdateManager', () => {
|
|
|
43
45
|
NeighborUpdate,
|
|
44
46
|
NeighborUpdate,
|
|
45
47
|
'neighborUpdate',
|
|
46
|
-
async (
|
|
48
|
+
async (): Promise<NeighborUpdate> => {
|
|
47
49
|
const node: PeerDescriptor = {
|
|
48
50
|
kademliaId: new Uint8Array([4, 2, 4]),
|
|
49
51
|
type: NodeType.NODEJS
|
|
50
52
|
}
|
|
51
53
|
const update: NeighborUpdate = {
|
|
52
|
-
|
|
54
|
+
streamPartId: StreamPartIDUtils.parse('stream#0'),
|
|
53
55
|
neighborDescriptors: [
|
|
54
56
|
node
|
|
55
57
|
],
|
|
@@ -58,10 +60,10 @@ describe('RemoteNeighborUpdateManager', () => {
|
|
|
58
60
|
return update
|
|
59
61
|
}
|
|
60
62
|
)
|
|
61
|
-
|
|
63
|
+
rpcRemote = new NeighborUpdateRpcRemote(
|
|
62
64
|
clientNode,
|
|
63
65
|
serverNode,
|
|
64
|
-
'test-stream',
|
|
66
|
+
'test-stream-part',
|
|
65
67
|
toProtoRpcClient(new NeighborUpdateRpcClient(clientRpc.getRpcClientTransport()))
|
|
66
68
|
)
|
|
67
69
|
})
|
|
@@ -75,7 +77,7 @@ describe('RemoteNeighborUpdateManager', () => {
|
|
|
75
77
|
})
|
|
76
78
|
|
|
77
79
|
it('updateNeighbors', async () => {
|
|
78
|
-
const res = await
|
|
80
|
+
const res = await rpcRemote.updateNeighbors([])
|
|
79
81
|
expect(res.peerDescriptors.length).toEqual(1)
|
|
80
82
|
})
|
|
81
83
|
})
|