binance: add TestClient_GetDepth test

This commit is contained in:
c9s 2024-02-06 13:13:57 +08:00
parent 0cf028d192
commit d015670d63
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 18 additions and 2 deletions

View File

@ -244,3 +244,19 @@ func TestClient_NewPlaceMarginOrderRequest(t *testing.T) {
assert.NotEmpty(t, res)
t.Logf("result: %+v", res)
}
func TestClient_GetDepth(t *testing.T) {
client := getTestClientOrSkip(t)
ctx := context.Background()
err := client.SetTimeOffsetFromServer(ctx)
assert.NoError(t, err)
req := client.NewGetDepthRequest().Symbol("BTCUSDT").Limit(1000)
resp, err := req.Do(ctx)
if assert.NoError(t, err) {
assert.NotNil(t, resp)
assert.NotEmpty(t, resp)
t.Logf("response: %+v", resp)
}
}

View File

@ -14,7 +14,7 @@ type Depth struct {
//go:generate requestgen -method GET -url "/api/v3/depth" -type GetDepthRequest -responseType .Depth
type GetDepthRequest struct {
client requestgen.AuthenticatedAPIClient
client requestgen.APIClient
symbol string `param:"symbol"`
limit int `param:"limit" defaultValue:"1000"`

View File

@ -148,7 +148,7 @@ func (g *GetDepthRequest) Do(ctx context.Context) (*Depth, error) {
apiURL = g.GetPath()
req, err := g.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
req, err := g.client.NewRequest(ctx, "GET", apiURL, query, params)
if err != nil {
return nil, err
}