@streamr/dht 100.0.0-pretestnet.6 → 100.0.0-testnet-one.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/connection/ConnectionLockHandler.js +2 -2
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +2 -2
- package/dist/src/connection/ConnectionLockRpcRemote.js +3 -27
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +0 -1
- package/dist/src/connection/ConnectionManager.js +11 -7
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +2 -2
- package/dist/src/connection/ConnectorFacade.js +1 -2
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/ManagedConnection.js +1 -0
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/connectivityChecker.d.ts +9 -0
- package/dist/src/connection/connectivityChecker.js +122 -0
- package/dist/src/connection/connectivityChecker.js.map +1 -0
- package/dist/src/connection/connectivityRequestHandler.d.ts +2 -0
- package/dist/src/connection/connectivityRequestHandler.js +79 -0
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -0
- package/dist/src/connection/simulator/Simulator.js +3 -2
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +2 -2
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js +2 -2
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/ClientWebsocket.d.ts +1 -0
- package/dist/src/connection/websocket/ClientWebsocket.js +7 -3
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/ServerWebsocket.d.ts +4 -0
- package/dist/src/connection/websocket/ServerWebsocket.js +32 -21
- package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +0 -2
- package/dist/src/connection/websocket/WebsocketConnector.js +61 -16
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +8 -11
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +4 -4
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js +5 -39
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServer.js +21 -4
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +13 -23
- package/dist/src/dht/DhtNode.js +97 -226
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +1 -4
- package/dist/src/dht/DhtNodeRpcLocal.js +1 -5
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +3 -3
- package/dist/src/dht/DhtNodeRpcRemote.js +4 -4
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +4 -4
- package/dist/src/dht/ExternalApiRpcLocal.js +5 -12
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcRemote.js +5 -5
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +52 -0
- package/dist/src/dht/PeerManager.js +273 -0
- package/dist/src/dht/PeerManager.js.map +1 -0
- package/dist/src/dht/contact/ContactList.d.ts +1 -1
- package/dist/src/dht/contact/ContactList.js +1 -0
- package/dist/src/dht/contact/ContactList.js.map +1 -1
- package/dist/src/dht/contact/{Remote.d.ts → RpcRemote.d.ts} +3 -3
- package/dist/src/dht/contact/{Remote.js → RpcRemote.js} +8 -8
- package/dist/src/dht/contact/RpcRemote.js.map +1 -0
- package/dist/src/dht/contact/SortedContactList.d.ts +20 -6
- package/dist/src/dht/contact/SortedContactList.js +55 -24
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +4 -14
- package/dist/src/dht/discovery/DiscoverySession.js +15 -26
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +2 -9
- package/dist/src/dht/discovery/PeerDiscovery.js +11 -19
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/find/FindRpcLocal.js +2 -1
- package/dist/src/dht/find/FindRpcLocal.js.map +1 -1
- package/dist/src/dht/find/FindSession.d.ts +6 -6
- package/dist/src/dht/find/FindSession.js +18 -13
- package/dist/src/dht/find/FindSession.js.map +1 -1
- package/dist/src/dht/find/FindSessionRpcLocal.d.ts +1 -1
- package/dist/src/dht/find/FindSessionRpcRemote.d.ts +2 -2
- package/dist/src/dht/find/FindSessionRpcRemote.js +2 -2
- package/dist/src/dht/find/FindSessionRpcRemote.js.map +1 -1
- package/dist/src/dht/find/Finder.d.ts +4 -4
- package/dist/src/dht/find/Finder.js +55 -42
- package/dist/src/dht/find/Finder.js.map +1 -1
- package/dist/src/dht/routing/FindRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/FindRpcRemote.js +7 -5
- package/dist/src/dht/routing/FindRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +3 -7
- package/dist/src/dht/routing/Router.js +29 -22
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcLocal.js +4 -3
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcRemote.js +13 -8
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +1 -1
- package/dist/src/dht/routing/RoutingSession.js +23 -11
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/getPreviousPeer.js.map +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +3 -3
- package/dist/src/dht/store/LocalDataStore.js +18 -17
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreRpcLocal.d.ts +10 -9
- package/dist/src/dht/store/StoreRpcLocal.js +108 -102
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +4 -5
- package/dist/src/dht/store/StoreRpcRemote.js +6 -15
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +1 -1
- package/dist/src/exports.js +4 -4
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/PeerID.d.ts +1 -0
- package/dist/src/helpers/PeerID.js +9 -4
- package/dist/src/helpers/PeerID.js.map +1 -1
- package/dist/src/helpers/UUID.js +1 -1
- package/dist/src/helpers/UUID.js.map +1 -1
- package/dist/src/helpers/nodeId.d.ts +1 -0
- package/dist/src/helpers/{kademliaId.js → nodeId.js} +4 -4
- package/dist/src/helpers/nodeId.js.map +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +4 -4
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +5 -16
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +2 -9
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +80 -95
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +67 -66
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +3 -10
- package/dist/src/transport/RoutingRpcCommunicator.js +2 -0
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/karma.config.js +2 -2
- package/package.json +5 -5
- package/protos/DhtRpc.proto +36 -36
- package/src/connection/ConnectionLockHandler.ts +2 -2
- package/src/connection/ConnectionLockRpcRemote.ts +3 -4
- package/src/connection/ConnectionManager.ts +19 -17
- package/src/connection/ConnectorFacade.ts +5 -7
- package/src/connection/ManagedConnection.ts +1 -0
- package/src/connection/connectivityChecker.ts +102 -0
- package/src/connection/connectivityRequestHandler.ts +79 -0
- package/src/connection/simulator/Simulator.ts +3 -2
- package/src/connection/simulator/SimulatorConnection.ts +1 -1
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +10 -10
- package/src/connection/webrtc/NodeWebrtcConnection.ts +1 -1
- package/src/connection/webrtc/WebrtcConnector.ts +1 -1
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +1 -1
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +2 -2
- package/src/connection/webrtc/iceServerAsString.ts +1 -1
- package/src/connection/websocket/ClientWebsocket.ts +6 -2
- package/src/connection/websocket/ServerWebsocket.ts +40 -25
- package/src/connection/websocket/WebsocketConnector.ts +43 -22
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +9 -11
- package/src/connection/websocket/WebsocketConnectorRpcRemote.ts +7 -16
- package/src/connection/websocket/WebsocketServer.ts +20 -5
- package/src/dht/DhtNode.ts +123 -280
- package/src/dht/DhtNodeRpcLocal.ts +2 -9
- package/src/dht/DhtNodeRpcRemote.ts +4 -4
- package/src/dht/ExternalApiRpcLocal.ts +8 -13
- package/src/dht/ExternalApiRpcRemote.ts +5 -5
- package/src/dht/PeerManager.ts +330 -0
- package/src/dht/contact/ContactList.ts +3 -2
- package/src/dht/contact/{Remote.ts → RpcRemote.ts} +7 -6
- package/src/dht/contact/SortedContactList.ts +87 -44
- package/src/dht/discovery/DiscoverySession.ts +19 -44
- package/src/dht/discovery/PeerDiscovery.ts +16 -28
- package/src/dht/find/FindRpcLocal.ts +2 -2
- package/src/dht/find/FindSession.ts +25 -20
- package/src/dht/find/FindSessionRpcLocal.ts +1 -1
- package/src/dht/find/FindSessionRpcRemote.ts +2 -2
- package/src/dht/find/Finder.ts +84 -64
- package/src/dht/routing/FindRpcRemote.ts +7 -5
- package/src/dht/routing/Router.ts +30 -25
- package/src/dht/routing/RouterRpcLocal.ts +5 -5
- package/src/dht/routing/RouterRpcRemote.ts +13 -10
- package/src/dht/routing/RoutingSession.ts +22 -17
- package/src/dht/routing/getPreviousPeer.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +18 -17
- package/src/dht/store/StoreRpcLocal.ts +118 -113
- package/src/dht/store/StoreRpcRemote.ts +7 -23
- package/src/exports.ts +1 -1
- package/src/helpers/PeerID.ts +8 -4
- package/src/helpers/UUID.ts +1 -1
- package/src/helpers/{kademliaId.ts → nodeId.ts} +1 -1
- package/src/helpers/peerIdFromPeerDescriptor.ts +6 -6
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +6 -20
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +3 -10
- package/src/proto/packages/dht/protos/DhtRpc.ts +103 -135
- package/src/transport/RoutingRpcCommunicator.ts +2 -0
- package/test/benchmark/Find.test.ts +5 -5
- package/test/benchmark/KademliaCorrectness.test.ts +3 -3
- package/test/benchmark/SortedContactListBenchmark.test.ts +150 -0
- package/test/benchmark/WebsocketServerMemoryLeak.test.ts +41 -0
- package/test/benchmark/kademlia-simulation/Contact.ts +1 -1
- package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +1 -1
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +6 -1
- package/test/end-to-end/Layer0-Layer1.test.ts +1 -1
- package/test/end-to-end/Layer0.test.ts +4 -4
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +11 -11
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +6 -6
- package/test/end-to-end/Layer0Webrtc.test.ts +2 -2
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +3 -3
- package/test/end-to-end/Layer1-Scale-Webrtc.test.ts +3 -3
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +1 -1
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +1 -1
- package/test/end-to-end/memory-leak.test.ts +9 -12
- package/test/integration/ConnectionLocking.test.ts +2 -2
- package/test/integration/ConnectionManager.test.ts +14 -14
- package/test/integration/DhtJoinPeerDiscovery.test.ts +3 -3
- package/test/integration/DhtNodeExternalAPI.test.ts +10 -7
- package/test/integration/DhtNodeRpcRemote.test.ts +4 -4
- package/test/integration/DhtRpc.test.ts +6 -6
- package/test/integration/Find.test.ts +3 -3
- package/test/integration/Layer1-scale.test.ts +3 -3
- package/test/integration/Mock-Layer1-Layer0.test.ts +16 -16
- package/test/integration/MultipleEntryPointJoining.test.ts +7 -7
- package/test/integration/{MigrateData.test.ts → ReplicateData.test.ts} +15 -10
- package/test/integration/RouteMessage.test.ts +2 -2
- package/test/integration/RouterRpcRemote.test.ts +2 -2
- package/test/integration/RpcErrors.test.ts +2 -2
- package/test/integration/ScaleDownDht.test.ts +4 -2
- package/test/integration/SimultaneousConnections.test.ts +89 -57
- package/test/integration/Store.test.ts +33 -13
- package/test/integration/StoreAndDelete.test.ts +19 -17
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +21 -21
- package/test/integration/StoreRpcRemote.test.ts +3 -3
- package/test/integration/WebrtcConnectionManagement.test.ts +2 -2
- package/test/integration/WebrtcConnectorRpc.test.ts +1 -1
- package/test/integration/WebsocketConnectionManagement.test.ts +41 -3
- package/test/integration/WebsocketConnectorRpc.test.ts +5 -7
- package/test/unit/ConnectivityHelpers.test.ts +4 -4
- package/test/unit/Finder.test.ts +69 -23
- package/test/unit/LocalDataStore.test.ts +60 -43
- package/test/unit/RandomContactList.test.ts +2 -2
- package/test/unit/Router.test.ts +19 -11
- package/test/unit/RoutingSession.test.ts +76 -0
- package/test/unit/SortedContactList.test.ts +17 -12
- package/test/unit/WebsocketConnector.test.ts +1 -1
- package/test/unit/connectivityRequestHandler.test.ts +71 -0
- package/test/utils/mock/Router.ts +1 -1
- package/test/utils/utils.ts +24 -22
- package/dist/src/connection/ConnectivityChecker.d.ts +0 -17
- package/dist/src/connection/ConnectivityChecker.js +0 -208
- package/dist/src/connection/ConnectivityChecker.js.map +0 -1
- package/dist/src/dht/contact/Remote.js.map +0 -1
- package/dist/src/helpers/kademliaId.d.ts +0 -1
- package/dist/src/helpers/kademliaId.js.map +0 -1
- package/src/connection/ConnectivityChecker.ts +0 -199
|
@@ -20,16 +20,16 @@ const createConnectionManager = (localPeerDescriptor: PeerDescriptor, opts: Omit
|
|
|
20
20
|
describe('SimultaneousConnections', () => {
|
|
21
21
|
|
|
22
22
|
let simulator: Simulator
|
|
23
|
-
let
|
|
24
|
-
let
|
|
23
|
+
let simTransport1: SimulatorTransport
|
|
24
|
+
let simTransport2: SimulatorTransport
|
|
25
25
|
|
|
26
26
|
const peerDescriptor1 = {
|
|
27
|
-
|
|
27
|
+
nodeId: PeerID.fromString('mock1').value,
|
|
28
28
|
type: NodeType.NODEJS
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const peerDescriptor2 = {
|
|
32
|
-
|
|
32
|
+
nodeId: PeerID.fromString('mock2').value,
|
|
33
33
|
type: NodeType.NODEJS
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -45,15 +45,15 @@ describe('SimultaneousConnections', () => {
|
|
|
45
45
|
|
|
46
46
|
beforeEach(async () => {
|
|
47
47
|
simulator = new Simulator()
|
|
48
|
-
|
|
49
|
-
await
|
|
50
|
-
|
|
51
|
-
await
|
|
48
|
+
simTransport1 = new SimulatorTransport(peerDescriptor1, simulator)
|
|
49
|
+
await simTransport1.start()
|
|
50
|
+
simTransport2 = new SimulatorTransport(peerDescriptor2, simulator)
|
|
51
|
+
await simTransport2.start()
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
afterEach(async () => {
|
|
55
|
-
await
|
|
56
|
-
await
|
|
55
|
+
await simTransport1.stop()
|
|
56
|
+
await simTransport2.stop()
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
it('simultanous simulated connection', async () => {
|
|
@@ -67,13 +67,13 @@ describe('SimultaneousConnections', () => {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const promise1 = new Promise<void>((resolve, _reject) => {
|
|
70
|
-
|
|
70
|
+
simTransport1.on('message', async (message: Message) => {
|
|
71
71
|
expect(message.messageType).toBe(MessageType.RPC)
|
|
72
72
|
resolve()
|
|
73
73
|
})
|
|
74
74
|
})
|
|
75
75
|
const promise2 = new Promise<void>((resolve, _reject) => {
|
|
76
|
-
|
|
76
|
+
simTransport2.on('message', async (message: Message) => {
|
|
77
77
|
expect(message.messageType).toBe(MessageType.RPC)
|
|
78
78
|
resolve()
|
|
79
79
|
})
|
|
@@ -81,20 +81,22 @@ describe('SimultaneousConnections', () => {
|
|
|
81
81
|
await Promise.all([
|
|
82
82
|
promise1,
|
|
83
83
|
promise2,
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
simTransport1.send(msg1),
|
|
85
|
+
simTransport2.send(msg2)
|
|
86
86
|
])
|
|
87
|
-
await waitForCondition(() =>
|
|
88
|
-
await waitForCondition(() =>
|
|
87
|
+
await waitForCondition(() => simTransport2.hasConnection(peerDescriptor1))
|
|
88
|
+
await waitForCondition(() => simTransport1.hasConnection(peerDescriptor2))
|
|
89
89
|
})
|
|
90
90
|
|
|
91
91
|
describe('Websocket 2 servers', () => {
|
|
92
92
|
|
|
93
|
+
let simTransport1: SimulatorTransport
|
|
94
|
+
let simTransport2: SimulatorTransport
|
|
93
95
|
let connectionManager1: ConnectionManager
|
|
94
96
|
let connectionManager2: ConnectionManager
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
97
|
+
|
|
98
|
+
const wsPeerDescriptor1: PeerDescriptor = {
|
|
99
|
+
nodeId: PeerID.fromString('mock1').value,
|
|
98
100
|
type: NodeType.NODEJS,
|
|
99
101
|
websocket: {
|
|
100
102
|
host: '127.0.0.1',
|
|
@@ -103,8 +105,8 @@ describe('SimultaneousConnections', () => {
|
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
+
const wsPeerDescriptor2: PeerDescriptor = {
|
|
109
|
+
nodeId: PeerID.fromString('mock2').value,
|
|
108
110
|
type: NodeType.NODEJS,
|
|
109
111
|
websocket: {
|
|
110
112
|
host: '127.0.0.1',
|
|
@@ -114,17 +116,26 @@ describe('SimultaneousConnections', () => {
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
beforeEach(async () => {
|
|
119
|
+
|
|
120
|
+
// SimulatorTransport needs to have exatly same peerDescriptor as ConnectionManager
|
|
121
|
+
// that is why we need to create new SimulatorTransports here
|
|
122
|
+
simulator = new Simulator()
|
|
123
|
+
simTransport1 = new SimulatorTransport(wsPeerDescriptor1, simulator)
|
|
124
|
+
await simTransport1.start()
|
|
125
|
+
simTransport2 = new SimulatorTransport(wsPeerDescriptor2, simulator)
|
|
126
|
+
await simTransport2.start()
|
|
127
|
+
|
|
117
128
|
const websocketPortRange = { min: 43432, max: 43433 }
|
|
118
|
-
connectionManager1 = createConnectionManager(
|
|
119
|
-
transport:
|
|
129
|
+
connectionManager1 = createConnectionManager(wsPeerDescriptor1, {
|
|
130
|
+
transport: simTransport1,
|
|
120
131
|
websocketPortRange,
|
|
121
|
-
entryPoints: [
|
|
132
|
+
entryPoints: [wsPeerDescriptor1],
|
|
122
133
|
websocketServerEnableTls: false
|
|
123
134
|
})
|
|
124
|
-
connectionManager2 = createConnectionManager(
|
|
125
|
-
transport:
|
|
135
|
+
connectionManager2 = createConnectionManager(wsPeerDescriptor2, {
|
|
136
|
+
transport: simTransport2,
|
|
126
137
|
websocketPortRange,
|
|
127
|
-
entryPoints: [
|
|
138
|
+
entryPoints: [wsPeerDescriptor1],
|
|
128
139
|
websocketServerEnableTls: false
|
|
129
140
|
})
|
|
130
141
|
await connectionManager1.start()
|
|
@@ -134,16 +145,18 @@ describe('SimultaneousConnections', () => {
|
|
|
134
145
|
afterEach(async () => {
|
|
135
146
|
await connectionManager1.stop()
|
|
136
147
|
await connectionManager2.stop()
|
|
148
|
+
await simTransport1.stop()
|
|
149
|
+
await simTransport2.stop()
|
|
137
150
|
})
|
|
138
151
|
|
|
139
152
|
it('Simultaneous Connections', async () => {
|
|
140
153
|
const msg1: Message = {
|
|
141
154
|
...baseMsg,
|
|
142
|
-
targetDescriptor:
|
|
155
|
+
targetDescriptor: wsPeerDescriptor2
|
|
143
156
|
}
|
|
144
157
|
const msg2: Message = {
|
|
145
158
|
...baseMsg,
|
|
146
|
-
targetDescriptor:
|
|
159
|
+
targetDescriptor: wsPeerDescriptor1
|
|
147
160
|
}
|
|
148
161
|
|
|
149
162
|
const promise1 = new Promise<void>((resolve, _reject) => {
|
|
@@ -166,18 +179,20 @@ describe('SimultaneousConnections', () => {
|
|
|
166
179
|
connectionManager2.send(msg2)
|
|
167
180
|
])
|
|
168
181
|
|
|
169
|
-
await waitForCondition(() => connectionManager1.hasConnection(
|
|
170
|
-
await waitForCondition(() => connectionManager2.hasConnection(
|
|
182
|
+
await waitForCondition(() => connectionManager1.hasConnection(wsPeerDescriptor2))
|
|
183
|
+
await waitForCondition(() => connectionManager2.hasConnection(wsPeerDescriptor1))
|
|
171
184
|
})
|
|
172
185
|
})
|
|
173
186
|
|
|
174
187
|
describe('Websocket 1 server (ConnectionRequests)', () => {
|
|
175
|
-
|
|
188
|
+
|
|
189
|
+
let simTransport1: SimulatorTransport
|
|
190
|
+
let simTransport2: SimulatorTransport
|
|
176
191
|
let connectionManager1: ConnectionManager
|
|
177
192
|
let connectionManager2: ConnectionManager
|
|
178
193
|
|
|
179
|
-
const
|
|
180
|
-
|
|
194
|
+
const wsPeerDescriptor1: PeerDescriptor = {
|
|
195
|
+
nodeId: PeerID.fromString('mock1').value,
|
|
181
196
|
type: NodeType.NODEJS,
|
|
182
197
|
websocket: {
|
|
183
198
|
host: '127.0.0.1',
|
|
@@ -186,20 +201,26 @@ describe('SimultaneousConnections', () => {
|
|
|
186
201
|
}
|
|
187
202
|
}
|
|
188
203
|
|
|
189
|
-
const
|
|
190
|
-
|
|
204
|
+
const wsPeerDescriptor2: PeerDescriptor = {
|
|
205
|
+
nodeId: PeerID.fromString('mock2').value,
|
|
191
206
|
type: NodeType.NODEJS
|
|
192
207
|
}
|
|
193
208
|
|
|
194
209
|
beforeEach(async () => {
|
|
195
|
-
|
|
196
|
-
|
|
210
|
+
simulator = new Simulator()
|
|
211
|
+
simTransport1 = new SimulatorTransport(wsPeerDescriptor1, simulator)
|
|
212
|
+
await simTransport1.start()
|
|
213
|
+
simTransport2 = new SimulatorTransport(wsPeerDescriptor2, simulator)
|
|
214
|
+
await simTransport2.start()
|
|
215
|
+
|
|
216
|
+
connectionManager1 = createConnectionManager(wsPeerDescriptor1, {
|
|
217
|
+
transport: simTransport1,
|
|
197
218
|
websocketPortRange: { min: 43432, max: 43432 },
|
|
198
|
-
entryPoints: [
|
|
219
|
+
entryPoints: [wsPeerDescriptor1],
|
|
199
220
|
websocketServerEnableTls: false
|
|
200
221
|
})
|
|
201
|
-
connectionManager2 = createConnectionManager(
|
|
202
|
-
transport:
|
|
222
|
+
connectionManager2 = createConnectionManager(wsPeerDescriptor2, {
|
|
223
|
+
transport: simTransport2
|
|
203
224
|
})
|
|
204
225
|
await connectionManager1.start()
|
|
205
226
|
await connectionManager2.start()
|
|
@@ -208,16 +229,18 @@ describe('SimultaneousConnections', () => {
|
|
|
208
229
|
afterEach(async () => {
|
|
209
230
|
await connectionManager1.stop()
|
|
210
231
|
await connectionManager2.stop()
|
|
232
|
+
await simTransport1.stop()
|
|
233
|
+
await simTransport2.stop()
|
|
211
234
|
})
|
|
212
235
|
|
|
213
236
|
it('Simultaneous Connections', async () => {
|
|
214
237
|
const msg1: Message = {
|
|
215
238
|
...baseMsg,
|
|
216
|
-
targetDescriptor:
|
|
239
|
+
targetDescriptor: wsPeerDescriptor2
|
|
217
240
|
}
|
|
218
241
|
const msg2: Message = {
|
|
219
242
|
...baseMsg,
|
|
220
|
-
targetDescriptor:
|
|
243
|
+
targetDescriptor: wsPeerDescriptor1
|
|
221
244
|
}
|
|
222
245
|
|
|
223
246
|
const promise1 = new Promise<void>((resolve, _reject) => {
|
|
@@ -240,32 +263,39 @@ describe('SimultaneousConnections', () => {
|
|
|
240
263
|
connectionManager2.send(msg2)
|
|
241
264
|
])
|
|
242
265
|
|
|
243
|
-
await waitForCondition(() => connectionManager1.hasConnection(
|
|
244
|
-
await waitForCondition(() => connectionManager2.hasConnection(
|
|
266
|
+
await waitForCondition(() => connectionManager1.hasConnection(wsPeerDescriptor2))
|
|
267
|
+
await waitForCondition(() => connectionManager2.hasConnection(wsPeerDescriptor1))
|
|
245
268
|
})
|
|
246
269
|
})
|
|
247
270
|
|
|
248
271
|
describe('WebRTC', () => {
|
|
249
272
|
|
|
273
|
+
let simTransport1: SimulatorTransport
|
|
274
|
+
let simTransport2: SimulatorTransport
|
|
250
275
|
let connectionManager1: ConnectionManager
|
|
251
276
|
let connectionManager2: ConnectionManager
|
|
252
277
|
|
|
253
|
-
const
|
|
254
|
-
|
|
278
|
+
const wrtcPeerDescriptor1: PeerDescriptor = {
|
|
279
|
+
nodeId: PeerID.fromString('mock1').value,
|
|
255
280
|
type: NodeType.NODEJS
|
|
256
281
|
}
|
|
257
282
|
|
|
258
|
-
const
|
|
259
|
-
|
|
283
|
+
const wrtcPeerDescriptor2: PeerDescriptor = {
|
|
284
|
+
nodeId: PeerID.fromString('mock2').value,
|
|
260
285
|
type: NodeType.NODEJS
|
|
261
286
|
}
|
|
262
287
|
|
|
263
288
|
beforeEach(async () => {
|
|
264
|
-
|
|
265
|
-
|
|
289
|
+
simulator = new Simulator()
|
|
290
|
+
simTransport1 = new SimulatorTransport(wrtcPeerDescriptor1, simulator)
|
|
291
|
+
await simTransport1.start()
|
|
292
|
+
simTransport2 = new SimulatorTransport(wrtcPeerDescriptor2, simulator)
|
|
293
|
+
await simTransport2.start()
|
|
294
|
+
connectionManager1 = createConnectionManager(wrtcPeerDescriptor1, {
|
|
295
|
+
transport: simTransport1,
|
|
266
296
|
})
|
|
267
|
-
connectionManager2 = createConnectionManager(
|
|
268
|
-
transport:
|
|
297
|
+
connectionManager2 = createConnectionManager(wrtcPeerDescriptor2, {
|
|
298
|
+
transport: simTransport2,
|
|
269
299
|
})
|
|
270
300
|
await connectionManager1.start()
|
|
271
301
|
await connectionManager2.start()
|
|
@@ -274,16 +304,18 @@ describe('SimultaneousConnections', () => {
|
|
|
274
304
|
afterEach(async () => {
|
|
275
305
|
await connectionManager1.stop()
|
|
276
306
|
await connectionManager2.stop()
|
|
307
|
+
await simTransport1.stop()
|
|
308
|
+
await simTransport2.stop()
|
|
277
309
|
})
|
|
278
310
|
|
|
279
311
|
it('Simultaneous Connections', async () => {
|
|
280
312
|
const msg1: Message = {
|
|
281
313
|
...baseMsg,
|
|
282
|
-
targetDescriptor:
|
|
314
|
+
targetDescriptor: wrtcPeerDescriptor2
|
|
283
315
|
}
|
|
284
316
|
const msg2: Message = {
|
|
285
317
|
...baseMsg,
|
|
286
|
-
targetDescriptor:
|
|
318
|
+
targetDescriptor: wrtcPeerDescriptor1
|
|
287
319
|
}
|
|
288
320
|
|
|
289
321
|
const promise1 = new Promise<void>((resolve, _reject) => {
|
|
@@ -306,8 +338,8 @@ describe('SimultaneousConnections', () => {
|
|
|
306
338
|
connectionManager2.send(msg2)
|
|
307
339
|
])
|
|
308
340
|
|
|
309
|
-
await waitForCondition(() => connectionManager1.hasConnection(
|
|
310
|
-
await waitForCondition(() => connectionManager2.hasConnection(
|
|
341
|
+
await waitForCondition(() => connectionManager1.hasConnection(wrtcPeerDescriptor2))
|
|
342
|
+
await waitForCondition(() => connectionManager2.hasConnection(wrtcPeerDescriptor1))
|
|
311
343
|
})
|
|
312
344
|
})
|
|
313
345
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
|
-
import { createMockConnectionDhtNode, waitConnectionManagersReadyForTesting } from '../utils/utils'
|
|
5
|
-
import { PeerID } from '../../src/helpers/PeerID'
|
|
4
|
+
import { createMockConnectionDhtNode, createMockPeerDescriptor, waitConnectionManagersReadyForTesting } from '../utils/utils'
|
|
6
5
|
import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
7
6
|
import { Any } from '../../src/proto/google/protobuf/any'
|
|
7
|
+
import { createRandomNodeId } from '../../src/helpers/nodeId'
|
|
8
8
|
|
|
9
9
|
describe('Storing data in DHT', () => {
|
|
10
10
|
let entryPoint: DhtNode
|
|
@@ -46,24 +46,44 @@ describe('Storing data in DHT', () => {
|
|
|
46
46
|
|
|
47
47
|
it('Storing data works', async () => {
|
|
48
48
|
const storingNodeIndex = 34
|
|
49
|
-
const dataKey =
|
|
50
|
-
const
|
|
51
|
-
const
|
|
49
|
+
const dataKey = createRandomNodeId()
|
|
50
|
+
const storedData = createMockPeerDescriptor()
|
|
51
|
+
const data = Any.pack(storedData, PeerDescriptor)
|
|
52
|
+
const successfulStorers = await nodes[storingNodeIndex].storeDataToDht(dataKey, data)
|
|
52
53
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
53
|
-
},
|
|
54
|
+
}, 30000)
|
|
54
55
|
|
|
55
56
|
it('Storing and getting data works', async () => {
|
|
56
57
|
const storingNode = getRandomNode()
|
|
57
|
-
const dataKey =
|
|
58
|
-
const
|
|
59
|
-
const
|
|
58
|
+
const dataKey = createRandomNodeId()
|
|
59
|
+
const storedData = createMockPeerDescriptor()
|
|
60
|
+
const data = Any.pack(storedData, PeerDescriptor)
|
|
61
|
+
const successfulStorers = await storingNode.storeDataToDht(dataKey, data)
|
|
60
62
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
61
63
|
|
|
62
64
|
const fetchingNode = getRandomNode()
|
|
63
|
-
const results = await fetchingNode.getDataFromDht(dataKey
|
|
65
|
+
const results = await fetchingNode.getDataFromDht(dataKey)
|
|
64
66
|
results.forEach((entry) => {
|
|
65
|
-
const
|
|
66
|
-
expect(areEqualPeerDescriptors(
|
|
67
|
+
const foundData = Any.unpack(entry.data!, PeerDescriptor)
|
|
68
|
+
expect(areEqualPeerDescriptors(foundData, storedData)).toBeTrue()
|
|
67
69
|
})
|
|
68
|
-
},
|
|
70
|
+
}, 30000)
|
|
71
|
+
|
|
72
|
+
it('storing with explicit creator', async () => {
|
|
73
|
+
const storingNode = getRandomNode()
|
|
74
|
+
const dataKey = createRandomNodeId()
|
|
75
|
+
const storedData = createMockPeerDescriptor()
|
|
76
|
+
const data = Any.pack(storedData, PeerDescriptor)
|
|
77
|
+
const requestor = createMockPeerDescriptor()
|
|
78
|
+
const successfulStorers = await storingNode.storeDataToDht(dataKey, data, requestor)
|
|
79
|
+
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
80
|
+
|
|
81
|
+
const fetchingNode = getRandomNode()
|
|
82
|
+
const results = await fetchingNode.getDataFromDht(dataKey)
|
|
83
|
+
results.forEach((entry) => {
|
|
84
|
+
const foundData = Any.unpack(entry.data!, PeerDescriptor)
|
|
85
|
+
expect(areEqualPeerDescriptors(foundData, storedData)).toBeTrue()
|
|
86
|
+
expect(areEqualPeerDescriptors(entry.creator!, requestor)).toBeTrue()
|
|
87
|
+
})
|
|
88
|
+
}, 30000)
|
|
69
89
|
})
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
|
-
import { createMockConnectionDhtNode, waitConnectionManagersReadyForTesting } from '../utils/utils'
|
|
5
|
-
import { PeerID } from '../../src/helpers/PeerID'
|
|
4
|
+
import { createMockConnectionDhtNode, createMockPeerDescriptor, waitConnectionManagersReadyForTesting } from '../utils/utils'
|
|
6
5
|
import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
7
6
|
import { Any } from '../../src/proto/google/protobuf/any'
|
|
7
|
+
import { createRandomNodeId } from '../../src/helpers/nodeId'
|
|
8
8
|
|
|
9
9
|
describe('Storing data in DHT', () => {
|
|
10
10
|
let entryPoint: DhtNode
|
|
@@ -46,45 +46,47 @@ describe('Storing data in DHT', () => {
|
|
|
46
46
|
|
|
47
47
|
it('Data can be deleted', async () => {
|
|
48
48
|
const storingNode = getRandomNode()
|
|
49
|
-
const dataKey =
|
|
50
|
-
const
|
|
51
|
-
const
|
|
49
|
+
const dataKey = createRandomNodeId()
|
|
50
|
+
const storedData = createMockPeerDescriptor()
|
|
51
|
+
const data = Any.pack(storedData, PeerDescriptor)
|
|
52
|
+
const successfulStorers = await storingNode.storeDataToDht(dataKey, data)
|
|
52
53
|
expect(successfulStorers.length).toBeGreaterThan(4)
|
|
53
|
-
await storingNode.deleteDataFromDht(dataKey
|
|
54
|
+
await storingNode.deleteDataFromDht(dataKey, true)
|
|
54
55
|
|
|
55
56
|
const fetchingNode = getRandomNode()
|
|
56
|
-
const results = await fetchingNode.getDataFromDht(dataKey
|
|
57
|
+
const results = await fetchingNode.getDataFromDht(dataKey)
|
|
57
58
|
results.forEach((entry) => {
|
|
58
59
|
const fetchedDescriptor = Any.unpack(entry.data!, PeerDescriptor)
|
|
59
60
|
expect(entry.deleted).toBeTrue()
|
|
60
|
-
expect(areEqualPeerDescriptors(fetchedDescriptor,
|
|
61
|
+
expect(areEqualPeerDescriptors(fetchedDescriptor, storedData)).toBeTrue()
|
|
61
62
|
})
|
|
62
63
|
}, 90000)
|
|
63
64
|
|
|
64
65
|
it('Data can be deleted and re-stored', async () => {
|
|
65
66
|
const storingNode = getRandomNode()
|
|
66
|
-
const dataKey =
|
|
67
|
-
const
|
|
68
|
-
const
|
|
67
|
+
const dataKey = createRandomNodeId()
|
|
68
|
+
const storedData = createMockPeerDescriptor()
|
|
69
|
+
const data = Any.pack(storedData, PeerDescriptor)
|
|
70
|
+
const successfulStorers1 = await storingNode.storeDataToDht(dataKey, data)
|
|
69
71
|
expect(successfulStorers1.length).toBeGreaterThan(4)
|
|
70
|
-
await storingNode.deleteDataFromDht(dataKey
|
|
72
|
+
await storingNode.deleteDataFromDht(dataKey, true)
|
|
71
73
|
|
|
72
74
|
const fetchingNode = getRandomNode()
|
|
73
|
-
const results1 = await fetchingNode.getDataFromDht(dataKey
|
|
75
|
+
const results1 = await fetchingNode.getDataFromDht(dataKey)
|
|
74
76
|
results1.forEach((entry) => {
|
|
75
77
|
const fetchedDescriptor = Any.unpack(entry.data!, PeerDescriptor)
|
|
76
78
|
expect(entry.deleted).toBeTrue()
|
|
77
|
-
expect(areEqualPeerDescriptors(fetchedDescriptor,
|
|
79
|
+
expect(areEqualPeerDescriptors(fetchedDescriptor, storedData)).toBeTrue()
|
|
78
80
|
})
|
|
79
81
|
|
|
80
|
-
const successfulStorers2 = await storingNode.storeDataToDht(dataKey
|
|
82
|
+
const successfulStorers2 = await storingNode.storeDataToDht(dataKey, data)
|
|
81
83
|
expect(successfulStorers2.length).toBeGreaterThan(4)
|
|
82
84
|
|
|
83
|
-
const results2 = await fetchingNode.getDataFromDht(dataKey
|
|
85
|
+
const results2 = await fetchingNode.getDataFromDht(dataKey)
|
|
84
86
|
results2.forEach((entry) => {
|
|
85
87
|
const fetchedDescriptor = Any.unpack(entry.data!, PeerDescriptor)
|
|
86
88
|
expect(entry.deleted).toBeFalse()
|
|
87
|
-
expect(areEqualPeerDescriptors(fetchedDescriptor,
|
|
89
|
+
expect(areEqualPeerDescriptors(fetchedDescriptor, storedData)).toBeTrue()
|
|
88
90
|
})
|
|
89
91
|
}, 90000)
|
|
90
92
|
})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
1
|
+
import { createMockConnectionDhtNode, createMockPeerDescriptor } from '../utils/utils'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
4
|
-
import { PeerID } from '../../src/helpers/PeerID'
|
|
5
4
|
import { Any } from '../../src/proto/google/protobuf/any'
|
|
6
5
|
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
7
6
|
import { areEqualPeerDescriptors } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
8
7
|
import { waitForCondition } from '@streamr/utils'
|
|
8
|
+
import { createRandomNodeId } from '../../src/helpers/nodeId'
|
|
9
9
|
|
|
10
10
|
describe('Storing data in DHT with two peers', () => {
|
|
11
11
|
|
|
@@ -41,31 +41,31 @@ describe('Storing data in DHT with two peers', () => {
|
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
it('Node can store on two peer DHT', async () => {
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
44
|
+
const storedData1 = createMockPeerDescriptor()
|
|
45
|
+
const storedData2 = createMockPeerDescriptor()
|
|
46
|
+
const dataKey1 = createRandomNodeId()
|
|
47
|
+
const dataKey2 = createRandomNodeId()
|
|
48
|
+
const data1 = Any.pack(storedData1, PeerDescriptor)
|
|
49
|
+
const data2 = Any.pack(storedData2, PeerDescriptor)
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
expect(successfulStorers1[0].kademliaId).toStrictEqual(entryPoint.getLocalPeerDescriptor().kademliaId)
|
|
52
|
-
expect(successfulStorers2[0].kademliaId).toStrictEqual(otherNode.getLocalPeerDescriptor().kademliaId)
|
|
51
|
+
await otherNode.storeDataToDht(dataKey1, data1)
|
|
52
|
+
await entryPoint.storeDataToDht(dataKey2, data2)
|
|
53
53
|
|
|
54
|
-
const foundData1 = await otherNode.getDataFromDht(dataKey1
|
|
55
|
-
const foundData2 = await entryPoint.getDataFromDht(dataKey2
|
|
56
|
-
expect(areEqualPeerDescriptors(
|
|
57
|
-
expect(areEqualPeerDescriptors(
|
|
54
|
+
const foundData1 = await otherNode.getDataFromDht(dataKey1)
|
|
55
|
+
const foundData2 = await entryPoint.getDataFromDht(dataKey2)
|
|
56
|
+
expect(areEqualPeerDescriptors(storedData1, Any.unpack(foundData1[0]!.data!, PeerDescriptor))).toBeTrue()
|
|
57
|
+
expect(areEqualPeerDescriptors(storedData2, Any.unpack(foundData2[0]!.data!, PeerDescriptor))).toBeTrue()
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
it('Can store on one peer DHT', async () => {
|
|
61
61
|
await otherNode.stop()
|
|
62
|
-
await waitForCondition(() => entryPoint.
|
|
63
|
-
const dataKey =
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
62
|
+
await waitForCondition(() => entryPoint.getNumberOfNeighbors() === 0)
|
|
63
|
+
const dataKey = createRandomNodeId()
|
|
64
|
+
const storedData = createMockPeerDescriptor()
|
|
65
|
+
const data = Any.pack(storedData, PeerDescriptor)
|
|
66
|
+
await entryPoint.storeDataToDht(dataKey, data)
|
|
67
67
|
|
|
68
|
-
const foundData = await entryPoint.getDataFromDht(dataKey
|
|
69
|
-
expect(areEqualPeerDescriptors(
|
|
68
|
+
const foundData = await entryPoint.getDataFromDht(dataKey)
|
|
69
|
+
expect(areEqualPeerDescriptors(storedData, Any.unpack(foundData[0]!.data!, PeerDescriptor))).toBeTrue()
|
|
70
70
|
}, 60000)
|
|
71
71
|
})
|
|
@@ -18,16 +18,16 @@ describe('StoreRpcRemote', () => {
|
|
|
18
18
|
let serverRpcCommunicator: RpcCommunicator
|
|
19
19
|
const serviceId = 'test'
|
|
20
20
|
const clientPeerDescriptor: PeerDescriptor = {
|
|
21
|
-
|
|
21
|
+
nodeId: generateId('client'),
|
|
22
22
|
type: NodeType.NODEJS
|
|
23
23
|
}
|
|
24
24
|
const serverPeerDescriptor: PeerDescriptor = {
|
|
25
|
-
|
|
25
|
+
nodeId: generateId('server'),
|
|
26
26
|
type: NodeType.NODEJS
|
|
27
27
|
}
|
|
28
28
|
const data = Any.pack(clientPeerDescriptor, PeerDescriptor)
|
|
29
29
|
const request: StoreDataRequest = {
|
|
30
|
-
|
|
30
|
+
key: clientPeerDescriptor.nodeId,
|
|
31
31
|
data,
|
|
32
32
|
ttl: 10
|
|
33
33
|
}
|
|
@@ -28,12 +28,12 @@ describe('WebRTC Connection Management', () => {
|
|
|
28
28
|
let simulator: Simulator
|
|
29
29
|
|
|
30
30
|
const peerDescriptor1: PeerDescriptor = {
|
|
31
|
-
|
|
31
|
+
nodeId: PeerID.fromString('peer1').value,
|
|
32
32
|
type: NodeType.NODEJS,
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const peerDescriptor2: PeerDescriptor = {
|
|
36
|
-
|
|
36
|
+
nodeId: PeerID.fromString('peer2').value,
|
|
37
37
|
type: NodeType.NODEJS,
|
|
38
38
|
}
|
|
39
39
|
|