From d4443de71f1cb0b76c9538f03f822b6a57f82602 Mon Sep 17 00:00:00 2001 From: Teo Gebhard Date: Thu, 24 Oct 2024 16:14:52 +0300 Subject: [PATCH] Revert "types from latest monorepo" This reverts commit f985d5c9886d2416baac947b6353741260089b9a. --- src/crawler/Crawler.ts | 7 ++----- src/crawler/NetworkNodeFacade.ts | 15 ++++++++------- test/end-to-end.test.ts | 6 ++++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/crawler/Crawler.ts b/src/crawler/Crawler.ts index 8af9817..d16cf25 100644 --- a/src/crawler/Crawler.ts +++ b/src/crawler/Crawler.ts @@ -53,13 +53,10 @@ const createNodeInfoLogOutput = (nodeInfo: NormalizedNodeInfo) => { neighbors: nodeInfo.controlLayer!.neighbors.map(toNodeId), connections: nodeInfo.controlLayer!.connections.map(toNodeId) }, - streamPartitions: nodeInfo.streamPartitions.map((sp) => ({ + streamPartitions: nodeInfo.streamPartitions.map((sp: any) => ({ id: sp.id, controlLayerNeighbors: sp.controlLayerNeighbors.map(toNodeId), - contentDeliveryLayerNeighbors: sp.contentDeliveryLayerNeighbors.map((n) => ({ - nodeId: toNodeId(n.peerDescriptor), - rtt: n.rtt - })) + contentDeliveryLayerNeighbors: sp.contentDeliveryLayerNeighbors.map((n: any) => toNodeId(n.peerDescriptor)) // TODO better type })), version: nodeInfo.version } diff --git a/src/crawler/NetworkNodeFacade.ts b/src/crawler/NetworkNodeFacade.ts index 1369dc8..efc0eee 100644 --- a/src/crawler/NetworkNodeFacade.ts +++ b/src/crawler/NetworkNodeFacade.ts @@ -1,6 +1,6 @@ import { PeerDescriptor } from '@streamr/dht' -import { NetworkNode, NodeInfo, StreamMessage, streamPartIdToDataKey, StreamPartitionInfo } from '@streamr/trackerless-network' -import { ChangeFieldType, StreamPartID } from '@streamr/utils' +import { NetworkNode, NodeInfo, StreamMessage, streamPartIdToDataKey } from '@streamr/trackerless-network' +import { StreamPartID } from '@streamr/utils' import EventEmitter3 from 'eventemitter3' import semver from 'semver' import { Config } from '../Config' @@ -10,16 +10,17 @@ export interface Events { unsubscribe: () => void } -export type NormalizedNodeInfo = ChangeFieldType< - NodeInfo, - 'streamPartitions', - Omit[]> +type ArrayElement = + ArrayType extends readonly (infer ElementType)[] ? ElementType : never + +export type NormalizedNodeInfo = Omit + & { streamPartitions: Omit, 'deprecatedContentDeliveryLayerNeighbors'>[] } const toNormalizeNodeInfo = (info: NodeInfo): NormalizedNodeInfo => { const isLegacyFormat = semver.satisfies(semver.coerce(info.version)!, '< 102.0.0') return { ...info, - streamPartitions: info.streamPartitions.map((sp: StreamPartitionInfo) => ({ + streamPartitions: info.streamPartitions.map((sp) => ({ ...sp, contentDeliveryLayerNeighbors: !isLegacyFormat ? sp.contentDeliveryLayerNeighbors diff --git a/test/end-to-end.test.ts b/test/end-to-end.test.ts index 8b619fd..8960634 100644 --- a/test/end-to-end.test.ts +++ b/test/end-to-end.test.ts @@ -1,7 +1,7 @@ import 'reflect-metadata' import { DhtAddress, NodeType, randomDhtAddress, toDhtAddress, toDhtAddressRaw } from '@streamr/dht' -import StreamrClient, { NetworkNodeType, PeerDescriptor, StreamID, StreamPermission, StreamrClientConfig } from '@streamr/sdk' +import StreamrClient, { CONFIG_TEST, NetworkNodeType, PeerDescriptor, StreamID, StreamPermission, StreamrClientConfig } from '@streamr/sdk' import { NetworkNode, createNetworkNode } from '@streamr/trackerless-network' import { StreamPartID, collect, setAbortableInterval, toStreamPartID, waitForCondition } from '@streamr/utils' import { sample, uniq, without } from 'lodash' @@ -50,9 +50,11 @@ const startEntryPoint = async (): Promise => { const createClientConfig = (entryPointPeerDescriptor: PeerDescriptor): StreamrClientConfig => { return { - environment:'dev2', + ...CONFIG_TEST, network: { + ...CONFIG_TEST.network, controlLayer: { + ...CONFIG_TEST.network!.controlLayer, entryPoints: [{ nodeId: toDhtAddress(entryPointPeerDescriptor.nodeId), type: NetworkNodeType.NODEJS,