diff --git a/packages/transport-http/src/subscribe/subscription-manager.test.ts b/packages/transport-http/src/subscribe/subscription-manager.test.ts index 4ce60cc57..48d2b81cc 100644 --- a/packages/transport-http/src/subscribe/subscription-manager.test.ts +++ b/packages/transport-http/src/subscribe/subscription-manager.test.ts @@ -7,7 +7,10 @@ import { SubscriptionDataMessage, UnsubscribeMessageRequest, } from "./models" -import {SubscriptionManager} from "./subscription-manager" +import { + SubscriptionManager, + SubscriptionManagerConfig, +} from "./subscription-manager" import {SdkTransport} from "@onflow/typedefs" jest.mock("./websocket", () => ({ @@ -25,10 +28,8 @@ describe("WsSubscriptionTransport", () => { }) test("does not connect to the socket when no subscriptions are made", async () => { - const config = { + const config: SubscriptionManagerConfig = { node: "wss://localhost:8080", - reconnectInterval: 1000, - reconnectAttempts: 10, } new SubscriptionManager(config) @@ -38,10 +39,8 @@ describe("WsSubscriptionTransport", () => { }) test("disconnects from the socket when the last subscription is removed", async () => { - const config = { + const config: SubscriptionManagerConfig = { node: "wss://localhost:8080", - reconnectInterval: 1000, - reconnectAttempts: 10, } const streamController = new SubscriptionManager(config) const topic = "topic" as SdkTransport.SubscriptionTopic @@ -90,10 +89,8 @@ describe("WsSubscriptionTransport", () => { }) test("subscribes, receives data, and unsubscribes", async () => { - const config = { + const config: SubscriptionManagerConfig = { node: "wss://localhost:8080", - reconnectInterval: 1000, - reconnectAttempts: 10, } const streamController = new SubscriptionManager(config) const topic = "topic" as SdkTransport.SubscriptionTopic @@ -162,10 +159,8 @@ describe("WsSubscriptionTransport", () => { }) test("reconnects to stream on close", async () => { - const config = { + const config: SubscriptionManagerConfig = { node: "wss://localhost:8080", - reconnectInterval: 1000, - reconnectAttempts: 1, } const streamController = new SubscriptionManager(config) const topic = "topic" as SdkTransport.SubscriptionTopic diff --git a/packages/transport-http/src/subscribe/subscription-manager.ts b/packages/transport-http/src/subscribe/subscription-manager.ts index 043aa0f6d..b7ea02436 100644 --- a/packages/transport-http/src/subscribe/subscription-manager.ts +++ b/packages/transport-http/src/subscribe/subscription-manager.ts @@ -34,7 +34,7 @@ interface SubscriptionInfo { onError: (error: Error) => void } -interface WsTransportConfig { +export interface SubscriptionManagerConfig { /** * The URL of the node to connect to */ @@ -65,10 +65,10 @@ export class SubscriptionManager { private counter = 0 private subscriptions: SubscriptionInfo[] = [] private socket: WebSocket | null = null - private config: DeepRequired + private config: DeepRequired private reconnectAttempts = 0 - constructor(config: WsTransportConfig) { + constructor(config: SubscriptionManagerConfig) { this.config = { ...config, reconnectOptions: {