fix unstable ws test handler + improve logging

This commit is contained in:
tiagosiebler
2022-12-28 13:40:20 +00:00
parent dcf5050d32
commit f0394f91e9
4 changed files with 19 additions and 16 deletions

View File

@@ -58,18 +58,6 @@ describe('Public Spot V3 Websocket Client', () => {
req_id: wsTopic,
});
expect(wsUpdatePromise).resolves.toMatchObject({
data: {
a: expect.any(Array),
b: expect.any(Array),
s: symbol,
t: expect.any(Number),
},
topic: wsTopic,
ts: expect.any(Number),
type: 'delta',
});
wsClient.subscribe(wsTopic);
try {
@@ -82,9 +70,20 @@ describe('Public Spot V3 Websocket Client', () => {
}
try {
await wsUpdatePromise;
expect(await wsUpdatePromise).toMatchObject({
data: {
a: expect.any(Array),
b: expect.any(Array),
s: symbol,
t: expect.any(Number),
},
topic: wsTopic,
ts: expect.any(Number),
type: 'snapshot',
});
} catch (e) {
console.error(`Wait for "${wsTopic}" event exception: `, e);
expect(e).toBeFalsy();
}
});
});

View File

@@ -70,12 +70,14 @@ describe('Public Unified Margin Websocket Client (Perps - USDC)', () => {
s: 'BTCUSDT',
u: expect.any(Number),
},
wsKey: WS_KEY_MAP.unifiedPerpUSDTPublic,
topic: 'orderbook.25.BTCUSDC',
ts: expect.any(Number),
type: 'snapshot',
wsKey: WS_KEY_MAP.unifiedPerpUSDTPublic,
});
} catch (e) {
console.error('unified margin perp ws public error: ', e);
// no data
expect(e).toBeFalsy();
}

View File

@@ -49,7 +49,7 @@ describe('Public Unified Margin Websocket Client (Perps - USDT)', () => {
const wsUpdatePromise = waitForSocketEvent(wsClient, 'update');
// USDT should be detected and automatically routed through the USDT connection
const topic = 'orderbook.25.BTCUSDT';
const topic = 'orderbook.1.BTCUSDT';
wsClient.subscribe(topic);
try {
@@ -74,10 +74,11 @@ describe('Public Unified Margin Websocket Client (Perps - USDT)', () => {
},
topic: topic,
ts: expect.any(Number),
type: 'snapshot',
wsKey: WS_KEY_MAP.unifiedPerpUSDTPublic,
type: 'snapshot',
});
} catch (e) {
console.error('unified margin perp usdt orderbook test fail', e);
// no data
expect(e).toBeFalsy();
}

View File

@@ -69,6 +69,7 @@ describe('Public USDC Perp Websocket Client', () => {
type: 'snapshot',
});
} catch (e) {
console.error('usdc perp ws public error: ', e);
// no data
expect(e).toBeFalsy();
}