Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokisan committed Mar 3, 2023
1 parent 0425794 commit 6c4e9cc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 66 deletions.
3 changes: 1 addition & 2 deletions integrationtest-ws/v5/testdata/private-v5-position.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{
"autoAddMargin": 0,
"positionIdx": 0,
"tpSlMode": "",
"tradeMode": 0,
"riskId": 1,
"riskLimitValue": "2000000",
Expand Down Expand Up @@ -34,4 +33,4 @@
"positionStatus": "Normal"
}
]
}
}
64 changes: 0 additions & 64 deletions v5_ws_private_wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,70 +72,6 @@ func TestV5WebsocketPrivate_Wallet(t *testing.T) {
require.NoError(t, err)
}

assert.NoError(t, svc.Run())
assert.NoError(t, svc.Ping())
assert.NoError(t, svc.Close())
})
t.Run("for Contract", func(t *testing.T) {
respBody := map[string]interface{}{
"topic": "wallet",
"id": "75d86e42f18b23b9ad2c1f10eaffa8bb:18483ff242aca593:0:01",
"creationTime": 1677226839837,
"data": []map[string]interface{}{
{
"accountIMRate": "0.016",
"accountMMRate": "0.003",
"totalEquity": "12837.78330098",
"totalWalletBalance": "12840.4045924",
"totalMarginBalance": "12837.78330188",
"totalAvailableBalance": "12632.05767702",
"totalPerpUPL": "-2.62129051",
"totalInitialMargin": "205.72562486",
"totalMaintenanceMargin": "39.42876721",
"accountType": "UNIFIED",
"coin": map[string]interface{}{
"coin": "USDC",
"equity": "200.62572554",
"usdValue": "200.62572554",
"walletBalance": "201.34882644",
"availableToWithdraw": "0",
"availableToBorrow": "1500000",
"borrowAmount": "0",
"accruedInterest": "0",
"totalOrderIM": "0",
"totalPositionIM": "202.99874213",
"totalPositionMM": "39.14289747",
"unrealisedPnl": "74.2768991",
"cumRealisedPnl": "-209.1544627",
},
},
},
}
bytesBody, err := json.Marshal(respBody)
require.NoError(t, err)

server, teardown := testhelper.NewWebsocketServer(
testhelper.WithWebsocketHandlerOption(V5WebsocketPrivatePath, bytesBody),
)
defer teardown()

wsClient := NewTestWebsocketClient().
WithBaseURL(server.URL).
WithAuth("test", "test")

svc, err := wsClient.V5().Private()
require.NoError(t, err)

require.NoError(t, svc.Subscribe())

{
_, err := svc.SubscribeWallet(func(response V5WebsocketPrivateWalletResponse) error {
testhelper.Compare(t, respBody["data"].([]map[string]interface{})[0]["coin"], response.Data[0].Coins[0])
return nil
})
require.NoError(t, err)
}

assert.NoError(t, svc.Run())
assert.NoError(t, svc.Ping())
assert.NoError(t, svc.Close())
Expand Down

0 comments on commit 6c4e9cc

Please sign in to comment.