add TestWithdrawBatchQuery test

This commit is contained in:
c9s 2022-06-02 11:56:44 +08:00
parent b36be80fd7
commit 813166dd92
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 44 additions and 5 deletions

View File

@ -0,0 +1,38 @@
package batch
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/c9s/bbgo/pkg/exchange/binance"
"github.com/c9s/bbgo/pkg/testutil"
)
func TestWithdrawBatchQuery(t *testing.T) {
key, secret, ok := testutil.IntegrationTestConfigured(t, "BINANCE")
if !ok {
t.Skip("binance api is not set")
}
ex := binance.New(key, secret)
q := WithdrawBatchQuery{
ExchangeTransferService: ex,
}
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()
now := time.Now()
startTime := now.AddDate(0, -6, 0)
endTime := now
dataC, errC := q.Query(ctx, "", startTime, endTime)
for withdraw := range dataC {
t.Logf("%+v", withdraw)
}
err := <-errC
assert.NoError(t, err)
}

View File

@ -47,7 +47,7 @@ const (
WithdrawStatusCompleted WithdrawStatusCompleted
) )
//go:generate requestgen -method POST -url "/sapi/v1/capital/withdraw/history" -type GetWithdrawHistoryRequest -responseType []WithdrawRecord //go:generate requestgen -method GET -url "/sapi/v1/capital/withdraw/history" -type GetWithdrawHistoryRequest -responseType []WithdrawRecord
type GetWithdrawHistoryRequest struct { type GetWithdrawHistoryRequest struct {
client requestgen.AuthenticatedAPIClient client requestgen.AuthenticatedAPIClient
coin string `param:"coin"` coin string `param:"coin"`

View File

@ -1,4 +1,4 @@
// Code generated by "requestgen -method POST -url /sapi/v1/capital/withdraw/history -type GetWithdrawHistoryRequest -responseType []WithdrawRecord"; DO NOT EDIT. // Code generated by "requestgen -method GET -url /sapi/v1/capital/withdraw/history -type GetWithdrawHistoryRequest -responseType []WithdrawRecord"; DO NOT EDIT.
package binanceapi package binanceapi
@ -214,15 +214,16 @@ func (g *GetWithdrawHistoryRequest) GetSlugsMap() (map[string]string, error) {
func (g *GetWithdrawHistoryRequest) Do(ctx context.Context) ([]WithdrawRecord, error) { func (g *GetWithdrawHistoryRequest) Do(ctx context.Context) ([]WithdrawRecord, error) {
params, err := g.GetParameters() // empty params for GET operation
var params interface{}
query, err := g.GetParametersQuery()
if err != nil { if err != nil {
return nil, err return nil, err
} }
query := url.Values{}
apiURL := "/sapi/v1/capital/withdraw/history" apiURL := "/sapi/v1/capital/withdraw/history"
req, err := g.client.NewAuthenticatedRequest(ctx, "POST", apiURL, query, params) req, err := g.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
if err != nil { if err != nil {
return nil, err return nil, err
} }