forked from hirokisan/bybit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ws_spot_v1_private_test.go
56 lines (47 loc) · 1.47 KB
/
ws_spot_v1_private_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
package bybit
import (
"encoding/json"
"testing"
"github.com/hirokisan/bybit/v2/testhelper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestSpotWebsocketV1PrivateOutboundAccountInfo(t *testing.T) {
respBody := []SpotWebsocketV1PrivateOutboundAccountInfoResponse{
{
Content: SpotWebsocketV1PrivateOutboundAccountInfoResponseContent{
EventType: SpotWebsocketV1PrivateEventTypeOutboundAccountInfo,
Timestamp: "1664285837492",
AllowTrade: true,
AllowWithdraw: true,
AllowWDeposit: true,
WalletBalanceChanges: []SpotWebsocketV1PrivateOutboundAccountInfoResponseWalletBalanceChange{
{
SymbolName: "USDT",
AvailableBalance: "250.117543",
ReservedBalance: "10",
},
},
},
},
}
bytesBody, err := json.Marshal(respBody)
require.NoError(t, err)
server, teardown := testhelper.NewWebsocketServer(
testhelper.WithWebsocketHandlerOption(SpotWebsocketV1PrivatePath, bytesBody),
)
defer teardown()
wsClient := NewTestWebsocketClient().
WithBaseURL(server.URL).
WithAuth("test", "test")
svc, err := wsClient.Spot().V1().Private()
require.NoError(t, err)
require.NoError(t, svc.Subscribe())
require.NoError(t, svc.RegisterFuncOutboundAccountInfo(func(response SpotWebsocketV1PrivateOutboundAccountInfoResponse) error {
assert.Equal(t, respBody[0], response)
return nil
}))
assert.NoError(t, svc.Run())
assert.NoError(t, svc.Ping())
assert.NoError(t, svc.Close())
}