@streamr/dht 100.0.0-testnet-two.3 → 100.0.0-testnet-three.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 +8 -8
- package/dist/src/connection/Connection.d.ts +1 -0
- package/dist/src/connection/Connection.js +10 -3
- package/dist/src/connection/Connection.js.map +1 -1
- package/dist/src/connection/ConnectionLockHandler.d.ts +3 -3
- package/dist/src/connection/ConnectionLockHandler.js +8 -10
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.js +5 -4
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.js +4 -4
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +8 -8
- package/dist/src/connection/ConnectionManager.js +54 -57
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +3 -2
- package/dist/src/connection/ConnectorFacade.js +7 -0
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.js +3 -1
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/IConnection.d.ts +2 -7
- package/dist/src/connection/IConnection.js +1 -8
- package/dist/src/connection/IConnection.js.map +1 -1
- package/dist/src/connection/ManagedConnection.js +23 -15
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -1
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +5 -2
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.js +32 -20
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +13 -10
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +9 -6
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/simulator/pings.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +26 -14
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +0 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +18 -17
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +10 -9
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +3 -0
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
- package/dist/src/connection/websocket/ClientWebsocket.js +7 -4
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/ServerWebsocket.d.ts +1 -0
- package/dist/src/connection/websocket/ServerWebsocket.js +22 -3
- package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +2 -1
- package/dist/src/connection/websocket/WebsocketConnector.js +24 -15
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +2 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +3 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js +2 -2
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServer.js +6 -3
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +18 -19
- package/dist/src/dht/DhtNode.js +56 -65
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.js +5 -4
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +2 -1
- package/dist/src/dht/DhtNodeRpcRemote.js +5 -3
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.js +4 -3
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +5 -5
- package/dist/src/dht/PeerManager.js +31 -24
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/Contact.js +3 -2
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/ContactList.js +9 -5
- package/dist/src/dht/contact/ContactList.js.map +1 -1
- package/dist/src/dht/contact/RandomContactList.js +1 -0
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/RpcRemote.d.ts +2 -1
- package/dist/src/dht/contact/RpcRemote.js +4 -0
- package/dist/src/dht/contact/RpcRemote.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.js +3 -2
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.js +8 -8
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +8 -2
- package/dist/src/dht/discovery/PeerDiscovery.js +26 -17
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +9 -9
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +3 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +6 -5
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +2 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +26 -20
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +4 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +5 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/DuplicateDetector.d.ts +2 -4
- package/dist/src/dht/routing/DuplicateDetector.js +10 -15
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +1 -1
- package/dist/src/dht/routing/Router.js +20 -15
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.js +4 -4
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.js +11 -9
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +2 -0
- package/dist/src/dht/routing/RoutingSession.js +27 -9
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/LocalDataStore.js +5 -4
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.js +8 -8
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/dist/src/dht/store/StoreRpcLocal.js +1 -0
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.js +3 -3
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +1 -4
- package/dist/src/exports.js +4 -7
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/AddressTools.js.map +1 -1
- package/dist/src/helpers/Connectivity.js.map +1 -1
- package/dist/src/helpers/MapWithTtl.js +2 -1
- package/dist/src/helpers/MapWithTtl.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptor.d.ts +3 -0
- package/dist/src/helpers/createPeerDescriptor.js +56 -0
- package/dist/src/helpers/createPeerDescriptor.js.map +1 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +2 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +30 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -0
- package/dist/src/helpers/debugHelpers.js.map +1 -1
- package/dist/src/helpers/errors.js +2 -0
- package/dist/src/helpers/errors.js.map +1 -1
- package/dist/src/helpers/offering.d.ts +4 -0
- package/dist/src/helpers/offering.js +18 -0
- package/dist/src/helpers/offering.js.map +1 -0
- package/dist/src/helpers/protoToString.js.map +1 -1
- package/dist/src/identifiers.d.ts +3 -0
- package/dist/src/identifiers.js +9 -1
- package/dist/src/identifiers.js.map +1 -1
- package/dist/src/proto/google/protobuf/any.d.ts +8 -5
- package/dist/src/proto/google/protobuf/any.js +8 -8
- package/dist/src/proto/google/protobuf/any.js.map +1 -1
- package/dist/src/proto/google/protobuf/empty.d.ts +0 -1
- package/dist/src/proto/google/protobuf/empty.js +2 -4
- package/dist/src/proto/google/protobuf/empty.js.map +1 -1
- package/dist/src/proto/google/protobuf/timestamp.d.ts +10 -1
- package/dist/src/proto/google/protobuf/timestamp.js +10 -10
- package/dist/src/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +4 -5
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +38 -29
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +22 -12
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +11 -16
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +2 -3
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +0 -1
- package/dist/src/rpc-protocol/DhtCallContext.js +8 -0
- package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
- package/dist/src/transport/ITransport.d.ts +1 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +2 -0
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/RoutingRpcCommunicator.js +2 -0
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/package.json +8 -8
- package/protos/DhtRpc.proto +7 -4
- package/src/connection/Connection.ts +6 -1
- package/src/connection/ConnectionLockHandler.ts +3 -3
- package/src/connection/ConnectionLockRpcLocal.ts +1 -5
- package/src/connection/ConnectionLockRpcRemote.ts +1 -1
- package/src/connection/ConnectionManager.ts +24 -40
- package/src/connection/ConnectorFacade.ts +3 -2
- package/src/connection/IConnection.ts +2 -8
- package/src/connection/ManagedConnection.ts +3 -3
- package/src/connection/connectivityRequestHandler.ts +7 -3
- package/src/connection/simulator/Simulator.ts +1 -2
- package/src/connection/simulator/SimulatorConnection.ts +1 -1
- package/src/connection/simulator/SimulatorConnector.ts +1 -2
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +4 -3
- package/src/connection/webrtc/NodeWebrtcConnection.ts +5 -4
- package/src/connection/webrtc/WebrtcConnector.ts +9 -17
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +7 -7
- package/src/connection/websocket/ClientWebsocket.ts +3 -2
- package/src/connection/websocket/ServerWebsocket.ts +17 -1
- package/src/connection/websocket/WebsocketConnector.ts +10 -9
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +4 -2
- package/src/connection/websocket/WebsocketConnectorRpcRemote.ts +1 -1
- package/src/connection/websocket/WebsocketServer.ts +2 -2
- package/src/dht/DhtNode.ts +63 -86
- package/src/dht/DhtNodeRpcLocal.ts +5 -5
- package/src/dht/DhtNodeRpcRemote.ts +3 -3
- package/src/dht/ExternalApiRpcLocal.ts +3 -4
- package/src/dht/PeerManager.ts +14 -20
- package/src/dht/contact/Contact.ts +1 -2
- package/src/dht/contact/RpcRemote.ts +2 -1
- package/src/dht/discovery/DiscoverySession.ts +2 -3
- package/src/dht/discovery/PeerDiscovery.ts +16 -9
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +12 -6
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +1 -1
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +3 -2
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +19 -9
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +13 -3
- package/src/dht/routing/DuplicateDetector.ts +9 -21
- package/src/dht/routing/Router.ts +12 -11
- package/src/dht/routing/RouterRpcLocal.ts +1 -2
- package/src/dht/routing/RouterRpcRemote.ts +5 -5
- package/src/dht/routing/RoutingSession.ts +22 -2
- package/src/dht/store/StoreManager.ts +1 -2
- package/src/dht/store/StoreRpcRemote.ts +1 -1
- package/src/exports.ts +9 -4
- package/src/helpers/createPeerDescriptor.ts +56 -0
- package/src/helpers/createPeerDescriptorSignaturePayload.ts +28 -0
- package/src/helpers/offering.ts +15 -0
- package/src/identifiers.ts +10 -1
- package/src/proto/google/protobuf/any.ts +12 -9
- package/src/proto/google/protobuf/empty.ts +2 -5
- package/src/proto/google/protobuf/timestamp.ts +14 -5
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +6 -7
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +3 -4
- package/src/proto/packages/dht/protos/DhtRpc.ts +32 -20
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
- package/src/rpc-protocol/DhtCallContext.ts +0 -1
- package/src/transport/ITransport.ts +1 -1
- package/src/transport/RoutingRpcCommunicator.ts +1 -1
- package/test/benchmark/Find.test.ts +6 -8
- package/test/benchmark/KademliaCorrectness.test.ts +2 -3
- package/test/benchmark/SortedContactListBenchmark.test.ts +16 -16
- package/test/benchmark/WebsocketServerMemoryLeak.test.ts +1 -1
- package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +8 -8
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +8 -8
- 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 +12 -12
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +18 -18
- package/test/end-to-end/Layer0Webrtc.test.ts +13 -10
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +2 -2
- package/test/end-to-end/Layer1-Scale-Webrtc.test.ts +2 -2
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +1 -1
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +3 -3
- package/test/end-to-end/memory-leak.test.ts +2 -2
- package/test/integration/ConnectionLocking.test.ts +60 -47
- package/test/integration/ConnectionManager.test.ts +8 -7
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNodeExternalAPI.test.ts +1 -2
- package/test/integration/DhtNodeRpcRemote.test.ts +4 -3
- package/test/integration/DhtRpc.test.ts +4 -3
- package/test/integration/Find.test.ts +4 -6
- package/test/integration/Layer1-scale.test.ts +7 -7
- package/test/integration/Mock-Layer1-Layer0.test.ts +21 -24
- package/test/integration/MultipleEntryPointJoining.test.ts +7 -7
- package/test/integration/ReplicateData.test.ts +52 -161
- package/test/integration/RouteMessage.test.ts +24 -47
- package/test/integration/RouterRpcRemote.test.ts +7 -4
- package/test/integration/ScaleDownDht.test.ts +2 -3
- package/test/integration/SimultaneousConnections.test.ts +9 -8
- package/test/integration/Store.test.ts +1 -2
- package/test/integration/StoreAndDelete.test.ts +5 -0
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +59 -0
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +1 -1
- package/test/integration/StoreRpcRemote.test.ts +4 -4
- package/test/integration/WebrtcConnectionManagement.test.ts +6 -5
- package/test/integration/WebrtcConnectorRpc.test.ts +3 -2
- package/test/integration/WebsocketConnectionManagement.test.ts +27 -15
- package/test/integration/WebsocketConnectorRpc.test.ts +3 -2
- package/test/integration/{RpcErrors.test.ts → rpc-connections-over-webrpc.test.ts} +6 -3
- package/test/unit/DuplicateDetector.test.ts +2 -2
- package/test/unit/LocalDataStore.test.ts +1 -4
- package/test/unit/RandomContactList.test.ts +2 -4
- package/test/unit/RecursiveOperationManager.test.ts +5 -6
- package/test/unit/RecursiveOperationSession.test.ts +5 -4
- package/test/unit/Router.test.ts +25 -8
- package/test/unit/RoutingSession.test.ts +3 -3
- package/test/unit/SortedContactList.test.ts +2 -4
- package/test/unit/connectivityRequestHandler.test.ts +5 -3
- package/test/unit/createPeerDescriptor.test.ts +63 -0
- package/test/utils/FakeTransport.ts +7 -4
- package/test/utils/mock/Transport.ts +1 -1
- package/test/utils/utils.ts +6 -6
- package/dist/src/helpers/PeerID.d.ts +0 -27
- package/dist/src/helpers/PeerID.js +0 -87
- package/dist/src/helpers/PeerID.js.map +0 -1
- package/dist/src/helpers/UUID.d.ts +0 -8
- package/dist/src/helpers/UUID.js +0 -36
- package/dist/src/helpers/UUID.js.map +0 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +0 -7
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +0 -23
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +0 -1
- package/src/helpers/PeerID.ts +0 -97
- package/src/helpers/UUID.ts +0 -35
- package/src/helpers/peerIdFromPeerDescriptor.ts +0 -20
- package/test/unit/PeerID.test.ts +0 -22
- package/test/unit/UUID.test.ts +0 -55
|
@@ -3,10 +3,11 @@ import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
|
3
3
|
import { DefaultConnectorFacade } from '../../src/connection/ConnectorFacade'
|
|
4
4
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
5
5
|
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
6
|
-
import { ITransport } from '../../src/
|
|
6
|
+
import { ITransport } from '../../src/transport/ITransport'
|
|
7
7
|
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
8
8
|
import { getRandomRegion } from '../../dist/src/connection/simulator/pings'
|
|
9
9
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
10
|
+
import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
10
11
|
|
|
11
12
|
const createConnectionManager = (localPeerDescriptor: PeerDescriptor, transport: ITransport) => {
|
|
12
13
|
return new ConnectionManager({
|
|
@@ -55,114 +56,126 @@ describe('Connection Locking', () => {
|
|
|
55
56
|
})
|
|
56
57
|
|
|
57
58
|
it('can lock connections', async () => {
|
|
59
|
+
const nodeId1 = getNodeIdFromPeerDescriptor(mockPeerDescriptor1)
|
|
60
|
+
const nodeId2 = getNodeIdFromPeerDescriptor(mockPeerDescriptor2)
|
|
58
61
|
await Promise.all([
|
|
59
|
-
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(
|
|
62
|
+
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
60
63
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock')
|
|
61
64
|
])
|
|
62
|
-
expect(connectionManager1.hasConnection(
|
|
63
|
-
expect(connectionManager1.hasLocalLockedConnection(
|
|
64
|
-
expect(connectionManager2.hasRemoteLockedConnection(
|
|
65
|
+
expect(connectionManager1.hasConnection(nodeId2)).toEqual(true)
|
|
66
|
+
expect(connectionManager1.hasLocalLockedConnection(nodeId2)).toEqual(true)
|
|
67
|
+
expect(connectionManager2.hasRemoteLockedConnection(nodeId1)).toEqual(true)
|
|
65
68
|
})
|
|
66
69
|
|
|
67
70
|
it('Multiple services on the same peer', async () => {
|
|
71
|
+
const nodeId1 = getNodeIdFromPeerDescriptor(mockPeerDescriptor1)
|
|
72
|
+
const nodeId2 = getNodeIdFromPeerDescriptor(mockPeerDescriptor2)
|
|
68
73
|
await Promise.all([
|
|
69
|
-
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(
|
|
74
|
+
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
70
75
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock1')
|
|
71
76
|
])
|
|
72
77
|
await Promise.all([
|
|
73
|
-
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(
|
|
78
|
+
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
74
79
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock2')
|
|
75
80
|
])
|
|
76
|
-
expect(connectionManager1.hasConnection(
|
|
77
|
-
expect(connectionManager1.hasLocalLockedConnection(
|
|
78
|
-
expect(connectionManager2.hasRemoteLockedConnection(
|
|
81
|
+
expect(connectionManager1.hasConnection(nodeId2)).toEqual(true)
|
|
82
|
+
expect(connectionManager1.hasLocalLockedConnection(nodeId2)).toEqual(true)
|
|
83
|
+
expect(connectionManager2.hasRemoteLockedConnection(nodeId1)).toEqual(true)
|
|
79
84
|
})
|
|
80
85
|
|
|
81
86
|
it('can unlock connections', async () => {
|
|
87
|
+
const nodeId1 = getNodeIdFromPeerDescriptor(mockPeerDescriptor1)
|
|
88
|
+
const nodeId2 = getNodeIdFromPeerDescriptor(mockPeerDescriptor2)
|
|
82
89
|
await Promise.all([
|
|
83
|
-
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(
|
|
90
|
+
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
84
91
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock')
|
|
85
92
|
])
|
|
86
|
-
expect(connectionManager1.hasConnection(
|
|
87
|
-
expect(connectionManager2.hasLocalLockedConnection(
|
|
88
|
-
expect(connectionManager2.hasRemoteLockedConnection(
|
|
93
|
+
expect(connectionManager1.hasConnection(nodeId2))
|
|
94
|
+
expect(connectionManager2.hasLocalLockedConnection(nodeId2)).toEqual(false)
|
|
95
|
+
expect(connectionManager2.hasRemoteLockedConnection(nodeId1)).toEqual(true)
|
|
89
96
|
|
|
90
97
|
connectionManager1.unlockConnection(mockPeerDescriptor2, 'testLock')
|
|
91
|
-
expect(connectionManager1.hasLocalLockedConnection(
|
|
92
|
-
await waitForCondition(() => connectionManager2.hasRemoteLockedConnection(
|
|
93
|
-
expect(connectionManager1.hasConnection(
|
|
98
|
+
expect(connectionManager1.hasLocalLockedConnection(nodeId2)).toEqual(false)
|
|
99
|
+
await waitForCondition(() => connectionManager2.hasRemoteLockedConnection(nodeId1) === false)
|
|
100
|
+
expect(connectionManager1.hasConnection(nodeId1)).toEqual(false)
|
|
94
101
|
})
|
|
95
102
|
|
|
96
103
|
it('unlocking multiple services', async () => {
|
|
104
|
+
const nodeId1 = getNodeIdFromPeerDescriptor(mockPeerDescriptor1)
|
|
105
|
+
const nodeId2 = getNodeIdFromPeerDescriptor(mockPeerDescriptor2)
|
|
97
106
|
await Promise.all([
|
|
98
|
-
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(
|
|
107
|
+
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
99
108
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock1')
|
|
100
109
|
])
|
|
101
110
|
await Promise.all([
|
|
102
|
-
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(
|
|
111
|
+
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
103
112
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock2')
|
|
104
113
|
])
|
|
105
114
|
|
|
106
|
-
expect(connectionManager1.hasConnection(
|
|
107
|
-
expect(connectionManager2.hasLocalLockedConnection(
|
|
115
|
+
expect(connectionManager1.hasConnection(nodeId2))
|
|
116
|
+
expect(connectionManager2.hasLocalLockedConnection(nodeId1)).toEqual(false)
|
|
108
117
|
|
|
109
118
|
connectionManager1.unlockConnection(mockPeerDescriptor2, 'testLock1')
|
|
110
|
-
expect(connectionManager1.hasLocalLockedConnection(
|
|
119
|
+
expect(connectionManager1.hasLocalLockedConnection(nodeId2)).toEqual(true)
|
|
111
120
|
|
|
112
121
|
connectionManager1.unlockConnection(mockPeerDescriptor2, 'testLock2')
|
|
113
|
-
expect(connectionManager1.hasLocalLockedConnection(
|
|
114
|
-
expect(connectionManager1.hasConnection(
|
|
122
|
+
expect(connectionManager1.hasLocalLockedConnection(nodeId2)).toEqual(false)
|
|
123
|
+
expect(connectionManager1.hasConnection(nodeId1)).toEqual(false)
|
|
115
124
|
})
|
|
116
125
|
|
|
117
126
|
it('maintains connection if both sides initially lock and then one end unlocks', async () => {
|
|
127
|
+
const nodeId1 = getNodeIdFromPeerDescriptor(mockPeerDescriptor1)
|
|
128
|
+
const nodeId2 = getNodeIdFromPeerDescriptor(mockPeerDescriptor2)
|
|
118
129
|
await Promise.all([
|
|
119
|
-
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(
|
|
120
|
-
waitForCondition(() => connectionManager1.hasRemoteLockedConnection(
|
|
130
|
+
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
131
|
+
waitForCondition(() => connectionManager1.hasRemoteLockedConnection(nodeId2)),
|
|
121
132
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock1'),
|
|
122
133
|
connectionManager2.lockConnection(mockPeerDescriptor1, 'testLock1')
|
|
123
134
|
])
|
|
124
135
|
|
|
125
|
-
expect(connectionManager1.hasLocalLockedConnection(
|
|
126
|
-
expect(connectionManager2.hasLocalLockedConnection(
|
|
136
|
+
expect(connectionManager1.hasLocalLockedConnection(nodeId2))
|
|
137
|
+
expect(connectionManager2.hasLocalLockedConnection(nodeId1))
|
|
127
138
|
|
|
128
139
|
connectionManager1.unlockConnection(mockPeerDescriptor2, 'testLock1')
|
|
129
140
|
await waitForCondition(() =>
|
|
130
|
-
connectionManager1.hasRemoteLockedConnection(
|
|
131
|
-
&& !connectionManager1.hasLocalLockedConnection(
|
|
132
|
-
&& !connectionManager2.hasRemoteLockedConnection(
|
|
133
|
-
&& connectionManager2.hasLocalLockedConnection(
|
|
141
|
+
connectionManager1.hasRemoteLockedConnection(nodeId2)
|
|
142
|
+
&& !connectionManager1.hasLocalLockedConnection(nodeId2)
|
|
143
|
+
&& !connectionManager2.hasRemoteLockedConnection(nodeId1)
|
|
144
|
+
&& connectionManager2.hasLocalLockedConnection(nodeId1)
|
|
134
145
|
)
|
|
135
146
|
|
|
136
|
-
expect(connectionManager2.hasConnection(
|
|
137
|
-
expect(connectionManager1.hasConnection(
|
|
147
|
+
expect(connectionManager2.hasConnection(nodeId1)).toEqual(true)
|
|
148
|
+
expect(connectionManager1.hasConnection(nodeId2)).toEqual(true)
|
|
138
149
|
})
|
|
139
150
|
|
|
140
151
|
it('unlocks after graceful disconnect', async () => {
|
|
152
|
+
const nodeId1 = getNodeIdFromPeerDescriptor(mockPeerDescriptor1)
|
|
153
|
+
const nodeId2 = getNodeIdFromPeerDescriptor(mockPeerDescriptor2)
|
|
141
154
|
await Promise.all([
|
|
142
|
-
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(
|
|
143
|
-
waitForCondition(() => connectionManager1.hasRemoteLockedConnection(
|
|
155
|
+
waitForCondition(() => connectionManager2.hasRemoteLockedConnection(nodeId1)),
|
|
156
|
+
waitForCondition(() => connectionManager1.hasRemoteLockedConnection(nodeId2)),
|
|
144
157
|
connectionManager1.lockConnection(mockPeerDescriptor2, 'testLock1'),
|
|
145
158
|
connectionManager2.lockConnection(mockPeerDescriptor1, 'testLock1')
|
|
146
159
|
])
|
|
147
|
-
expect(connectionManager1.hasConnection(
|
|
148
|
-
expect(connectionManager2.hasLocalLockedConnection(
|
|
149
|
-
expect(connectionManager2.hasRemoteLockedConnection(
|
|
160
|
+
expect(connectionManager1.hasConnection(nodeId2))
|
|
161
|
+
expect(connectionManager2.hasLocalLockedConnection(nodeId1)).toEqual(true)
|
|
162
|
+
expect(connectionManager2.hasRemoteLockedConnection(nodeId1)).toEqual(true)
|
|
150
163
|
|
|
151
164
|
//@ts-expect-error private field
|
|
152
165
|
await connectionManager1.gracefullyDisconnectAsync(mockPeerDescriptor2)
|
|
153
166
|
|
|
154
167
|
await waitForCondition(() =>
|
|
155
|
-
!connectionManager1.hasRemoteLockedConnection(
|
|
156
|
-
&& !connectionManager1.hasLocalLockedConnection(
|
|
168
|
+
!connectionManager1.hasRemoteLockedConnection(nodeId2)
|
|
169
|
+
&& !connectionManager1.hasLocalLockedConnection(nodeId2)
|
|
157
170
|
)
|
|
158
171
|
await waitForCondition(() =>
|
|
159
|
-
!connectionManager2.hasRemoteLockedConnection(
|
|
160
|
-
&& !connectionManager2.hasLocalLockedConnection(
|
|
172
|
+
!connectionManager2.hasRemoteLockedConnection(nodeId1)
|
|
173
|
+
&& !connectionManager2.hasLocalLockedConnection(nodeId1)
|
|
161
174
|
)
|
|
162
|
-
await waitForCondition(() => !connectionManager2.hasConnection(
|
|
163
|
-
await waitForCondition(() => !connectionManager1.hasConnection(
|
|
175
|
+
await waitForCondition(() => !connectionManager2.hasConnection(nodeId1))
|
|
176
|
+
await waitForCondition(() => !connectionManager1.hasConnection(nodeId2))
|
|
164
177
|
|
|
165
|
-
expect(connectionManager1.hasConnection(
|
|
166
|
-
expect(connectionManager2.hasConnection(
|
|
178
|
+
expect(connectionManager1.hasConnection(nodeId2)).toEqual(false)
|
|
179
|
+
expect(connectionManager2.hasConnection(nodeId1)).toEqual(false)
|
|
167
180
|
}, 10000)
|
|
168
181
|
})
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { Logger, MetricsContext, waitForEvent3 } from '@streamr/utils'
|
|
2
|
+
import { MarkOptional } from 'ts-essentials'
|
|
1
3
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
2
|
-
import {
|
|
4
|
+
import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../../src/connection/ConnectorFacade'
|
|
3
5
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
4
|
-
import {
|
|
6
|
+
import { SimulatorTransport } from '../../src/connection/simulator/SimulatorTransport'
|
|
7
|
+
import { createPeerDescriptor } from '../../src/helpers/createPeerDescriptor'
|
|
8
|
+
import { createRandomDhtAddress, getRawFromDhtAddress } from '../../src/identifiers'
|
|
9
|
+
import { ConnectivityResponse, Message, MessageType, NodeType, PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
5
10
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
6
|
-
import { Logger, MetricsContext, waitForEvent3 } from '@streamr/utils'
|
|
7
|
-
import { SimulatorTransport } from '../../src/exports'
|
|
8
|
-
import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../../src/connection/ConnectorFacade'
|
|
9
|
-
import { MarkOptional } from 'ts-essentials'
|
|
10
11
|
import { TransportEvents } from '../../src/transport/ITransport'
|
|
11
12
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
12
|
-
import { createRandomDhtAddress, getRawFromDhtAddress } from '../../src/identifiers'
|
|
13
13
|
|
|
14
14
|
const SERVICE_ID = 'demo'
|
|
15
15
|
|
|
@@ -292,6 +292,7 @@ describe('ConnectionManager', () => {
|
|
|
292
292
|
await Promise.all([disconnectedPromise1, disconnectedPromise2])
|
|
293
293
|
await connectionManager3.stop()
|
|
294
294
|
await connectionManager4.stop()
|
|
295
|
+
simulator2.stop()
|
|
295
296
|
})
|
|
296
297
|
|
|
297
298
|
it('Cannot send to own WebsocketServer if nodeIds do not match', async () => {
|
|
@@ -21,10 +21,10 @@ const runTest = async (latencyType: LatencyType) => {
|
|
|
21
21
|
await entryPoint.joinDht([entrypointDescriptor])
|
|
22
22
|
await Promise.all(nodes.map((node) => node.joinDht([entrypointDescriptor])))
|
|
23
23
|
nodes.forEach((node) => {
|
|
24
|
-
expect(node.
|
|
24
|
+
expect(node.getNeighborCount()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET / 2)
|
|
25
25
|
expect(node.getClosestContacts().length).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET / 2)
|
|
26
26
|
})
|
|
27
|
-
expect(entryPoint.
|
|
27
|
+
expect(entryPoint.getNeighborCount()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET / 2)
|
|
28
28
|
|
|
29
29
|
await Promise.all([
|
|
30
30
|
entryPoint.stop(),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
|
-
import { createRandomDhtAddress, getDhtAddressFromRaw } from '../../src/identifiers'
|
|
4
|
-
import { getNodeIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
3
|
+
import { createRandomDhtAddress, getDhtAddressFromRaw, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
5
4
|
import { createMockDataEntry, expectEqualData } from '../utils/mock/mockDataEntry'
|
|
6
5
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
7
6
|
|
|
@@ -8,15 +8,16 @@ import {
|
|
|
8
8
|
PingResponse
|
|
9
9
|
} from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
10
10
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
11
|
-
import {
|
|
11
|
+
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
12
|
+
import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
12
13
|
|
|
13
14
|
const SERVICE_ID = 'test'
|
|
14
15
|
|
|
15
16
|
describe('DhtNodeRpcRemote', () => {
|
|
16
17
|
|
|
17
18
|
let rpcRemote: DhtNodeRpcRemote
|
|
18
|
-
let clientRpcCommunicator: RpcCommunicator
|
|
19
|
-
let serverRpcCommunicator: RpcCommunicator
|
|
19
|
+
let clientRpcCommunicator: RpcCommunicator<DhtCallContext>
|
|
20
|
+
let serverRpcCommunicator: RpcCommunicator<DhtCallContext>
|
|
20
21
|
const clientPeerDescriptor = createMockPeerDescriptor()
|
|
21
22
|
const serverPeerDescriptor = createMockPeerDescriptor()
|
|
22
23
|
const mockDhtRpc = createMockDhtRpc(createMockPeers())
|
|
@@ -4,12 +4,13 @@ import { DhtNodeRpcClient } from '../../src/proto/packages/dht/protos/DhtRpc.cli
|
|
|
4
4
|
import { ClosestPeersRequest, ClosestPeersResponse } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { wait } from '@streamr/utils'
|
|
6
6
|
import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
|
|
7
|
-
import { getNodeIdFromPeerDescriptor } from '../../src/
|
|
7
|
+
import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
8
|
+
import { DhtCallContext } from '../../src/rpc-protocol/DhtCallContext'
|
|
8
9
|
|
|
9
10
|
describe('DhtRpc', () => {
|
|
10
11
|
|
|
11
|
-
let rpcCommunicator1: RpcCommunicator
|
|
12
|
-
let rpcCommunicator2: RpcCommunicator
|
|
12
|
+
let rpcCommunicator1: RpcCommunicator<DhtCallContext>
|
|
13
|
+
let rpcCommunicator2: RpcCommunicator<DhtCallContext>
|
|
13
14
|
let client1: ProtoRpcClient<DhtNodeRpcClient>
|
|
14
15
|
let client2: ProtoRpcClient<DhtNodeRpcClient>
|
|
15
16
|
const peerDescriptor1 = createMockPeerDescriptor()
|
|
@@ -2,12 +2,10 @@ import { LatencyType, Simulator } from '../../src/connection/simulator/Simulator
|
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { PeerDescriptor, RecursiveOperation } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { createMockConnectionDhtNode, waitConnectionManagersReadyForTesting } from '../utils/utils'
|
|
5
|
-
import {
|
|
6
|
-
import { peerIdFromPeerDescriptor } from '../../src/helpers/peerIdFromPeerDescriptor'
|
|
7
|
-
import { getDhtAddressFromRaw, getRawFromDhtAddress } from '../../src/identifiers'
|
|
5
|
+
import { getDhtAddressFromRaw, getNodeIdFromPeerDescriptor, getRawFromDhtAddress } from '../../src/identifiers'
|
|
8
6
|
|
|
9
7
|
const NUM_NODES = 100
|
|
10
|
-
const K =
|
|
8
|
+
const K = 8
|
|
11
9
|
|
|
12
10
|
describe('Find correctness', () => {
|
|
13
11
|
|
|
@@ -22,7 +20,7 @@ describe('Find correctness', () => {
|
|
|
22
20
|
nodes.push(entryPoint)
|
|
23
21
|
entrypointDescriptor = entryPoint.getLocalPeerDescriptor()
|
|
24
22
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
25
|
-
const node = await createMockConnectionDhtNode(simulator, undefined, K,
|
|
23
|
+
const node = await createMockConnectionDhtNode(simulator, undefined, K, 40, 60000)
|
|
26
24
|
nodes.push(node)
|
|
27
25
|
}
|
|
28
26
|
await entryPoint.joinDht([entrypointDescriptor])
|
|
@@ -41,7 +39,7 @@ describe('Find correctness', () => {
|
|
|
41
39
|
const targetId = getRawFromDhtAddress(nodes[45].getNodeId())
|
|
42
40
|
const results = await entryPoint.executeRecursiveOperation(getDhtAddressFromRaw(targetId), RecursiveOperation.FIND_NODE)
|
|
43
41
|
expect(results.closestNodes.length).toBeGreaterThanOrEqual(5)
|
|
44
|
-
expect(
|
|
42
|
+
expect(getDhtAddressFromRaw(targetId)).toEqual(getNodeIdFromPeerDescriptor(results.closestNodes[0]))
|
|
45
43
|
}, 30000)
|
|
46
44
|
|
|
47
45
|
})
|
|
@@ -63,9 +63,9 @@ describe('Layer1', () => {
|
|
|
63
63
|
const layer0Node = nodes[i]
|
|
64
64
|
const layer1Node = layer1Nodes[i]
|
|
65
65
|
expect(layer1Node.getNodeId()).toEqual(layer0Node.getNodeId())
|
|
66
|
-
expect(layer1Node.
|
|
67
|
-
expect(layer1Node.
|
|
68
|
-
expect(layer1Node.
|
|
66
|
+
expect(layer1Node.getConnectionCount()).toEqual(layer0Node.getConnectionCount())
|
|
67
|
+
expect(layer1Node.getNeighborCount()).toBeGreaterThanOrEqual(NUM_OF_NODES_PER_KBUCKET / 2)
|
|
68
|
+
expect(layer1Node.getConnections()).toEqual(layer0Node.getConnections())
|
|
69
69
|
}
|
|
70
70
|
}, 120000)
|
|
71
71
|
|
|
@@ -119,10 +119,10 @@ describe('Layer1', () => {
|
|
|
119
119
|
const stream3Node = stream3[i]
|
|
120
120
|
const stream4Node = stream4[i]
|
|
121
121
|
|
|
122
|
-
expect(layer0Node.
|
|
123
|
-
expect(layer0Node.
|
|
124
|
-
expect(layer0Node.
|
|
125
|
-
expect(layer0Node.
|
|
122
|
+
expect(layer0Node.getConnectionCount()).toEqual(stream1Node.getConnectionCount())
|
|
123
|
+
expect(layer0Node.getConnectionCount()).toEqual(stream2Node.getConnectionCount())
|
|
124
|
+
expect(layer0Node.getConnectionCount()).toEqual(stream3Node.getConnectionCount())
|
|
125
|
+
expect(layer0Node.getConnectionCount()).toEqual(stream4Node.getConnectionCount())
|
|
126
126
|
|
|
127
127
|
}
|
|
128
128
|
}, 120000)
|
|
@@ -2,13 +2,10 @@ import { Logger } from '@streamr/utils'
|
|
|
2
2
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
4
|
import { createMockConnectionDhtNode, createMockConnectionLayer1Node } from '../utils/utils'
|
|
5
|
-
import {
|
|
6
|
-
import { getDhtAddressFromRaw } from '../../src/identifiers'
|
|
5
|
+
import { createRandomDhtAddress } from '../../src/identifiers'
|
|
7
6
|
|
|
8
7
|
const logger = new Logger(module)
|
|
9
8
|
|
|
10
|
-
// TODO refactor the test to not to use PeerID
|
|
11
|
-
|
|
12
9
|
describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
13
10
|
|
|
14
11
|
const simulator = new Simulator()
|
|
@@ -25,11 +22,11 @@ describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
|
25
22
|
|
|
26
23
|
beforeEach(async () => {
|
|
27
24
|
|
|
28
|
-
layer0EntryPoint = await createMockConnectionDhtNode(simulator,
|
|
29
|
-
layer0Node1 = await createMockConnectionDhtNode(simulator,
|
|
30
|
-
layer0Node2 = await createMockConnectionDhtNode(simulator,
|
|
31
|
-
layer0Node3 = await createMockConnectionDhtNode(simulator,
|
|
32
|
-
layer0Node4 = await createMockConnectionDhtNode(simulator,
|
|
25
|
+
layer0EntryPoint = await createMockConnectionDhtNode(simulator, createRandomDhtAddress())
|
|
26
|
+
layer0Node1 = await createMockConnectionDhtNode(simulator, createRandomDhtAddress())
|
|
27
|
+
layer0Node2 = await createMockConnectionDhtNode(simulator, createRandomDhtAddress())
|
|
28
|
+
layer0Node3 = await createMockConnectionDhtNode(simulator, createRandomDhtAddress())
|
|
29
|
+
layer0Node4 = await createMockConnectionDhtNode(simulator, createRandomDhtAddress())
|
|
33
30
|
|
|
34
31
|
layer1EntryPoint = await createMockConnectionLayer1Node(layer0EntryPoint)
|
|
35
32
|
|
|
@@ -68,21 +65,21 @@ describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
|
68
65
|
await layer1Node3.joinDht([layer0EntryPoint.getLocalPeerDescriptor()])
|
|
69
66
|
await layer1Node4.joinDht([layer0EntryPoint.getLocalPeerDescriptor()])
|
|
70
67
|
|
|
71
|
-
logger.info('layer1EntryPoint.
|
|
72
|
-
logger.info('layer1Node1.
|
|
73
|
-
logger.info('layer1Node2.
|
|
74
|
-
logger.info('layer1Node3.
|
|
75
|
-
logger.info('layer1Node4.
|
|
76
|
-
|
|
77
|
-
expect(layer1Node1.
|
|
78
|
-
expect(layer1Node2.
|
|
79
|
-
expect(layer1Node3.
|
|
80
|
-
expect(layer1Node4.
|
|
81
|
-
|
|
82
|
-
expect(layer1Node1.
|
|
83
|
-
expect(layer1Node2.
|
|
84
|
-
expect(layer1Node3.
|
|
85
|
-
expect(layer1Node4.
|
|
68
|
+
logger.info('layer1EntryPoint.getNeighborCount() ' + layer1EntryPoint.getNeighborCount())
|
|
69
|
+
logger.info('layer1Node1.getNeighborCount()' + layer1Node1.getNeighborCount())
|
|
70
|
+
logger.info('layer1Node2.getNeighborCount()' + layer1Node2.getNeighborCount())
|
|
71
|
+
logger.info('layer1Node3.getNeighborCount()' + layer1Node3.getNeighborCount())
|
|
72
|
+
logger.info('layer1Node4.getNeighborCount()' + layer1Node4.getNeighborCount())
|
|
73
|
+
|
|
74
|
+
expect(layer1Node1.getNeighborCount()).toEqual(layer0Node1.getNeighborCount())
|
|
75
|
+
expect(layer1Node2.getNeighborCount()).toEqual(layer0Node2.getNeighborCount())
|
|
76
|
+
expect(layer1Node3.getNeighborCount()).toEqual(layer0Node3.getNeighborCount())
|
|
77
|
+
expect(layer1Node4.getNeighborCount()).toEqual(layer0Node4.getNeighborCount())
|
|
78
|
+
|
|
79
|
+
expect(layer1Node1.getNeighbors()).toContainValues(layer0Node1.getNeighbors())
|
|
80
|
+
expect(layer1Node2.getNeighbors()).toContainValues(layer0Node2.getNeighbors())
|
|
81
|
+
expect(layer1Node3.getNeighbors()).toContainValues(layer0Node3.getNeighbors())
|
|
82
|
+
expect(layer1Node4.getNeighbors()).toContainValues(layer0Node4.getNeighbors())
|
|
86
83
|
|
|
87
84
|
}, 60000)
|
|
88
85
|
})
|
|
@@ -42,9 +42,9 @@ describe('multiple entry point joining', () => {
|
|
|
42
42
|
node2.joinDht(entryPoints),
|
|
43
43
|
node3.joinDht(entryPoints)
|
|
44
44
|
])
|
|
45
|
-
expect(node1.
|
|
46
|
-
expect(node2.
|
|
47
|
-
expect(node3.
|
|
45
|
+
expect(node1.getNeighborCount()).toEqual(2)
|
|
46
|
+
expect(node2.getNeighborCount()).toEqual(2)
|
|
47
|
+
expect(node3.getNeighborCount()).toEqual(2)
|
|
48
48
|
})
|
|
49
49
|
|
|
50
50
|
it('can join even if a node is offline', async () => {
|
|
@@ -53,8 +53,8 @@ describe('multiple entry point joining', () => {
|
|
|
53
53
|
node1.joinDht(entryPoints),
|
|
54
54
|
node2.joinDht(entryPoints)
|
|
55
55
|
])
|
|
56
|
-
expect(node1.
|
|
57
|
-
expect(node2.
|
|
56
|
+
expect(node1.getNeighborCount()).toEqual(1)
|
|
57
|
+
expect(node2.getNeighborCount()).toEqual(1)
|
|
58
58
|
}, 10000)
|
|
59
59
|
})
|
|
60
60
|
|
|
@@ -96,9 +96,9 @@ describe('multiple entry point joining', () => {
|
|
|
96
96
|
|
|
97
97
|
it('non-entry point nodes can join', async () => {
|
|
98
98
|
await node1.joinDht(entryPoints)
|
|
99
|
-
expect(node1.
|
|
99
|
+
expect(node1.getNeighborCount()).toEqual(2)
|
|
100
100
|
await node2.joinDht(entryPoints)
|
|
101
|
-
expect(node2.
|
|
101
|
+
expect(node2.getNeighborCount()).toEqual(3)
|
|
102
102
|
})
|
|
103
103
|
|
|
104
104
|
})
|