-
Notifications
You must be signed in to change notification settings - Fork 77
/
fiat_test.go
117 lines (107 loc) · 3.05 KB
/
fiat_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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package binance_connector
import (
"testing"
"github.com/stretchr/testify/suite"
)
type fiatTestSuite struct {
baseTestSuite
}
func TestFiat(t *testing.T) {
suite.Run(t, new(fiatTestSuite))
}
func (s *fiatTestSuite) TestGetFiatDepositWithdrawHistory() {
data := []byte(`{
"code": "000000",
"message": "success",
"data": [
{
"orderNo":"7d76d611-0568-4f43-afb6-24cac7767365",
"fiatCurrency": "BRL",
"indicatedAmount": "10.00",
"amount": "10.00",
"totalFee": "0.00",
"method": "BankAccount",
"status": "Expired",
"createTime": 1626144956000,
"updateTime": 1626400907000
}
],
"total": 1,
"success": true
}`)
s.mockDo(data, nil)
defer s.assertDo()
transactionType := "0"
s.assertReq(func(r *request) {
e := newSignedRequest().setParams(params{
"transactionType": transactionType,
})
s.assertRequestEqual(e, r)
})
res, err := s.client.NewGetFiatDepositWithdrawHistoryService().TransactionType(transactionType).Do(newContext())
s.r().NoError(err)
s.Equal("000000", res.Code)
s.Equal("success", res.Message)
s.r().Len(res.Data, 1)
s.Equal("7d76d611-0568-4f43-afb6-24cac7767365", res.Data[0].OrderNo)
s.Equal("BRL", res.Data[0].FiatCurrency)
s.Equal("10.00", res.Data[0].IndicatedAmount)
s.Equal("10.00", res.Data[0].Amount)
s.Equal("0.00", res.Data[0].TotalFee)
s.Equal("BankAccount", res.Data[0].Method)
s.Equal("Expired", res.Data[0].Status)
s.Equal(uint64(1626144956000), res.Data[0].CreateTime)
s.Equal(uint64(1626400907000), res.Data[0].UpdateTime)
s.Equal(int64(1), res.Total)
s.True(res.Success)
}
func (s *fiatTestSuite) TestGetPaymentFiatHistory() {
data := []byte(`{
"code": "000000",
"message": "success",
"data": [
{
"orderNo": "353fca443f06466db0c4dc89f94f027a",
"sourceAmount": "20.0",
"fiatCurrency": "EUR",
"obtainAmount": "4.462",
"cryptoCurrency": "LUNA",
"totalFee": "0.2",
"price": "4.437472",
"status": "Failed",
"paymentMethod": "Credit Card",
"createTime": 1624529919000,
"updateTime": 1624529919000
}
],
"total": 1,
"success": true
}`)
s.mockDo(data, nil)
defer s.assertDo()
transactionType := "0"
s.assertReq(func(r *request) {
e := newSignedRequest().setParams(params{
"transactionType": transactionType,
})
s.assertRequestEqual(e, r)
})
res, err := s.client.NewGetFiatPaymentHistoryService().TransactionType(transactionType).Do(newContext())
s.r().NoError(err)
s.Equal("000000", res.Code)
s.Equal("success", res.Message)
s.r().Len(res.Data, 1)
s.Equal("353fca443f06466db0c4dc89f94f027a", res.Data[0].OrderNo)
s.Equal("20.0", res.Data[0].SourceAmount)
s.Equal("EUR", res.Data[0].FiatCurrency)
s.Equal("4.462", res.Data[0].ObtainAmount)
s.Equal("LUNA", res.Data[0].CryptoCurrency)
s.Equal("0.2", res.Data[0].TotalFee)
s.Equal("4.437472", res.Data[0].Price)
s.Equal("Failed", res.Data[0].Status)
s.Equal("Credit Card", res.Data[0].PaymentMethod)
s.Equal(uint64(1624529919000), res.Data[0].CreateTime)
s.Equal(uint64(1624529919000), res.Data[0].UpdateTime)
s.Equal(int64(1), res.Total)
s.True(res.Success)
}