tests for unified margin WS

This commit is contained in:
tiagosiebler
2022-09-16 19:56:24 +01:00
parent 2766a17fe8
commit 4eca5fb180
5 changed files with 169 additions and 33 deletions

View File

@@ -44,16 +44,18 @@ describe('Public Unified Margin Websocket Client (Perps - USDT)', () => {
}
});
it('should subscribe to public trade events through USDT topic', async () => {
it('should subscribe to public orderbook events through USDT connection', async () => {
const wsResponsePromise = waitForSocketEvent(wsClient, 'response');
const wsUpdatePromise = waitForSocketEvent(wsClient, 'update');
wsClient.subscribe('orderbook.25.BTCUSDT');
// USDT should be detected and automatically routed through the USDT connection
const topic = 'orderbook.25.BTCUSDT';
wsClient.subscribe(topic);
try {
expect(await wsResponsePromise).toMatchObject({
op: 'subscribe',
req_id: 'orderbook.25.BTCUSDT',
req_id: topic,
success: true,
wsKey: WS_KEY_MAP.unifiedPerpUSDTPublic,
});
@@ -70,7 +72,7 @@ describe('Public Unified Margin Websocket Client (Perps - USDT)', () => {
s: 'BTCUSDT',
u: expect.any(Number),
},
topic: 'orderbook.25.BTCUSDT',
topic: topic,
ts: expect.any(Number),
type: 'snapshot',
wsKey: WS_KEY_MAP.unifiedPerpUSDTPublic,