diff --git a/test/inverse/ws.private.test.ts b/test/inverse/ws.private.test.ts index c95a3b5..23c703d 100644 --- a/test/inverse/ws.private.test.ts +++ b/test/inverse/ws.private.test.ts @@ -81,14 +81,6 @@ describe('Private Inverse Perps Websocket Client', () => { // const wsUpdatePromise = waitForSocketEvent(wsClient, 'update'); const wsTopic = 'wallet'; - expect(wsResponsePromise).resolves.toMatchObject({ - request: { - args: [wsTopic], - op: 'subscribe', - }, - success: true, - }); - // No easy way to trigger a private event (other than executing trades) // expect(wsUpdatePromise).resolves.toMatchObject({ // topic: wsTopic, @@ -97,7 +89,13 @@ describe('Private Inverse Perps Websocket Client', () => { wsClient.subscribe(wsTopic); - await Promise.all([wsResponsePromise]); + expect(await wsResponsePromise).toMatchObject({ + request: { + args: [wsTopic], + op: 'subscribe', + }, + success: true, + }); }); }); }); diff --git a/test/linear/ws.private.test.ts b/test/linear/ws.private.test.ts index 1f9336f..fca6ea2 100644 --- a/test/linear/ws.private.test.ts +++ b/test/linear/ws.private.test.ts @@ -31,7 +31,6 @@ describe('Private Linear Perps Websocket Client', () => { ); const wsOpenPromise = waitForSocketEvent(badClient, 'open', 2500); - badClient.connectPrivate(); try { diff --git a/test/linear/ws.public.test.ts b/test/linear/ws.public.test.ts index ee1dd27..7d3b195 100644 --- a/test/linear/ws.public.test.ts +++ b/test/linear/ws.public.test.ts @@ -94,6 +94,10 @@ describe('Public Linear Perps Websocket Client', () => { wsClient.subscribe(wsTopic); - await Promise.all([wsResponsePromise]); + try { + await Promise.all([wsResponsePromise]); + } catch (e) { + // + } }); }); diff --git a/test/spot/ws.private.v3.test.ts b/test/spot/ws.private.v3.test.ts index 16836fa..1a5d614 100644 --- a/test/spot/ws.private.v3.test.ts +++ b/test/spot/ws.private.v3.test.ts @@ -90,16 +90,11 @@ describe('Private Spot V3 Websocket Client', () => { expect(e).toBeFalsy(); } - try { - expect(await wsResponsePromise).toMatchObject({ - op: 'auth', - success: true, - req_id: `${WS_KEY_MAP.spotV3Private}-auth`, - }); - } catch (e) { - console.error(`Wait for "${wsTopic}" event exception: `, e); - expect(e).toBeFalsy(); - } + expect(await wsResponsePromise).toMatchObject({ + op: 'auth', + success: true, + req_id: `${WS_KEY_MAP.spotV3Private}-auth`, + }); }); it('should subscribe to private outboundAccountInfo events', async () => { @@ -108,20 +103,12 @@ describe('Private Spot V3 Websocket Client', () => { // expect(wsUpdatePromise).resolves.toStrictEqual(''); wsClient.subscribe(wsTopic); - try { - expect(await wsResponsePromise).toMatchObject({ - op: 'subscribe', - success: true, - ret_msg: '', - req_id: wsTopic, - }); - } catch (e) { - console.error( - `Wait for "${wsTopic}" subscription response exception: `, - e - ); - expect(e).toBeFalsy(); - } + expect(await wsResponsePromise).toMatchObject({ + op: 'subscribe', + success: true, + ret_msg: '', + req_id: wsTopic, + }); }); }); }); diff --git a/test/usdc/options/ws.public.test.ts b/test/usdc/options/ws.public.test.ts index 0771099..48c4fbf 100644 --- a/test/usdc/options/ws.public.test.ts +++ b/test/usdc/options/ws.public.test.ts @@ -22,11 +22,7 @@ describe('Public USDC Option Websocket Client', () => { wsClientOptions, getSilentLogger('expectSuccessNoAuth') ); - }); - - beforeEach(() => { - wsClient.removeAllListeners(); - // logAllEvents(wsClient); + wsClient.connectPublic(); }); afterAll(() => { diff --git a/test/usdc/perpetual/ws.public.test.ts b/test/usdc/perpetual/ws.public.test.ts index b3fce40..5b67c0f 100644 --- a/test/usdc/perpetual/ws.public.test.ts +++ b/test/usdc/perpetual/ws.public.test.ts @@ -22,11 +22,7 @@ describe('Public USDC Perp Websocket Client', () => { wsClientOptions, getSilentLogger('expectSuccessNoAuth') ); - // logAllEvents(wsClient); - }); - - beforeEach(() => { - wsClient.removeAllListeners(); + wsClient.connectPublic(); // logAllEvents(wsClient); }); diff --git a/test/ws.util.ts b/test/ws.util.ts index ae0302c..1fa49da 100644 --- a/test/ws.util.ts +++ b/test/ws.util.ts @@ -6,8 +6,8 @@ export function getSilentLogger(logHint?: string) { debug: () => {}, notice: () => {}, info: () => {}, - warning: (...params) => console.warn('warning', logHint, ...params), - error: (...params) => console.error('error', logHint, ...params), + warning: () => {}, + error: () => {}, }; }