mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
add TestWithdrawBatchQuery test
This commit is contained in:
parent
b36be80fd7
commit
813166dd92
38
pkg/exchange/batch/withdraw_test.go
Normal file
38
pkg/exchange/batch/withdraw_test.go
Normal 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)
|
||||
}
|
|
@ -47,7 +47,7 @@ const (
|
|||
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 {
|
||||
client requestgen.AuthenticatedAPIClient
|
||||
coin string `param:"coin"`
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -214,15 +214,16 @@ func (g *GetWithdrawHistoryRequest) GetSlugsMap() (map[string]string, 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 {
|
||||
return nil, err
|
||||
}
|
||||
query := url.Values{}
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user