forked from ccxt/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlending_interest_service_test.go
92 lines (83 loc) · 2 KB
/
lending_interest_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
92
package binance
import (
"context"
"testing"
"github.com/stretchr/testify/suite"
)
type lendingInterestServiceTestSuite struct {
baseTestSuite
}
func TestLendingInterestService(t *testing.T) {
suite.Run(t, new(lendingInterestServiceTestSuite))
}
func (s *lendingInterestServiceTestSuite) TestListLendingInterestService() {
data := []byte(`
[
{
"asset": "USDT",
"interest": "0.00006408",
"lendingType": "DAILY",
"productName": "USDT",
"time": 1577233578000
},
{
"asset": "USDT",
"interest": "0.00687654",
"lendingType": "DAILY",
"productName": "USDT",
"time": 1577233562000
}
]
`)
s.mockDo(data, nil)
defer s.assertDo()
asset := `USDT`
startTime := int64(1508198532000)
endTime := int64(1508198532001)
s.assertReq(func(r *request) {
e := newSignedRequest().setParams(params{
`asset`: asset,
`size`: 2,
`current`: 1,
`lendingType`: `DAILY`,
`startTime`: startTime,
`endTime`: endTime,
`recvWindow`: 60000,
})
s.assertRequestEqual(e, r)
})
results, err := s.client.NewListLendingInterestService().
Asset(asset).
Size(2).
Current(1).
LendingType(`DAILY`).
StartTime(startTime).
EndTime(endTime).
Do(context.Background())
r := s.r()
r.NoError(err)
resultArr := *results
s.Len(resultArr, 2)
s.assertInterestEqual(&LendingInterestResponse{
Time: 1577233578000,
Asset: `USDT`,
ProductName: `USDT`,
Interest: `0.00006408`,
LendingType: `DAILY`,
}, &resultArr[0])
s.assertInterestEqual(&LendingInterestResponse{
Time: 1577233562000,
Asset: `USDT`,
ProductName: `USDT`,
Interest: `0.00687654`,
LendingType: `DAILY`,
}, &resultArr[1])
}
func (s *lendingInterestServiceTestSuite) assertInterestEqual(e, a *LendingInterestResponse) {
r := s.r()
r.Equal(e.Interest, a.Interest, `Interest`)
r.Equal(e.LendingType, a.LendingType, `LendingType`)
r.Equal(e.Asset, a.Asset, `Asset`)
r.Equal(e.Time, a.Time, `Time`)
r.Equal(e.ProductName, a.ProductName, `ProductName`)
}