-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
v5_ws_public_liquidation_test.go
57 lines (48 loc) · 1.29 KB
/
v5_ws_public_liquidation_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package bybit
import (
"encoding/json"
"testing"
"github.com/hirokisan/bybit/v2/testhelper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestWebsocketV5Public_Liquidation(t *testing.T) {
respBody := map[string]interface{}{
"topic": "liquidation.BTCUSDT",
"type": "snapshot",
"ts": 1673251091822,
"data": map[string]interface{}{
"price": "25844.48",
"side": "Buy",
"size": "2.8",
"symbol": "BTCUSDT",
"updatedTime": 1673251091822,
},
}
bytesBody, err := json.Marshal(respBody)
require.NoError(t, err)
category := CategoryV5Linear
server, teardown := testhelper.NewWebsocketServer(
testhelper.WithWebsocketHandlerOption(V5WebsocketPublicPathFor(category), bytesBody),
)
defer teardown()
wsClient := NewTestWebsocketClient().
WithBaseURL(server.URL)
svc, err := wsClient.V5().Public(category)
require.NoError(t, err)
{
_, err := svc.SubscribeLiquidation(
V5WebsocketPublicLiquidationParamKey{
Symbol: SymbolV5BTCUSDT,
},
func(response V5WebsocketPublicLiquidationResponse) error {
assert.Equal(t, respBody["topic"], response.Topic)
return nil
},
)
require.NoError(t, err)
}
assert.NoError(t, svc.Run())
assert.NoError(t, svc.Ping())
assert.NoError(t, svc.Close())
}