@streamr/trackerless-network 100.0.0-testnet-one.4 → 100.0.0-testnet-two.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/dist/package.json +7 -7
- package/dist/src/NetworkStack.d.ts +1 -5
- package/dist/src/NetworkStack.js +1 -3
- package/dist/src/NetworkStack.js.map +1 -1
- package/dist/src/logic/DeliveryRpcLocal.d.ts +1 -1
- package/dist/src/logic/DeliveryRpcLocal.js +3 -3
- package/dist/src/logic/DeliveryRpcLocal.js.map +1 -1
- package/dist/src/logic/DeliveryRpcRemote.d.ts +3 -3
- package/dist/src/logic/DeliveryRpcRemote.js +3 -2
- package/dist/src/logic/DeliveryRpcRemote.js.map +1 -1
- package/dist/src/logic/EntryPointDiscovery.d.ts +3 -0
- package/dist/src/logic/EntryPointDiscovery.js +11 -5
- package/dist/src/logic/EntryPointDiscovery.js.map +1 -1
- package/dist/src/logic/RandomGraphNode.d.ts +10 -8
- package/dist/src/logic/RandomGraphNode.js +23 -17
- package/dist/src/logic/RandomGraphNode.js.map +1 -1
- package/dist/src/logic/StreamrNode.js +13 -4
- package/dist/src/logic/StreamrNode.js.map +1 -1
- package/dist/src/logic/formStreamPartDeliveryServiceId.d.ts +2 -1
- package/dist/src/logic/formStreamPartDeliveryServiceId.js.map +1 -1
- package/dist/src/logic/inspect/Inspector.d.ts +5 -11
- package/dist/src/logic/inspect/Inspector.js +2 -3
- package/dist/src/logic/inspect/Inspector.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.d.ts +3 -3
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js +39 -13
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.d.ts +5 -3
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js +18 -8
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/Handshaker.d.ts +1 -6
- package/dist/src/logic/neighbor-discovery/Handshaker.js +6 -6
- package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.d.ts +1 -6
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.d.ts +3 -8
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +1 -3
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js +1 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js.map +1 -1
- package/dist/src/logic/proxy/ProxyClient.d.ts +4 -1
- package/dist/src/logic/proxy/ProxyClient.js +7 -6
- package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js +2 -3
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.d.ts +2 -2
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.js.map +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +2 -2
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.d.ts +2 -2
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +21 -22
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +18 -18
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +36 -60
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +34 -53
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +11 -12
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.d.ts +6 -5
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js +2 -2
- 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 +26 -10
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js +21 -9
- 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 +4 -3
- package/dist/test/benchmark/first-message.js +4 -6
- package/dist/test/benchmark/first-message.js.map +1 -1
- package/dist/test/utils/utils.d.ts +1 -1
- package/dist/test/utils/utils.js +8 -7
- package/dist/test/utils/utils.js.map +1 -1
- package/package.json +7 -7
- package/protos/NetworkRpc.proto +8 -4
- package/src/NetworkStack.ts +1 -7
- package/src/logic/DeliveryRpcLocal.ts +4 -4
- package/src/logic/DeliveryRpcRemote.ts +5 -4
- package/src/logic/EntryPointDiscovery.ts +10 -6
- package/src/logic/RandomGraphNode.ts +38 -25
- package/src/logic/StreamrNode.ts +22 -5
- package/src/logic/formStreamPartDeliveryServiceId.ts +2 -1
- package/src/logic/inspect/Inspector.ts +15 -16
- package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +46 -15
- package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +21 -10
- package/src/logic/neighbor-discovery/Handshaker.ts +15 -24
- package/src/logic/neighbor-discovery/NeighborFinder.ts +1 -7
- package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +10 -12
- package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +4 -4
- package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +2 -2
- package/src/logic/proxy/ProxyClient.ts +19 -7
- package/src/logic/proxy/ProxyConnectionRpcLocal.ts +3 -3
- package/src/logic/proxy/ProxyConnectionRpcRemote.ts +3 -3
- package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +3 -2
- package/src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts +2 -2
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +31 -32
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +11 -12
- package/src/proto/packages/dht/protos/DhtRpc.ts +49 -80
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.client.ts +7 -6
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.server.ts +4 -3
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.ts +36 -15
- package/test/benchmark/first-message.ts +8 -6
- package/test/end-to-end/random-graph-with-real-connections.test.ts +10 -5
- package/test/end-to-end/webrtc-full-node-network.test.ts +1 -1
- package/test/end-to-end/websocket-full-node-network.test.ts +2 -2
- package/test/integration/DeliveryRpcRemote.test.ts +3 -3
- package/test/integration/HandshakeRpcRemote.test.ts +2 -4
- package/test/integration/Handshakes.test.ts +8 -7
- package/test/integration/Inspect.test.ts +0 -2
- package/test/integration/NeighborUpdateRpcRemote.test.ts +2 -2
- package/test/integration/NetworkNode.test.ts +0 -2
- package/test/integration/NetworkRpc.test.ts +0 -3
- package/test/integration/RandomGraphNode-Layer1Node-Latencies.test.ts +4 -4
- package/test/integration/RandomGraphNode-Layer1Node.test.ts +4 -5
- package/test/integration/stream-without-default-entrypoints.test.ts +4 -7
- package/test/integration/streamEntryPointReplacing.test.ts +94 -0
- package/test/unit/DeliveryRpcLocal.test.ts +2 -1
- package/test/unit/EntrypointDiscovery.test.ts +5 -2
- package/test/unit/HandshakeRpcLocal.test.ts +47 -9
- package/test/unit/NodeList.test.ts +10 -12
- package/test/unit/ProxyConnectionRpcRemote.test.ts +18 -10
- package/test/unit/RandomGraphNode.test.ts +6 -4
- package/test/utils/mock/MockHandshaker.ts +3 -2
- package/test/utils/mock/MockNeighborFinder.ts +3 -2
- package/test/utils/mock/MockNeighborUpdateManager.ts +3 -2
- package/test/utils/utils.ts +16 -8
|
@@ -3,7 +3,7 @@ import { hexToBinary } from '@streamr/utils'
|
|
|
3
3
|
import { NodeID, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
4
4
|
import { NodeList } from '../../src/logic/NodeList'
|
|
5
5
|
import { HandshakeRpcLocal } from '../../src/logic/neighbor-discovery/HandshakeRpcLocal'
|
|
6
|
-
import {
|
|
6
|
+
import { InterleaveRequest, StreamPartHandshakeRequest } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
7
7
|
import { createMockPeerDescriptor, createMockHandshakeRpcRemote, createMockDeliveryRpcRemote, mockConnectionLocker } from '../utils/utils'
|
|
8
8
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
9
9
|
|
|
@@ -17,18 +17,20 @@ describe('HandshakeRpcLocal', () => {
|
|
|
17
17
|
|
|
18
18
|
let targetNeighbors: NodeList
|
|
19
19
|
let ongoingHandshakes: Set<NodeID>
|
|
20
|
+
let ongoingInterleaves: Set<NodeID>
|
|
20
21
|
let handshakeWithInterleaving: jest.Mock
|
|
21
22
|
|
|
22
23
|
beforeEach(() => {
|
|
23
24
|
targetNeighbors = new NodeList(getNodeIdFromPeerDescriptor(localPeerDescriptor), 10)
|
|
24
25
|
ongoingHandshakes = new Set()
|
|
25
|
-
|
|
26
|
+
ongoingInterleaves = new Set()
|
|
26
27
|
handshakeWithInterleaving = jest.fn()
|
|
27
28
|
|
|
28
29
|
rpcLocal = new HandshakeRpcLocal({
|
|
29
30
|
streamPartId: STREAM_PART_ID,
|
|
30
31
|
connectionLocker: mockConnectionLocker,
|
|
31
32
|
ongoingHandshakes,
|
|
33
|
+
ongoingInterleaves,
|
|
32
34
|
createRpcRemote: (_p) => createMockHandshakeRpcRemote(),
|
|
33
35
|
createDeliveryRpcRemote: (_p) => createMockDeliveryRpcRemote(),
|
|
34
36
|
handshakeWithInterleaving: async (_p, _t) => {
|
|
@@ -85,31 +87,67 @@ describe('HandshakeRpcLocal', () => {
|
|
|
85
87
|
})
|
|
86
88
|
|
|
87
89
|
it('handshakeWithInterleaving success', async () => {
|
|
88
|
-
const req:
|
|
89
|
-
streamPartId: STREAM_PART_ID,
|
|
90
|
+
const req: InterleaveRequest = {
|
|
90
91
|
interleaveTargetDescriptor: {
|
|
91
92
|
nodeId: hexToBinary('0x2222'),
|
|
92
93
|
type: NodeType.NODEJS
|
|
93
94
|
}
|
|
94
|
-
|
|
95
95
|
}
|
|
96
|
-
await rpcLocal.
|
|
96
|
+
await rpcLocal.interleaveRequest(req, {
|
|
97
97
|
incomingSourceDescriptor: createMockPeerDescriptor()
|
|
98
98
|
} as any)
|
|
99
99
|
expect(handshakeWithInterleaving).toHaveBeenCalledTimes(1)
|
|
100
100
|
})
|
|
101
101
|
|
|
102
102
|
it('handshakeWithInterleaving success', async () => {
|
|
103
|
-
const req:
|
|
104
|
-
streamPartId: StreamPartIDUtils.parse('other-stream#0'),
|
|
103
|
+
const req: InterleaveRequest = {
|
|
105
104
|
interleaveTargetDescriptor: {
|
|
106
105
|
nodeId: hexToBinary('0x2222'),
|
|
107
106
|
type: NodeType.NODEJS
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
|
-
await rpcLocal.
|
|
109
|
+
await rpcLocal.interleaveRequest(req, {
|
|
110
|
+
incomingSourceDescriptor: createMockPeerDescriptor()
|
|
111
|
+
} as any)
|
|
112
|
+
expect(handshakeWithInterleaving).toHaveBeenCalledTimes(1)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('rejects handshakes if interleaving to the requestor is ongoing', async () => {
|
|
116
|
+
targetNeighbors.add(createMockDeliveryRpcRemote())
|
|
117
|
+
targetNeighbors.add(createMockDeliveryRpcRemote())
|
|
118
|
+
targetNeighbors.add(createMockDeliveryRpcRemote())
|
|
119
|
+
targetNeighbors.add(createMockDeliveryRpcRemote())
|
|
120
|
+
const requestor = createMockPeerDescriptor()
|
|
121
|
+
ongoingInterleaves.add(getNodeIdFromPeerDescriptor(requestor))
|
|
122
|
+
const req = StreamPartHandshakeRequest.create({
|
|
123
|
+
streamPartId: STREAM_PART_ID,
|
|
124
|
+
requestId: 'requestId'
|
|
125
|
+
})
|
|
126
|
+
const res = await rpcLocal.handshake(req, {
|
|
127
|
+
incomingSourceDescriptor: requestor
|
|
128
|
+
} as any)
|
|
129
|
+
expect(res.accepted).toEqual(false)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('Rejects if interleaving is required and too many interleaving requests are ongoing', async () => {
|
|
133
|
+
const interleavingPeer1 = createMockPeerDescriptor()
|
|
134
|
+
const interleavingPeer2 = createMockPeerDescriptor()
|
|
135
|
+
const interleavingPeer3 = createMockPeerDescriptor()
|
|
136
|
+
targetNeighbors.add(createMockDeliveryRpcRemote(interleavingPeer1))
|
|
137
|
+
targetNeighbors.add(createMockDeliveryRpcRemote(interleavingPeer2))
|
|
138
|
+
targetNeighbors.add(createMockDeliveryRpcRemote(interleavingPeer3))
|
|
139
|
+
targetNeighbors.add(createMockDeliveryRpcRemote())
|
|
140
|
+
ongoingInterleaves.add(getNodeIdFromPeerDescriptor(interleavingPeer1))
|
|
141
|
+
ongoingInterleaves.add(getNodeIdFromPeerDescriptor(interleavingPeer2))
|
|
142
|
+
ongoingInterleaves.add(getNodeIdFromPeerDescriptor(interleavingPeer3))
|
|
143
|
+
const req = StreamPartHandshakeRequest.create({
|
|
144
|
+
streamPartId: STREAM_PART_ID,
|
|
145
|
+
requestId: 'requestId'
|
|
146
|
+
})
|
|
147
|
+
const res = await rpcLocal.handshake(req, {
|
|
111
148
|
incomingSourceDescriptor: createMockPeerDescriptor()
|
|
112
149
|
} as any)
|
|
150
|
+
expect(res.accepted).toEqual(false)
|
|
113
151
|
expect(handshakeWithInterleaving).toHaveBeenCalledTimes(0)
|
|
114
152
|
})
|
|
115
153
|
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { NodeList } from '../../src/logic/NodeList'
|
|
2
|
-
import { DeliveryRpcRemote } from '../../src/logic/DeliveryRpcRemote'
|
|
3
1
|
import {
|
|
4
|
-
PeerDescriptor,
|
|
5
2
|
ListeningRpcCommunicator,
|
|
3
|
+
NodeType,
|
|
4
|
+
PeerDescriptor,
|
|
6
5
|
Simulator,
|
|
7
6
|
SimulatorTransport,
|
|
8
|
-
NodeType,
|
|
9
7
|
} from '@streamr/dht'
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
9
|
+
import { binaryToHex } from '@streamr/utils'
|
|
12
10
|
import { expect } from 'expect'
|
|
13
11
|
import { NodeID, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
12
|
+
import { DeliveryRpcRemote } from '../../src/logic/DeliveryRpcRemote'
|
|
13
|
+
import { NodeList } from '../../src/logic/NodeList'
|
|
17
14
|
import { formStreamPartDeliveryServiceId } from '../../src/logic/formStreamPartDeliveryServiceId'
|
|
15
|
+
import { DeliveryRpcClient } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
16
|
+
import { createMockPeerDescriptor, createRandomNodeId } from '../utils/utils'
|
|
18
17
|
|
|
19
18
|
const streamPartId = StreamPartIDUtils.parse('stream#0')
|
|
20
19
|
|
|
@@ -36,14 +35,13 @@ describe('NodeList', () => {
|
|
|
36
35
|
const mockTransport = new SimulatorTransport(peerDescriptor, simulator)
|
|
37
36
|
await mockTransport.start()
|
|
38
37
|
const mockCommunicator = new ListeningRpcCommunicator(formStreamPartDeliveryServiceId(streamPartId), mockTransport)
|
|
39
|
-
const mockClient = mockCommunicator.getRpcClientTransport()
|
|
40
|
-
|
|
41
38
|
mockTransports.push(mockTransport)
|
|
42
39
|
return new DeliveryRpcRemote(
|
|
43
40
|
createMockPeerDescriptor(),
|
|
44
41
|
peerDescriptor,
|
|
45
42
|
streamPartId,
|
|
46
|
-
|
|
43
|
+
mockCommunicator,
|
|
44
|
+
DeliveryRpcClient
|
|
47
45
|
)
|
|
48
46
|
}
|
|
49
47
|
|
|
@@ -1,30 +1,38 @@
|
|
|
1
|
+
import { RpcCommunicator } from '@streamr/proto-rpc'
|
|
1
2
|
import { StreamPartIDUtils } from '@streamr/protocol'
|
|
2
3
|
import { randomEthereumAddress } from '@streamr/test-utils'
|
|
3
4
|
import { hexToBinary } from '@streamr/utils'
|
|
4
5
|
import { ProxyConnectionRpcRemote } from '../../src/logic/proxy/ProxyConnectionRpcRemote'
|
|
5
|
-
import { ProxyDirection } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
6
|
+
import { ProxyConnectionRequest, ProxyDirection } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
7
|
+
import { ProxyConnectionRpcClient } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
6
8
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
7
9
|
|
|
8
10
|
describe('ProxyConnectionRpcRemote', () => {
|
|
9
11
|
|
|
10
|
-
it('happy path', () => {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
it('happy path', async () => {
|
|
13
|
+
const onOutgoingMessage = jest.fn()
|
|
14
|
+
const rpcCommunicator = new RpcCommunicator()
|
|
15
|
+
rpcCommunicator.setOutgoingMessageListener(onOutgoingMessage)
|
|
14
16
|
const clientPeerDescriptor = createMockPeerDescriptor()
|
|
15
17
|
const serverPeerDescriptor = createMockPeerDescriptor()
|
|
16
18
|
const rpcRemote = new ProxyConnectionRpcRemote(
|
|
17
19
|
clientPeerDescriptor,
|
|
18
20
|
serverPeerDescriptor,
|
|
19
21
|
StreamPartIDUtils.parse('stream#0'),
|
|
20
|
-
|
|
22
|
+
rpcCommunicator,
|
|
23
|
+
ProxyConnectionRpcClient
|
|
21
24
|
)
|
|
25
|
+
|
|
22
26
|
const userId = randomEthereumAddress()
|
|
23
|
-
rpcRemote.requestConnection(ProxyDirection.PUBLISH, userId)
|
|
24
|
-
|
|
27
|
+
await rpcRemote.requestConnection(ProxyDirection.PUBLISH, userId)
|
|
28
|
+
|
|
29
|
+
const [rpcMessage, _, callContext] = onOutgoingMessage.mock.calls[0]
|
|
30
|
+
const request = ProxyConnectionRequest.fromBinary(rpcMessage.body.value)
|
|
31
|
+
expect(request).toEqual({
|
|
25
32
|
direction: ProxyDirection.PUBLISH,
|
|
26
|
-
userId: hexToBinary(userId)
|
|
27
|
-
}
|
|
33
|
+
userId: Uint8Array.from(hexToBinary(userId))
|
|
34
|
+
})
|
|
35
|
+
expect(callContext).toMatchObject({
|
|
28
36
|
sourceDescriptor: clientPeerDescriptor,
|
|
29
37
|
targetDescriptor: serverPeerDescriptor,
|
|
30
38
|
timeout: 5000
|
|
@@ -38,10 +38,12 @@ describe('RandomGraphNode', () => {
|
|
|
38
38
|
localPeerDescriptor: peerDescriptor,
|
|
39
39
|
layer1Node,
|
|
40
40
|
connectionLocker: mockConnectionLocker,
|
|
41
|
-
handshaker: new MockHandshaker(),
|
|
42
|
-
neighborUpdateManager: new MockNeighborUpdateManager(),
|
|
43
|
-
neighborFinder: new MockNeighborFinder(),
|
|
44
|
-
streamPartId: StreamPartIDUtils.parse('stream#0')
|
|
41
|
+
handshaker: new MockHandshaker() as any,
|
|
42
|
+
neighborUpdateManager: new MockNeighborUpdateManager() as any,
|
|
43
|
+
neighborFinder: new MockNeighborFinder() as any,
|
|
44
|
+
streamPartId: StreamPartIDUtils.parse('stream#0'),
|
|
45
|
+
isLocalNodeEntryPoint: () => false
|
|
46
|
+
|
|
45
47
|
})
|
|
46
48
|
await randomGraphNode.start()
|
|
47
49
|
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Methods } from '@streamr/test-utils'
|
|
1
2
|
import { NodeID } from '../../../src/identifiers'
|
|
2
|
-
import {
|
|
3
|
+
import { Handshaker } from '../../../src/logic/neighbor-discovery/Handshaker'
|
|
3
4
|
|
|
4
|
-
export class MockHandshaker implements
|
|
5
|
+
export class MockHandshaker implements Methods<Handshaker> {
|
|
5
6
|
|
|
6
7
|
// eslint-disable-next-line class-methods-use-this
|
|
7
8
|
getOngoingHandshakes(): Set<NodeID> {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Methods } from '@streamr/test-utils'
|
|
2
|
+
import { NeighborFinder } from '../../../src/logic/neighbor-discovery/NeighborFinder'
|
|
2
3
|
|
|
3
|
-
export class MockNeighborFinder implements
|
|
4
|
+
export class MockNeighborFinder implements Methods<NeighborFinder> {
|
|
4
5
|
|
|
5
6
|
// eslint-disable-next-line class-methods-use-this
|
|
6
7
|
start(): void {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Methods } from '@streamr/test-utils'
|
|
2
|
+
import { NeighborUpdateManager } from '../../../src/logic/neighbor-discovery/NeighborUpdateManager'
|
|
2
3
|
import { NeighborUpdate } from '../../../src/proto/packages/trackerless-network/protos/NetworkRpc'
|
|
3
4
|
|
|
4
|
-
export class MockNeighborUpdateManager implements
|
|
5
|
+
export class MockNeighborUpdateManager implements Methods<NeighborUpdateManager> {
|
|
5
6
|
|
|
6
7
|
// eslint-disable-next-line class-methods-use-this
|
|
7
8
|
async start(): Promise<void> {
|
package/test/utils/utils.ts
CHANGED
|
@@ -16,6 +16,8 @@ import { EthereumAddress, hexToBinary, utf8ToBinary } from '@streamr/utils'
|
|
|
16
16
|
import { StreamPartID, StreamPartIDUtils } from '@streamr/protocol'
|
|
17
17
|
import { NodeID } from '../../src/identifiers'
|
|
18
18
|
import { Layer1Node } from '../../src/logic/Layer1Node'
|
|
19
|
+
import { DeliveryRpcClient, HandshakeRpcClient } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
20
|
+
import { RpcCommunicator } from '@streamr/proto-rpc'
|
|
19
21
|
|
|
20
22
|
export const mockConnectionLocker: ConnectionLocker = {
|
|
21
23
|
lockConnection: () => {},
|
|
@@ -45,7 +47,8 @@ export const createMockRandomGraphNodeAndDhtNode = async (
|
|
|
45
47
|
layer1Node,
|
|
46
48
|
connectionLocker: mockCm,
|
|
47
49
|
localPeerDescriptor,
|
|
48
|
-
rpcRequestTimeout: 5000
|
|
50
|
+
rpcRequestTimeout: 5000,
|
|
51
|
+
isLocalNodeEntryPoint: () => false
|
|
49
52
|
})
|
|
50
53
|
return [layer1Node, randomGraphNode]
|
|
51
54
|
}
|
|
@@ -90,7 +93,13 @@ export const createMockPeerDescriptor = (opts?: Omit<Partial<PeerDescriptor>, 'n
|
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
export const createMockDeliveryRpcRemote = (remotePeerDescriptor?: PeerDescriptor): DeliveryRpcRemote => {
|
|
93
|
-
return new DeliveryRpcRemote(
|
|
96
|
+
return new DeliveryRpcRemote(
|
|
97
|
+
createMockPeerDescriptor(),
|
|
98
|
+
remotePeerDescriptor ?? createMockPeerDescriptor(),
|
|
99
|
+
'mock',
|
|
100
|
+
new RpcCommunicator(),
|
|
101
|
+
DeliveryRpcClient
|
|
102
|
+
)
|
|
94
103
|
}
|
|
95
104
|
|
|
96
105
|
export const createMockHandshakeRpcRemote = (): HandshakeRpcRemote => {
|
|
@@ -98,19 +107,18 @@ export const createMockHandshakeRpcRemote = (): HandshakeRpcRemote => {
|
|
|
98
107
|
createMockPeerDescriptor(),
|
|
99
108
|
createMockPeerDescriptor(),
|
|
100
109
|
'mock',
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
interleaveNotice: async () => {}
|
|
104
|
-
} as any
|
|
110
|
+
new RpcCommunicator(),
|
|
111
|
+
HandshakeRpcClient
|
|
105
112
|
)
|
|
106
113
|
}
|
|
107
114
|
|
|
108
|
-
export const createNetworkNodeWithSimulator = (
|
|
115
|
+
export const createNetworkNodeWithSimulator = async (
|
|
109
116
|
peerDescriptor: PeerDescriptor,
|
|
110
117
|
simulator: Simulator,
|
|
111
118
|
entryPoints: PeerDescriptor[]
|
|
112
|
-
): NetworkNode => {
|
|
119
|
+
): Promise<NetworkNode> => {
|
|
113
120
|
const transport = new SimulatorTransport(peerDescriptor, simulator)
|
|
121
|
+
await transport.start()
|
|
114
122
|
return createNetworkNode({
|
|
115
123
|
layer0: {
|
|
116
124
|
peerDescriptor,
|