forked from adshao/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
asset_dividend_service_test.go
91 lines (82 loc) · 1.86 KB
/
asset_dividend_service_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package binance
import (
"context"
"testing"
"github.com/stretchr/testify/suite"
)
type assetDividendServiceTestSuite struct {
baseTestSuite
}
func TestAssetDividendService(t *testing.T) {
suite.Run(t, new(assetDividendServiceTestSuite))
}
func (s *assetDividendServiceTestSuite) TestListAssetDividend() {
data := []byte(`
{
"rows":[
{
"amount":"10.00000000",
"asset":"BHFT",
"divTime":1563189166000,
"enInfo":"BHFT distribution",
"tranId":2968885920
},
{
"amount":"10.00000000",
"asset":"BHFT",
"divTime":1563189165000,
"enInfo":"BHFT distribution",
"tranId":2968885920
}
],
"total":2
}
`)
s.mockDo(data, nil)
defer s.assertDo()
asset := `BHFT`
startTime := int64(1508198532000)
endTime := int64(1508198532001)
s.assertReq(func(r *request) {
e := newSignedRequest().setParams(params{
`asset`: asset,
`limit`: 2,
`startTime`: startTime,
`endTime`: endTime,
})
s.assertRequestEqual(e, r)
})
dividend, err := s.client.NewAssetDividendService().
Asset(asset).
StartTime(startTime).
EndTime(endTime).
Limit(2).
Do(context.Background())
r := s.r()
r.NoError(err)
rows := *dividend.Rows
s.Len(rows, 2)
s.assertDividendEqual(&DividendResponse{
Amount: `10.00000000`,
Asset: `BHFT`,
Time: 1563189166000,
Info: `BHFT distribution`,
TranID: 2968885920,
}, &rows[0])
s.assertDividendEqual(&DividendResponse{
Amount: `10.00000000`,
Asset: `BHFT`,
Time: 1563189165000,
Info: `BHFT distribution`,
TranID: 2968885920,
}, &rows[1])
}
func (s *assetDividendServiceTestSuite) assertDividendEqual(e, a *DividendResponse) {
r := s.r()
r.Equal(e.Amount, `10.00000000`, `Amount`)
r.Equal(e.Amount, a.Amount, `Amount`)
r.Equal(e.Info, a.Info, `Info`)
r.Equal(e.Asset, a.Asset, `Asset`)
r.Equal(e.Time, a.Time, `Time`)
r.Equal(e.TranID, a.TranID, `TranID`)
}