@streamr/dht 100.0.0-testnet-three.2 → 100.0.0-testnet-three.4
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/README.md +90 -8
- package/dist/package.json +5 -5
- package/dist/src/connection/ConnectionManager.js +10 -2
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.d.ts +1 -0
- package/dist/src/connection/connectivityRequestHandler.js +39 -22
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnector.js +32 -37
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +2 -2
- package/dist/src/dht/DhtNode.js +16 -11
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.js +2 -2
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +7 -9
- package/dist/src/dht/PeerManager.js +7 -14
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/ContactList.d.ts +1 -1
- package/dist/src/dht/contact/RandomContactList.js +1 -1
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.js +14 -15
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +1 -1
- package/dist/src/dht/discovery/DiscoverySession.js +5 -5
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.js +2 -2
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +0 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.js +2 -3
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.js +2 -1
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.js +2 -5
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +1 -1
- package/dist/src/dht/store/StoreManager.js +10 -17
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/package.json +5 -5
- package/src/connection/ConnectionManager.ts +9 -2
- package/src/connection/connectivityRequestHandler.ts +39 -22
- package/src/connection/websocket/WebsocketConnector.ts +33 -37
- package/src/dht/DhtNode.ts +20 -15
- package/src/dht/DhtNodeRpcLocal.ts +3 -3
- package/src/dht/PeerManager.ts +12 -21
- package/src/dht/contact/ContactList.ts +1 -1
- package/src/dht/contact/RandomContactList.ts +1 -1
- package/src/dht/contact/SortedContactList.ts +14 -18
- package/src/dht/discovery/DiscoverySession.ts +5 -5
- package/src/dht/discovery/PeerDiscovery.ts +2 -2
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +0 -1
- package/src/dht/routing/RouterRpcLocal.ts +2 -3
- package/src/dht/routing/RoutingSession.ts +2 -1
- package/src/dht/store/LocalDataStore.ts +2 -5
- package/src/dht/store/StoreManager.ts +10 -17
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +8 -4
- package/test/end-to-end/Layer0Webrtc.test.ts +0 -2
- package/test/end-to-end/memory-leak.test.ts +3 -3
- package/test/unit/PeerManager.test.ts +1 -1
- package/test/unit/SortedContactList.test.ts +5 -5
- package/test/unit/StoreManager.test.ts +26 -23
- package/test/unit/connectivityRequestHandler.test.ts +39 -6
|
@@ -15,8 +15,9 @@ describe('connectivityRequestHandler', () => {
|
|
|
15
15
|
|
|
16
16
|
let httpServer: HttpServer
|
|
17
17
|
let wsServer: WsServer
|
|
18
|
+
let connection: any
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
beforeEach(async () => {
|
|
20
21
|
httpServer = createHttpServer()
|
|
21
22
|
wsServer = new WsServer({
|
|
22
23
|
httpServer,
|
|
@@ -24,19 +25,18 @@ describe('connectivityRequestHandler', () => {
|
|
|
24
25
|
})
|
|
25
26
|
httpServer.listen(PORT)
|
|
26
27
|
await once(httpServer, 'listening')
|
|
28
|
+
connection = new EventEmitter()
|
|
29
|
+
connection.send = jest.fn()
|
|
30
|
+
connection.getRemoteIp = () => HOST
|
|
27
31
|
})
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
afterEach(async () => {
|
|
30
34
|
wsServer.shutDown()
|
|
31
35
|
httpServer.close()
|
|
32
36
|
await once(httpServer, 'close')
|
|
33
37
|
})
|
|
34
38
|
|
|
35
39
|
it('happy path', async () => {
|
|
36
|
-
const connection: any = new EventEmitter()
|
|
37
|
-
connection.send = jest.fn()
|
|
38
|
-
connection.getRemoteIp = () => HOST
|
|
39
|
-
|
|
40
40
|
attachConnectivityRequestHandler(connection)
|
|
41
41
|
const request: Message = {
|
|
42
42
|
serviceId: CONNECTIVITY_CHECKER_SERVICE_ID,
|
|
@@ -72,4 +72,37 @@ describe('connectivityRequestHandler', () => {
|
|
|
72
72
|
serviceId: 'system/connectivity-checker'
|
|
73
73
|
})
|
|
74
74
|
})
|
|
75
|
+
|
|
76
|
+
it('disabled connectivity probing', async () => {
|
|
77
|
+
attachConnectivityRequestHandler(connection)
|
|
78
|
+
const request: Message = {
|
|
79
|
+
serviceId: CONNECTIVITY_CHECKER_SERVICE_ID,
|
|
80
|
+
messageType: MessageType.CONNECTIVITY_REQUEST,
|
|
81
|
+
messageId: 'mock-message-id',
|
|
82
|
+
body: {
|
|
83
|
+
oneofKind: 'connectivityRequest',
|
|
84
|
+
connectivityRequest: { port: 0, host: HOST, tls: false, selfSigned: false }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
connection.emit('data', Message.toBinary(request))
|
|
88
|
+
|
|
89
|
+
await waitForCondition(() => connection.send.mock.calls.length > 0)
|
|
90
|
+
|
|
91
|
+
const receivedMessage = Message.fromBinary(connection.send.mock.calls[0][0])
|
|
92
|
+
expect(receivedMessage).toEqual({
|
|
93
|
+
body: {
|
|
94
|
+
connectivityResponse: {
|
|
95
|
+
host: HOST,
|
|
96
|
+
natType: 'unknown',
|
|
97
|
+
ipAddress: ipv4ToNumber(HOST),
|
|
98
|
+
version
|
|
99
|
+
},
|
|
100
|
+
oneofKind: 'connectivityResponse'
|
|
101
|
+
},
|
|
102
|
+
messageId: expect.any(String),
|
|
103
|
+
messageType: MessageType.CONNECTIVITY_RESPONSE,
|
|
104
|
+
serviceId: 'system/connectivity-checker'
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
|
|
75
108
|
})
|