@streamr/trackerless-network 100.0.0-testnet-three.4 → 100.0.0-testnet-three.6
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/NetworkNode.d.ts +3 -3
- package/dist/src/NetworkNode.js.map +1 -1
- package/dist/src/NetworkStack.d.ts +3 -1
- package/dist/src/NetworkStack.js +18 -1
- package/dist/src/NetworkStack.js.map +1 -1
- package/dist/src/exports.d.ts +2 -2
- package/dist/src/exports.js +1 -2
- package/dist/src/exports.js.map +1 -1
- package/dist/src/logic/node-info/NodeInfoClient.d.ts +2 -2
- package/dist/src/logic/node-info/NodeInfoClient.js +3 -1
- package/dist/src/logic/node-info/NodeInfoClient.js.map +1 -1
- package/dist/src/logic/node-info/NodeInfoRpcLocal.js +1 -10
- package/dist/src/logic/node-info/NodeInfoRpcLocal.js.map +1 -1
- package/package.json +8 -8
- package/src/NetworkNode.ts +4 -4
- package/src/NetworkStack.ts +29 -3
- package/src/exports.ts +2 -2
- package/src/logic/node-info/NodeInfoClient.ts +6 -4
- package/src/logic/node-info/NodeInfoRpcLocal.ts +1 -10
- package/test/end-to-end/inspect.test.ts +3 -3
- package/test/end-to-end/proxy-and-full-node.test.ts +12 -12
- package/test/end-to-end/proxy-connections.test.ts +7 -7
- package/test/end-to-end/proxy-key-exchange.test.ts +3 -3
- package/test/end-to-end/webrtc-full-node-network.test.ts +6 -6
- package/test/end-to-end/websocket-full-node-network.test.ts +6 -6
- package/test/integration/NetworkNode.test.ts +8 -4
- package/test/integration/NetworkStack.test.ts +2 -2
- package/test/unit/GroupKeyResponseTranslator.test.ts +1 -1
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/trackerless-network",
|
|
3
|
-
"version": "100.0.0-testnet-three.
|
|
3
|
+
"version": "100.0.0-testnet-three.6",
|
|
4
4
|
"description": "Minimal and extendable implementation of the Streamr Network node.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@protobuf-ts/runtime": "^2.8.2",
|
|
32
32
|
"@protobuf-ts/runtime-rpc": "^2.8.2",
|
|
33
|
-
"@streamr/dht": "100.0.0-testnet-three.
|
|
34
|
-
"@streamr/proto-rpc": "100.0.0-testnet-three.
|
|
35
|
-
"@streamr/protocol": "100.0.0-testnet-three.
|
|
36
|
-
"@streamr/test-utils": "100.0.0-testnet-three.
|
|
37
|
-
"@streamr/utils": "100.0.0-testnet-three.
|
|
33
|
+
"@streamr/dht": "100.0.0-testnet-three.6",
|
|
34
|
+
"@streamr/proto-rpc": "100.0.0-testnet-three.6",
|
|
35
|
+
"@streamr/protocol": "100.0.0-testnet-three.6",
|
|
36
|
+
"@streamr/test-utils": "100.0.0-testnet-three.6",
|
|
37
|
+
"@streamr/utils": "100.0.0-testnet-three.6",
|
|
38
38
|
"eventemitter3": "^5.0.0",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
40
40
|
"uuid": "^9.0.1",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@streamr/browser-test-runner": "^0.0.1",
|
|
45
45
|
"@types/lodash": "^4.14.202",
|
|
46
|
-
"@types/uuid": "^9.0.
|
|
46
|
+
"@types/uuid": "^9.0.8",
|
|
47
47
|
"@types/yallist": "^4.0.1",
|
|
48
|
-
"commander": "^
|
|
48
|
+
"commander": "^12.0.0",
|
|
49
49
|
"expect": "^29.6.2",
|
|
50
50
|
"express": "^4.17.1",
|
|
51
51
|
"ts-essentials": "^9.4.1",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StreamMessage, StreamPartID } from '@streamr/protocol';
|
|
2
2
|
import { DhtAddress, PeerDescriptor } from '@streamr/dht';
|
|
3
|
-
import { NetworkOptions, NetworkStack } from './NetworkStack';
|
|
3
|
+
import { NetworkOptions, NetworkStack, NodeInfo } from './NetworkStack';
|
|
4
4
|
import { EthereumAddress, MetricsContext } from '@streamr/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { ProxyDirection } from './proto/packages/trackerless-network/protos/NetworkRpc';
|
|
6
6
|
export declare const createNetworkNode: (opts: NetworkOptions) => NetworkNode;
|
|
7
7
|
/**
|
|
8
8
|
* Convenience wrapper for building client-facing functionality. Used by client.
|
|
@@ -32,6 +32,6 @@ export declare class NetworkNode {
|
|
|
32
32
|
getNodeId(): DhtAddress;
|
|
33
33
|
getOptions(): NetworkOptions;
|
|
34
34
|
getStreamParts(): StreamPartID[];
|
|
35
|
-
fetchNodeInfo(node: PeerDescriptor): Promise<
|
|
35
|
+
fetchNodeInfo(node: PeerDescriptor): Promise<NodeInfo>;
|
|
36
36
|
getDiagnosticInfo(): Record<string, unknown>;
|
|
37
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkNode.js","sourceRoot":"","sources":["../../src/NetworkNode.ts"],"names":[],"mappings":";;;AAEA,iHAA6G;AAC7G,
|
|
1
|
+
{"version":3,"file":"NetworkNode.js","sourceRoot":"","sources":["../../src/NetworkNode.ts"],"names":[],"mappings":";;;AAEA,iHAA6G;AAC7G,iDAAuE;AACvE,0CAAwE;AAExE,mCAA6B;AAEtB,MAAM,iBAAiB,GAAG,CAAC,IAAoB,EAAe,EAAE;IACnE,OAAO,IAAI,WAAW,CAAC,IAAI,2BAAY,CAAC,IAAI,CAAC,CAAC,CAAA;AAClD,CAAC,CAAA;AAFY,QAAA,iBAAiB,qBAE7B;AAED,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AACjC;;GAEG;AACH,MAAa,WAAW;IAEX,KAAK,CAAc;IACX,gBAAgB,GAAqC,EAAE,CAAA;IAChE,OAAO,GAAG,KAAK,CAAA;IAEvB,gBAAgB;IAChB,YAAY,KAAmB;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,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C,KAAK,CAAC,aAAa,EAAE,CAAC,sBAAsB,EAAE,CAAA;IAC9D,CAAC;IAED,iBAAiB;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAA;IACzC,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,SAAS,EAAE,CAAA;IAClD,CAAC;IAED,UAAU;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAA;IAClC,CAAC;IAED,cAAc;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,cAAc,EAAE,CAAA;IACvD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAoB;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC;IAED,kDAAkD;IAClD,iBAAiB;QACb,OAAO,EAAE,CAAA;IACb,CAAC;CACJ;AAlHD,kCAkHC"}
|
|
@@ -9,6 +9,7 @@ export interface NetworkOptions {
|
|
|
9
9
|
networkNode?: StreamrNodeConfig;
|
|
10
10
|
metricsContext?: MetricsContext;
|
|
11
11
|
}
|
|
12
|
+
export type NodeInfo = Required<NodeInfoResponse>;
|
|
12
13
|
export declare class NetworkStack {
|
|
13
14
|
private layer0Node?;
|
|
14
15
|
private streamrNode?;
|
|
@@ -28,7 +29,8 @@ export declare class NetworkStack {
|
|
|
28
29
|
getStreamrNode(): StreamrNode;
|
|
29
30
|
getLayer0Node(): Layer0Node;
|
|
30
31
|
getMetricsContext(): MetricsContext;
|
|
31
|
-
fetchNodeInfo(node: PeerDescriptor): Promise<
|
|
32
|
+
fetchNodeInfo(node: PeerDescriptor): Promise<NodeInfo>;
|
|
33
|
+
createNodeInfo(): NodeInfo;
|
|
32
34
|
getOptions(): NetworkOptions;
|
|
33
35
|
private getConnectionManager;
|
|
34
36
|
stop(): Promise<void>;
|
package/dist/src/NetworkStack.js
CHANGED
|
@@ -9,6 +9,7 @@ const NetworkRpc_1 = require("./proto/packages/trackerless-network/protos/Networ
|
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
10
10
|
const NodeInfoRpcLocal_1 = require("./logic/node-info/NodeInfoRpcLocal");
|
|
11
11
|
const NodeInfoClient_1 = require("./logic/node-info/NodeInfoClient");
|
|
12
|
+
const package_json_1 = require("../package.json");
|
|
12
13
|
const logger = new utils_1.Logger(module);
|
|
13
14
|
const instances = [];
|
|
14
15
|
const stopInstances = async () => {
|
|
@@ -121,7 +122,23 @@ class NetworkStack {
|
|
|
121
122
|
return this.metricsContext;
|
|
122
123
|
}
|
|
123
124
|
async fetchNodeInfo(node) {
|
|
124
|
-
|
|
125
|
+
if (!(0, dht_1.areEqualPeerDescriptors)(node, this.getLayer0Node().getLocalPeerDescriptor())) {
|
|
126
|
+
return this.nodeInfoClient.getInfo(node);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return this.createNodeInfo();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
createNodeInfo() {
|
|
133
|
+
return {
|
|
134
|
+
peerDescriptor: this.getLayer0Node().getLocalPeerDescriptor(),
|
|
135
|
+
controlLayer: {
|
|
136
|
+
connections: this.getLayer0Node().getConnections(),
|
|
137
|
+
neighbors: this.getLayer0Node().getNeighbors()
|
|
138
|
+
},
|
|
139
|
+
streamPartitions: this.getStreamrNode().getNodeInfo(),
|
|
140
|
+
version: package_json_1.version
|
|
141
|
+
};
|
|
125
142
|
}
|
|
126
143
|
getOptions() {
|
|
127
144
|
return this.options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkStack.js","sourceRoot":"","sources":["../../src/NetworkStack.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"NetworkStack.js","sourceRoot":"","sources":["../../src/NetworkStack.ts"],"names":[],"mappings":";;;AAAA,sCAOqB;AACrB,qDAAoE;AACpE,0CAAyE;AACzE,gDAA0E;AAC1E,uFAA2I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CA4IC"}
|
package/dist/src/exports.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { NetworkStack, NetworkOptions } from './NetworkStack';
|
|
1
|
+
export { NetworkStack, NetworkOptions, NodeInfo } from './NetworkStack';
|
|
2
2
|
export { NetworkNode, createNetworkNode } from './NetworkNode';
|
|
3
3
|
export { StreamrNodeConfig } from './logic/StreamrNode';
|
|
4
|
-
export { ProxyDirection
|
|
4
|
+
export { ProxyDirection } from './proto/packages/trackerless-network/protos/NetworkRpc';
|
|
5
5
|
export { streamPartIdToDataKey } from './logic/EntryPointDiscovery';
|
|
6
6
|
export { convertStreamMessageToBytes, convertBytesToStreamMessage } from './logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils';
|
package/dist/src/exports.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertBytesToStreamMessage = exports.convertStreamMessageToBytes = exports.streamPartIdToDataKey = exports.
|
|
3
|
+
exports.convertBytesToStreamMessage = exports.convertStreamMessageToBytes = exports.streamPartIdToDataKey = exports.ProxyDirection = exports.createNetworkNode = exports.NetworkNode = exports.NetworkStack = void 0;
|
|
4
4
|
var NetworkStack_1 = require("./NetworkStack");
|
|
5
5
|
Object.defineProperty(exports, "NetworkStack", { enumerable: true, get: function () { return NetworkStack_1.NetworkStack; } });
|
|
6
6
|
var NetworkNode_1 = require("./NetworkNode");
|
|
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "NetworkNode", { enumerable: true, get: function
|
|
|
8
8
|
Object.defineProperty(exports, "createNetworkNode", { enumerable: true, get: function () { return NetworkNode_1.createNetworkNode; } });
|
|
9
9
|
var NetworkRpc_1 = require("./proto/packages/trackerless-network/protos/NetworkRpc");
|
|
10
10
|
Object.defineProperty(exports, "ProxyDirection", { enumerable: true, get: function () { return NetworkRpc_1.ProxyDirection; } });
|
|
11
|
-
Object.defineProperty(exports, "NodeInfoResponse", { enumerable: true, get: function () { return NetworkRpc_1.NodeInfoResponse; } });
|
|
12
11
|
var EntryPointDiscovery_1 = require("./logic/EntryPointDiscovery");
|
|
13
12
|
Object.defineProperty(exports, "streamPartIdToDataKey", { enumerable: true, get: function () { return EntryPointDiscovery_1.streamPartIdToDataKey; } });
|
|
14
13
|
var oldStreamMessageBinaryUtils_1 = require("./logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils");
|
package/dist/src/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":";;;AAAA,+CAAuE;AAA9D,4GAAA,YAAY,OAAA;AACrB,6CAA8D;AAArD,0GAAA,WAAW,OAAA;AAAE,gHAAA,iBAAiB,OAAA;AAEvC,qFAAuF;AAA9E,4GAAA,cAAc,OAAA;AACvB,mEAAmE;AAA1D,4HAAA,qBAAqB,OAAA;AAC9B,uHAGgF;AAF5E,0IAAA,2BAA2B,OAAA;AAC3B,0IAAA,2BAA2B,OAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DhtCallContext, PeerDescriptor } from '@streamr/dht';
|
|
2
|
-
import { NodeInfoResponse } from '../../proto/packages/trackerless-network/protos/NetworkRpc';
|
|
3
2
|
import { RpcCommunicator } from '@streamr/proto-rpc';
|
|
3
|
+
import { NodeInfo } from '../../NetworkStack';
|
|
4
4
|
export declare class NodeInfoClient {
|
|
5
5
|
private readonly ownPeerDescriptor;
|
|
6
6
|
private readonly rpcCommunicator;
|
|
7
7
|
constructor(ownPeerDescriptor: PeerDescriptor, rpcCommunicator: RpcCommunicator<DhtCallContext>);
|
|
8
|
-
getInfo(node: PeerDescriptor): Promise<
|
|
8
|
+
getInfo(node: PeerDescriptor): Promise<NodeInfo>;
|
|
9
9
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NodeInfoClient = void 0;
|
|
4
|
-
const NodeInfoRpcRemote_1 = require("./NodeInfoRpcRemote");
|
|
5
4
|
const NetworkRpc_client_1 = require("../../proto/packages/trackerless-network/protos/NetworkRpc.client");
|
|
5
|
+
const NodeInfoRpcRemote_1 = require("./NodeInfoRpcRemote");
|
|
6
6
|
class NodeInfoClient {
|
|
7
7
|
ownPeerDescriptor;
|
|
8
8
|
rpcCommunicator;
|
|
@@ -12,6 +12,8 @@ class NodeInfoClient {
|
|
|
12
12
|
}
|
|
13
13
|
async getInfo(node) {
|
|
14
14
|
const remote = new NodeInfoRpcRemote_1.NodeInfoRpcRemote(this.ownPeerDescriptor, node, this.rpcCommunicator, NetworkRpc_client_1.NodeInfoRpcClient);
|
|
15
|
+
// TODO remove casting when we validate NodeInfoResponse messages and therefore can annotate
|
|
16
|
+
// each of the field as required in the decorated type
|
|
15
17
|
return remote.getInfo();
|
|
16
18
|
}
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeInfoClient.js","sourceRoot":"","sources":["../../../../src/logic/node-info/NodeInfoClient.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"NodeInfoClient.js","sourceRoot":"","sources":["../../../../src/logic/node-info/NodeInfoClient.ts"],"names":[],"mappings":";;;AAGA,yGAAqG;AACrG,2DAAuD;AAEvD,MAAa,cAAc;IACN,iBAAiB,CAAgB;IACjC,eAAe,CAAiC;IAEjE,YAAY,iBAAiC,EAAE,eAAgD;QAC3F,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;QAC1C,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IAC1C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAoB;QAC9B,MAAM,MAAM,GAAG,IAAI,qCAAiB,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,qCAAiB,CAAC,CAAA;QAC3G,4FAA4F;QAC5F,sDAAsD;QACtD,OAAO,MAAM,CAAC,OAAO,EAAyB,CAAA;IAClD,CAAC;CAEJ;AAhBD,wCAgBC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NodeInfoRpcLocal = exports.NODE_INFO_RPC_SERVICE_ID = void 0;
|
|
4
4
|
const NetworkRpc_1 = require("../../proto/packages/trackerless-network/protos/NetworkRpc");
|
|
5
|
-
const package_json_1 = require("../../../package.json");
|
|
6
5
|
exports.NODE_INFO_RPC_SERVICE_ID = 'system/node-info-rpc';
|
|
7
6
|
class NodeInfoRpcLocal {
|
|
8
7
|
stack;
|
|
@@ -16,15 +15,7 @@ class NodeInfoRpcLocal {
|
|
|
16
15
|
this.rpcCommunicator.registerRpcMethod(NetworkRpc_1.NodeInfoRequest, NetworkRpc_1.NodeInfoResponse, 'getInfo', () => this.getInfo());
|
|
17
16
|
}
|
|
18
17
|
async getInfo() {
|
|
19
|
-
return
|
|
20
|
-
peerDescriptor: this.stack.getLayer0Node().getLocalPeerDescriptor(),
|
|
21
|
-
controlLayer: {
|
|
22
|
-
connections: this.stack.getLayer0Node().getConnections(),
|
|
23
|
-
neighbors: this.stack.getLayer0Node().getNeighbors()
|
|
24
|
-
},
|
|
25
|
-
streamPartitions: this.stack.getStreamrNode().getNodeInfo(),
|
|
26
|
-
version: package_json_1.version
|
|
27
|
-
};
|
|
18
|
+
return this.stack.createNodeInfo();
|
|
28
19
|
}
|
|
29
20
|
}
|
|
30
21
|
exports.NodeInfoRpcLocal = NodeInfoRpcLocal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeInfoRpcLocal.js","sourceRoot":"","sources":["../../../../src/logic/node-info/NodeInfoRpcLocal.ts"],"names":[],"mappings":";;;AAAA,2FAA8G;
|
|
1
|
+
{"version":3,"file":"NodeInfoRpcLocal.js","sourceRoot":"","sources":["../../../../src/logic/node-info/NodeInfoRpcLocal.ts"],"names":[],"mappings":";;;AAAA,2FAA8G;AAKjG,QAAA,wBAAwB,GAAG,sBAAsB,CAAA;AAE9D,MAAa,gBAAgB;IAER,KAAK,CAAc;IACnB,eAAe,CAA0B;IAE1D,YAAY,KAAmB,EAAE,eAAyC;QACtE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;QACtC,IAAI,CAAC,4BAA4B,EAAE,CAAA;IACvC,CAAC;IAEO,4BAA4B;QAChC,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,4BAAe,EAAE,6BAAgB,EAAE,SAAS,EAC/E,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAA;IACtC,CAAC;CAEJ;AApBD,4CAoBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/trackerless-network",
|
|
3
|
-
"version": "100.0.0-testnet-three.
|
|
3
|
+
"version": "100.0.0-testnet-three.6",
|
|
4
4
|
"description": "Minimal and extendable implementation of the Streamr Network node.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@protobuf-ts/runtime": "^2.8.2",
|
|
32
32
|
"@protobuf-ts/runtime-rpc": "^2.8.2",
|
|
33
|
-
"@streamr/dht": "100.0.0-testnet-three.
|
|
34
|
-
"@streamr/proto-rpc": "100.0.0-testnet-three.
|
|
35
|
-
"@streamr/protocol": "100.0.0-testnet-three.
|
|
36
|
-
"@streamr/test-utils": "100.0.0-testnet-three.
|
|
37
|
-
"@streamr/utils": "100.0.0-testnet-three.
|
|
33
|
+
"@streamr/dht": "100.0.0-testnet-three.6",
|
|
34
|
+
"@streamr/proto-rpc": "100.0.0-testnet-three.6",
|
|
35
|
+
"@streamr/protocol": "100.0.0-testnet-three.6",
|
|
36
|
+
"@streamr/test-utils": "100.0.0-testnet-three.6",
|
|
37
|
+
"@streamr/utils": "100.0.0-testnet-three.6",
|
|
38
38
|
"eventemitter3": "^5.0.0",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
40
40
|
"uuid": "^9.0.1",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@streamr/browser-test-runner": "^0.0.1",
|
|
45
45
|
"@types/lodash": "^4.14.202",
|
|
46
|
-
"@types/uuid": "^9.0.
|
|
46
|
+
"@types/uuid": "^9.0.8",
|
|
47
47
|
"@types/yallist": "^4.0.1",
|
|
48
|
-
"commander": "^
|
|
48
|
+
"commander": "^12.0.0",
|
|
49
49
|
"expect": "^29.6.2",
|
|
50
50
|
"express": "^4.17.1",
|
|
51
51
|
"ts-essentials": "^9.4.1",
|
package/src/NetworkNode.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { StreamMessage, StreamPartID } from '@streamr/protocol'
|
|
2
2
|
import { DhtAddress, PeerDescriptor } from '@streamr/dht'
|
|
3
3
|
import { StreamMessageTranslator } from './logic/protocol-integration/stream-message/StreamMessageTranslator'
|
|
4
|
-
import { NetworkOptions, NetworkStack } from './NetworkStack'
|
|
4
|
+
import { NetworkOptions, NetworkStack, NodeInfo } from './NetworkStack'
|
|
5
5
|
import { EthereumAddress, Logger, MetricsContext } from '@streamr/utils'
|
|
6
|
-
import {
|
|
6
|
+
import { ProxyDirection } from './proto/packages/trackerless-network/protos/NetworkRpc'
|
|
7
7
|
import { pull } from 'lodash'
|
|
8
8
|
|
|
9
9
|
export const createNetworkNode = (opts: NetworkOptions): NetworkNode => {
|
|
@@ -73,7 +73,7 @@ export class NetworkNode {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
setStreamPartEntryPoints(streamPartId: StreamPartID, contactPeerDescriptors: PeerDescriptor[]): void {
|
|
76
|
-
this.stack.getStreamrNode()
|
|
76
|
+
this.stack.getStreamrNode().setStreamPartEntryPoints(streamPartId, contactPeerDescriptors)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
removeMessageListener(cb: (msg: StreamMessage) => void): void {
|
|
@@ -120,7 +120,7 @@ export class NetworkNode {
|
|
|
120
120
|
return this.stack.getStreamrNode().getStreamParts()
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
async fetchNodeInfo(node: PeerDescriptor): Promise<
|
|
123
|
+
async fetchNodeInfo(node: PeerDescriptor): Promise<NodeInfo> {
|
|
124
124
|
return this.stack.fetchNodeInfo(node)
|
|
125
125
|
}
|
|
126
126
|
|
package/src/NetworkStack.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ConnectionManager,
|
|
3
|
+
DhtNode,
|
|
4
|
+
DhtNodeOptions,
|
|
5
|
+
ListeningRpcCommunicator,
|
|
6
|
+
PeerDescriptor,
|
|
7
|
+
areEqualPeerDescriptors
|
|
8
|
+
} from '@streamr/dht'
|
|
2
9
|
import { StreamrNode, StreamrNodeConfig } from './logic/StreamrNode'
|
|
3
10
|
import { Logger, MetricsContext, waitForCondition } from '@streamr/utils'
|
|
4
11
|
import { StreamID, StreamPartID, toStreamPartID } from '@streamr/protocol'
|
|
@@ -7,6 +14,7 @@ import { Layer0Node } from './logic/Layer0Node'
|
|
|
7
14
|
import { pull } from 'lodash'
|
|
8
15
|
import { NODE_INFO_RPC_SERVICE_ID, NodeInfoRpcLocal } from './logic/node-info/NodeInfoRpcLocal'
|
|
9
16
|
import { NodeInfoClient } from './logic/node-info/NodeInfoClient'
|
|
17
|
+
import { version as localVersion } from '../package.json'
|
|
10
18
|
|
|
11
19
|
export interface NetworkOptions {
|
|
12
20
|
layer0?: DhtNodeOptions
|
|
@@ -41,6 +49,8 @@ if (typeof window === 'object') {
|
|
|
41
49
|
})
|
|
42
50
|
}
|
|
43
51
|
|
|
52
|
+
export type NodeInfo = Required<NodeInfoResponse>
|
|
53
|
+
|
|
44
54
|
export class NetworkStack {
|
|
45
55
|
|
|
46
56
|
private layer0Node?: Layer0Node
|
|
@@ -142,8 +152,24 @@ export class NetworkStack {
|
|
|
142
152
|
return this.metricsContext
|
|
143
153
|
}
|
|
144
154
|
|
|
145
|
-
async fetchNodeInfo(node: PeerDescriptor): Promise<
|
|
146
|
-
|
|
155
|
+
async fetchNodeInfo(node: PeerDescriptor): Promise<NodeInfo> {
|
|
156
|
+
if (!areEqualPeerDescriptors(node, this.getLayer0Node().getLocalPeerDescriptor())) {
|
|
157
|
+
return this.nodeInfoClient!.getInfo(node)
|
|
158
|
+
} else {
|
|
159
|
+
return this.createNodeInfo()
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
createNodeInfo(): NodeInfo {
|
|
164
|
+
return {
|
|
165
|
+
peerDescriptor: this.getLayer0Node().getLocalPeerDescriptor(),
|
|
166
|
+
controlLayer: {
|
|
167
|
+
connections: this.getLayer0Node().getConnections(),
|
|
168
|
+
neighbors: this.getLayer0Node().getNeighbors()
|
|
169
|
+
},
|
|
170
|
+
streamPartitions: this.getStreamrNode().getNodeInfo(),
|
|
171
|
+
version: localVersion
|
|
172
|
+
}
|
|
147
173
|
}
|
|
148
174
|
|
|
149
175
|
getOptions(): NetworkOptions {
|
package/src/exports.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { NetworkStack, NetworkOptions } from './NetworkStack'
|
|
1
|
+
export { NetworkStack, NetworkOptions, NodeInfo } from './NetworkStack'
|
|
2
2
|
export { NetworkNode, createNetworkNode } from './NetworkNode'
|
|
3
3
|
export { StreamrNodeConfig } from './logic/StreamrNode'
|
|
4
|
-
export { ProxyDirection
|
|
4
|
+
export { ProxyDirection } from './proto/packages/trackerless-network/protos/NetworkRpc'
|
|
5
5
|
export { streamPartIdToDataKey } from './logic/EntryPointDiscovery'
|
|
6
6
|
export {
|
|
7
7
|
convertStreamMessageToBytes,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DhtCallContext, PeerDescriptor } from '@streamr/dht'
|
|
2
|
-
import { NodeInfoResponse } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
3
|
-
import { NodeInfoRpcRemote } from './NodeInfoRpcRemote'
|
|
4
2
|
import { RpcCommunicator } from '@streamr/proto-rpc'
|
|
3
|
+
import { NodeInfo } from '../../NetworkStack'
|
|
5
4
|
import { NodeInfoRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
5
|
+
import { NodeInfoRpcRemote } from './NodeInfoRpcRemote'
|
|
6
6
|
|
|
7
7
|
export class NodeInfoClient {
|
|
8
8
|
private readonly ownPeerDescriptor: PeerDescriptor
|
|
@@ -13,9 +13,11 @@ export class NodeInfoClient {
|
|
|
13
13
|
this.rpcCommunicator = rpcCommunicator
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async getInfo(node: PeerDescriptor): Promise<
|
|
16
|
+
async getInfo(node: PeerDescriptor): Promise<NodeInfo> {
|
|
17
17
|
const remote = new NodeInfoRpcRemote(this.ownPeerDescriptor, node, this.rpcCommunicator, NodeInfoRpcClient)
|
|
18
|
-
|
|
18
|
+
// TODO remove casting when we validate NodeInfoResponse messages and therefore can annotate
|
|
19
|
+
// each of the field as required in the decorated type
|
|
20
|
+
return remote.getInfo() as unknown as NodeInfo
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
}
|
|
@@ -2,7 +2,6 @@ import { NodeInfoRequest, NodeInfoResponse } from '../../proto/packages/trackerl
|
|
|
2
2
|
import { INodeInfoRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
|
|
3
3
|
import { NetworkStack } from '../../NetworkStack'
|
|
4
4
|
import { ListeningRpcCommunicator } from '@streamr/dht'
|
|
5
|
-
import { version as localVersion } from '../../../package.json'
|
|
6
5
|
|
|
7
6
|
export const NODE_INFO_RPC_SERVICE_ID = 'system/node-info-rpc'
|
|
8
7
|
|
|
@@ -23,15 +22,7 @@ export class NodeInfoRpcLocal implements INodeInfoRpc {
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
async getInfo(): Promise<NodeInfoResponse> {
|
|
26
|
-
return
|
|
27
|
-
peerDescriptor: this.stack.getLayer0Node().getLocalPeerDescriptor(),
|
|
28
|
-
controlLayer: {
|
|
29
|
-
connections: this.stack.getLayer0Node().getConnections(),
|
|
30
|
-
neighbors: this.stack.getLayer0Node().getNeighbors()
|
|
31
|
-
},
|
|
32
|
-
streamPartitions: this.stack.getStreamrNode().getNodeInfo(),
|
|
33
|
-
version: localVersion
|
|
34
|
-
}
|
|
25
|
+
return this.stack.createNodeInfo()
|
|
35
26
|
}
|
|
36
27
|
|
|
37
28
|
}
|
|
@@ -96,9 +96,9 @@ describe('inspect', () => {
|
|
|
96
96
|
await inspectedNode.start()
|
|
97
97
|
await inspectorNode.start()
|
|
98
98
|
|
|
99
|
-
publisherNode.stack.getStreamrNode()
|
|
100
|
-
inspectedNode.stack.getStreamrNode()
|
|
101
|
-
inspectorNode.stack.getStreamrNode()
|
|
99
|
+
publisherNode.stack.getStreamrNode().joinStreamPart(STREAM_PART_ID)
|
|
100
|
+
inspectedNode.stack.getStreamrNode().joinStreamPart(STREAM_PART_ID)
|
|
101
|
+
inspectorNode.stack.getStreamrNode().joinStreamPart(STREAM_PART_ID)
|
|
102
102
|
|
|
103
103
|
await waitForCondition(() =>
|
|
104
104
|
publisherNode.stack.getStreamrNode().getNeighbors(STREAM_PART_ID).length === 2
|
|
@@ -65,11 +65,11 @@ describe('proxy and full node', () => {
|
|
|
65
65
|
}
|
|
66
66
|
})
|
|
67
67
|
await proxyNode.start()
|
|
68
|
-
proxyNode.stack.getStreamrNode()
|
|
69
|
-
proxyNode.stack.getStreamrNode()
|
|
70
|
-
proxyNode.stack.getStreamrNode()
|
|
71
|
-
proxyNode.stack.getStreamrNode()
|
|
72
|
-
proxyNode.stack.getStreamrNode()
|
|
68
|
+
proxyNode.stack.getStreamrNode().joinStreamPart(proxiedStreamPart)
|
|
69
|
+
proxyNode.stack.getStreamrNode().joinStreamPart(regularStreamPart1)
|
|
70
|
+
proxyNode.stack.getStreamrNode().joinStreamPart(regularStreamPart2)
|
|
71
|
+
proxyNode.stack.getStreamrNode().joinStreamPart(regularStreamPart3)
|
|
72
|
+
proxyNode.stack.getStreamrNode().joinStreamPart(regularStreamPart4)
|
|
73
73
|
|
|
74
74
|
proxiedNode = createNetworkNode({
|
|
75
75
|
layer0: {
|
|
@@ -90,14 +90,14 @@ describe('proxy and full node', () => {
|
|
|
90
90
|
expect(proxiedNode.stack.getLayer0Node().hasJoined()).toBe(false)
|
|
91
91
|
|
|
92
92
|
await Promise.all([
|
|
93
|
-
waitForEvent3(proxyNode.stack.getStreamrNode()
|
|
93
|
+
waitForEvent3(proxyNode.stack.getStreamrNode() as any, 'newMessage'),
|
|
94
94
|
proxiedNode.broadcast(createMessage(regularStreamPart1))
|
|
95
95
|
])
|
|
96
96
|
|
|
97
97
|
expect(proxiedNode.stack.getLayer0Node().hasJoined()).toBe(true)
|
|
98
98
|
|
|
99
99
|
await Promise.all([
|
|
100
|
-
waitForEvent3(proxyNode.stack.getStreamrNode()
|
|
100
|
+
waitForEvent3(proxyNode.stack.getStreamrNode() as any, 'newMessage'),
|
|
101
101
|
proxiedNode.broadcast(createMessage(proxiedStreamPart))
|
|
102
102
|
])
|
|
103
103
|
|
|
@@ -110,13 +110,13 @@ describe('proxy and full node', () => {
|
|
|
110
110
|
expect(proxiedNode.stack.getLayer0Node().hasJoined()).toBe(false)
|
|
111
111
|
|
|
112
112
|
await Promise.all([
|
|
113
|
-
waitForEvent3(proxyNode.stack.getStreamrNode()
|
|
113
|
+
waitForEvent3(proxyNode.stack.getStreamrNode() as any, 'newMessage', 5000,
|
|
114
114
|
(streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart1)),
|
|
115
|
-
waitForEvent3(proxyNode.stack.getStreamrNode()
|
|
115
|
+
waitForEvent3(proxyNode.stack.getStreamrNode() as any, 'newMessage', 5000,
|
|
116
116
|
(streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart2)),
|
|
117
|
-
waitForEvent3(proxyNode.stack.getStreamrNode()
|
|
117
|
+
waitForEvent3(proxyNode.stack.getStreamrNode() as any, 'newMessage', 5000,
|
|
118
118
|
(streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart3)),
|
|
119
|
-
waitForEvent3(proxyNode.stack.getStreamrNode()
|
|
119
|
+
waitForEvent3(proxyNode.stack.getStreamrNode() as any, 'newMessage', 5000,
|
|
120
120
|
(streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart4)),
|
|
121
121
|
proxiedNode.broadcast(createMessage(regularStreamPart1)),
|
|
122
122
|
proxiedNode.broadcast(createMessage(regularStreamPart2)),
|
|
@@ -127,7 +127,7 @@ describe('proxy and full node', () => {
|
|
|
127
127
|
expect(proxiedNode.stack.getLayer0Node().hasJoined()).toBe(true)
|
|
128
128
|
|
|
129
129
|
await Promise.all([
|
|
130
|
-
waitForEvent3(proxyNode.stack.getStreamrNode()
|
|
130
|
+
waitForEvent3(proxyNode.stack.getStreamrNode() as any, 'newMessage'),
|
|
131
131
|
proxiedNode.broadcast(createMessage(proxiedStreamPart))
|
|
132
132
|
])
|
|
133
133
|
|
|
@@ -46,14 +46,14 @@ describe('Proxy connections', () => {
|
|
|
46
46
|
let proxiedNode: NetworkNode
|
|
47
47
|
|
|
48
48
|
const hasConnectionFromProxy = (proxyNode: NetworkNode): boolean => {
|
|
49
|
-
const delivery = proxyNode.stack.getStreamrNode()
|
|
49
|
+
const delivery = proxyNode.stack.getStreamrNode().getStreamPartDelivery(STREAM_PART_ID)
|
|
50
50
|
return (delivery !== undefined)
|
|
51
51
|
? ((delivery as { node: RandomGraphNode }).node).hasProxyConnection(proxiedNode.getNodeId())
|
|
52
52
|
: false
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const hasConnectionToProxy = (proxyNodeId: DhtAddress, direction: ProxyDirection): boolean => {
|
|
56
|
-
const client = (proxiedNode.stack.getStreamrNode()
|
|
56
|
+
const client = (proxiedNode.stack.getStreamrNode().getStreamPartDelivery(STREAM_PART_ID) as { client: ProxyClient }).client
|
|
57
57
|
return client.hasConnection(proxyNodeId, direction)
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -77,7 +77,7 @@ describe('Proxy connections', () => {
|
|
|
77
77
|
})
|
|
78
78
|
await proxyNode1.start()
|
|
79
79
|
proxyNode1.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor1])
|
|
80
|
-
proxyNode1.stack.getStreamrNode()
|
|
80
|
+
proxyNode1.stack.getStreamrNode().joinStreamPart(STREAM_PART_ID)
|
|
81
81
|
proxyNode2 = createNetworkNode({
|
|
82
82
|
layer0: {
|
|
83
83
|
entryPoints: [proxyNodeDescriptor1],
|
|
@@ -90,7 +90,7 @@ describe('Proxy connections', () => {
|
|
|
90
90
|
})
|
|
91
91
|
await proxyNode2.start()
|
|
92
92
|
proxyNode2.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor1])
|
|
93
|
-
proxyNode2.stack.getStreamrNode()
|
|
93
|
+
proxyNode2.stack.getStreamrNode().joinStreamPart(STREAM_PART_ID)
|
|
94
94
|
proxiedNode = createNetworkNode({
|
|
95
95
|
layer0: {
|
|
96
96
|
entryPoints: [proxyNode1.getPeerDescriptor()],
|
|
@@ -109,7 +109,7 @@ describe('Proxy connections', () => {
|
|
|
109
109
|
it('happy path publishing', async () => {
|
|
110
110
|
await proxiedNode.setProxies(STREAM_PART_ID, [proxyNode1.getPeerDescriptor()], ProxyDirection.PUBLISH, PROXIED_NODE_USER_ID, 1)
|
|
111
111
|
await Promise.all([
|
|
112
|
-
waitForEvent3(proxyNode1.stack.getStreamrNode()
|
|
112
|
+
waitForEvent3(proxyNode1.stack.getStreamrNode() as any, 'newMessage'),
|
|
113
113
|
proxiedNode.broadcast(MESSAGE)
|
|
114
114
|
])
|
|
115
115
|
})
|
|
@@ -117,7 +117,7 @@ describe('Proxy connections', () => {
|
|
|
117
117
|
it('happy path subscribing', async () => {
|
|
118
118
|
await proxiedNode.setProxies(STREAM_PART_ID, [proxyNode1.getPeerDescriptor()], ProxyDirection.SUBSCRIBE, PROXIED_NODE_USER_ID, 1)
|
|
119
119
|
await Promise.all([
|
|
120
|
-
waitForEvent3(proxiedNode.stack.getStreamrNode()
|
|
120
|
+
waitForEvent3(proxiedNode.stack.getStreamrNode() as any, 'newMessage'),
|
|
121
121
|
proxyNode1.broadcast(MESSAGE)
|
|
122
122
|
])
|
|
123
123
|
})
|
|
@@ -196,7 +196,7 @@ describe('Proxy connections', () => {
|
|
|
196
196
|
await proxyNode1.leave(STREAM_PART_ID)
|
|
197
197
|
await waitForCondition(() => hasConnectionToProxy(proxyNode1.getNodeId(), ProxyDirection.SUBSCRIBE))
|
|
198
198
|
expect(hasConnectionFromProxy(proxyNode1)).toBe(false)
|
|
199
|
-
proxyNode1.stack.getStreamrNode()
|
|
199
|
+
proxyNode1.stack.getStreamrNode().joinStreamPart(STREAM_PART_ID)
|
|
200
200
|
await waitForCondition(() => hasConnectionToProxy(proxyNode1.getNodeId(), ProxyDirection.SUBSCRIBE), 25000)
|
|
201
201
|
// TODO why wait is needed?
|
|
202
202
|
await wait(100)
|
|
@@ -44,7 +44,7 @@ describe('proxy group key exchange', () => {
|
|
|
44
44
|
})
|
|
45
45
|
await proxyNode.start()
|
|
46
46
|
proxyNode.setStreamPartEntryPoints(STREAM_PART_ID, [proxyNodeDescriptor])
|
|
47
|
-
proxyNode.stack.getStreamrNode()
|
|
47
|
+
proxyNode.stack.getStreamrNode().joinStreamPart(STREAM_PART_ID)
|
|
48
48
|
publisher = createNetworkNode({
|
|
49
49
|
layer0: {
|
|
50
50
|
entryPoints: [proxyNodeDescriptor],
|
|
@@ -98,7 +98,7 @@ describe('proxy group key exchange', () => {
|
|
|
98
98
|
})
|
|
99
99
|
|
|
100
100
|
await Promise.all([
|
|
101
|
-
waitForEvent3(publisher.stack.getStreamrNode()
|
|
101
|
+
waitForEvent3(publisher.stack.getStreamrNode() as any, 'newMessage'),
|
|
102
102
|
subscriber.broadcast(request)
|
|
103
103
|
])
|
|
104
104
|
})
|
|
@@ -130,7 +130,7 @@ describe('proxy group key exchange', () => {
|
|
|
130
130
|
})
|
|
131
131
|
|
|
132
132
|
await Promise.all([
|
|
133
|
-
waitForEvent3(subscriber.stack.getStreamrNode()
|
|
133
|
+
waitForEvent3(subscriber.stack.getStreamrNode() as any, 'newMessage'),
|
|
134
134
|
publisher.broadcast(response)
|
|
135
135
|
])
|
|
136
136
|
})
|
|
@@ -33,8 +33,8 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
33
33
|
}
|
|
34
34
|
})
|
|
35
35
|
await entryPoint.start()
|
|
36
|
-
entryPoint.getStreamrNode()
|
|
37
|
-
entryPoint.getStreamrNode()
|
|
36
|
+
entryPoint.getStreamrNode().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
37
|
+
entryPoint.getStreamrNode().joinStreamPart(streamPartId)
|
|
38
38
|
|
|
39
39
|
await Promise.all(range(NUM_OF_NODES).map(async () => {
|
|
40
40
|
const peerDescriptor = createMockPeerDescriptor()
|
|
@@ -62,15 +62,15 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
62
62
|
it('happy path', async () => {
|
|
63
63
|
await Promise.all(nodes.map((node) =>
|
|
64
64
|
waitForCondition(() => {
|
|
65
|
-
return node.getStreamrNode()
|
|
65
|
+
return node.getStreamrNode().getNeighbors(streamPartId).length >= 3
|
|
66
66
|
}
|
|
67
67
|
, 30000)
|
|
68
68
|
))
|
|
69
69
|
let receivedMessageCount = 0
|
|
70
70
|
const successIds: string[] = []
|
|
71
71
|
nodes.forEach((node) => {
|
|
72
|
-
node.getStreamrNode()
|
|
73
|
-
successIds.push(getNodeIdFromPeerDescriptor(node.getStreamrNode()
|
|
72
|
+
node.getStreamrNode().on('newMessage', () => {
|
|
73
|
+
successIds.push(getNodeIdFromPeerDescriptor(node.getStreamrNode().getPeerDescriptor()))
|
|
74
74
|
receivedMessageCount += 1
|
|
75
75
|
})
|
|
76
76
|
})
|
|
@@ -79,7 +79,7 @@ describe('Full node network with WebRTC connections', () => {
|
|
|
79
79
|
streamPartId,
|
|
80
80
|
randomEthereumAddress()
|
|
81
81
|
)
|
|
82
|
-
entryPoint.getStreamrNode()
|
|
82
|
+
entryPoint.getStreamrNode().broadcast(msg)
|
|
83
83
|
await waitForCondition(() => receivedMessageCount === NUM_OF_NODES)
|
|
84
84
|
}, 120000)
|
|
85
85
|
|
|
@@ -30,8 +30,8 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
30
30
|
}
|
|
31
31
|
})
|
|
32
32
|
await entryPoint.start()
|
|
33
|
-
entryPoint.getStreamrNode()
|
|
34
|
-
entryPoint.getStreamrNode()
|
|
33
|
+
entryPoint.getStreamrNode().setStreamPartEntryPoints(streamPartId, [epPeerDescriptor])
|
|
34
|
+
entryPoint.getStreamrNode().joinStreamPart(streamPartId)
|
|
35
35
|
|
|
36
36
|
await Promise.all(range(NUM_OF_NODES).map(async (i) => {
|
|
37
37
|
const node = new NetworkStack({
|
|
@@ -60,15 +60,15 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
60
60
|
it('happy path', async () => {
|
|
61
61
|
await Promise.all(nodes.map((node) =>
|
|
62
62
|
waitForCondition(() => {
|
|
63
|
-
return node.getStreamrNode()
|
|
63
|
+
return node.getStreamrNode().getNeighbors(streamPartId).length >= 4
|
|
64
64
|
}
|
|
65
65
|
, 30000)
|
|
66
66
|
))
|
|
67
67
|
let receivedMessageCount = 0
|
|
68
68
|
const successIds: string[] = []
|
|
69
69
|
nodes.forEach((node) => {
|
|
70
|
-
node.getStreamrNode()
|
|
71
|
-
successIds.push(getNodeIdFromPeerDescriptor(node.getStreamrNode()
|
|
70
|
+
node.getStreamrNode().on('newMessage', () => {
|
|
71
|
+
successIds.push(getNodeIdFromPeerDescriptor(node.getStreamrNode().getPeerDescriptor()))
|
|
72
72
|
receivedMessageCount += 1
|
|
73
73
|
})
|
|
74
74
|
})
|
|
@@ -78,7 +78,7 @@ describe('Full node network with WebSocket connections only', () => {
|
|
|
78
78
|
streamPartId,
|
|
79
79
|
randomEthereumAddress()
|
|
80
80
|
)
|
|
81
|
-
entryPoint.getStreamrNode()
|
|
81
|
+
entryPoint.getStreamrNode().broadcast(msg)
|
|
82
82
|
await waitForCondition(() => receivedMessageCount === NUM_OF_NODES)
|
|
83
83
|
}, 220000)
|
|
84
84
|
|
|
@@ -98,12 +98,16 @@ describe('NetworkNode', () => {
|
|
|
98
98
|
await node2.join(STREAM_PART_ID)
|
|
99
99
|
const result1 = await node1.fetchNodeInfo(pd2)
|
|
100
100
|
const result2 = await node2.fetchNodeInfo(pd1)
|
|
101
|
+
const result3 = await node1.fetchNodeInfo(node1.getPeerDescriptor())
|
|
101
102
|
expect(result1.streamPartitions.length).toEqual(1)
|
|
102
103
|
expect(result2.streamPartitions.length).toEqual(1)
|
|
103
|
-
expect(
|
|
104
|
-
expect(
|
|
105
|
-
expect(
|
|
106
|
-
expect(
|
|
104
|
+
expect(result3.streamPartitions.length).toEqual(1)
|
|
105
|
+
expect(result1.controlLayer.connections.length).toEqual(1)
|
|
106
|
+
expect(result2.controlLayer.connections.length).toEqual(1)
|
|
107
|
+
expect(result3.controlLayer.connections.length).toEqual(1)
|
|
108
|
+
expect(result1.controlLayer.neighbors.length).toEqual(1)
|
|
109
|
+
expect(result2.controlLayer.neighbors.length).toEqual(1)
|
|
110
|
+
expect(result3.controlLayer.neighbors.length).toEqual(1)
|
|
107
111
|
})
|
|
108
112
|
|
|
109
113
|
})
|
|
@@ -34,9 +34,9 @@ describe('NetworkStack', () => {
|
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
await stack1.start()
|
|
37
|
-
stack1.getStreamrNode()
|
|
37
|
+
stack1.getStreamrNode().setStreamPartEntryPoints(STREAM_PART_ID, [epDescriptor])
|
|
38
38
|
await stack2.start()
|
|
39
|
-
stack2.getStreamrNode()
|
|
39
|
+
stack2.getStreamrNode().setStreamPartEntryPoints(STREAM_PART_ID, [epDescriptor])
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
afterEach(async () => {
|