forked from stellar-deprecated/kelp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccxtExchangeSpecificParamFactory_test.go
88 lines (83 loc) · 1.75 KB
/
ccxtExchangeSpecificParamFactory_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
package plugins
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBinanceTransformLimit(t *testing.T) {
testCases := []struct {
limit int
wantNewLimit int
wantError error
}{
{
limit: 1,
wantNewLimit: 5,
wantError: nil,
}, {
limit: 2,
wantNewLimit: 5,
wantError: nil,
}, {
limit: 3,
wantNewLimit: 5,
wantError: nil,
}, {
limit: 4,
wantNewLimit: 5,
wantError: nil,
}, {
limit: 5,
wantNewLimit: 5,
wantError: nil,
}, {
limit: 6,
wantNewLimit: 10,
wantError: nil,
}, {
limit: 10,
wantNewLimit: 10,
wantError: nil,
}, {
limit: 11,
wantNewLimit: 20,
wantError: nil,
}, {
limit: 21,
wantNewLimit: 50,
wantError: nil,
}, {
limit: 51,
wantNewLimit: 100,
wantError: nil,
}, {
limit: 101,
wantNewLimit: 500,
wantError: nil,
}, {
limit: 501,
wantNewLimit: 1000,
wantError: nil,
}, {
limit: 1001,
wantNewLimit: 5000,
wantError: nil,
}, {
limit: 5001,
wantNewLimit: -1,
wantError: fmt.Errorf("limit requested (5001) is higher than the maximum limit allowed (5000)"),
},
}
binanceParamFactory := makeCcxtExchangeSpecificParamFactoryBinance()
for _, k := range testCases {
t.Run(fmt.Sprintf("%d", k.limit), func(t *testing.T) {
newLimit, e := binanceParamFactory.transformLimit(k.limit)
assert.Equal(t, k.wantNewLimit, newLimit)
assert.Equal(t, k.wantError, e)
// repeat values to test caching
newLimit, e = binanceParamFactory.transformLimit(k.limit)
assert.Equal(t, k.wantNewLimit, newLimit)
assert.Equal(t, k.wantError, e)
})
}
}