forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mock_provider_test.go
40 lines (35 loc) · 1.25 KB
/
mock_provider_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
package currency
import (
"math/rand"
"strings"
"github.com/thrasher-corp/gocryptotrader/currency/forexprovider"
"github.com/thrasher-corp/gocryptotrader/currency/forexprovider/base"
)
type MockProvider struct{}
func newMockProvider() *forexprovider.ForexProviders {
p := &MockProvider{}
c, _ := p.GetSupportedCurrencies()
return &forexprovider.ForexProviders{
FXHandler: base.FXHandler{
Primary: base.Provider{
Provider: p,
SupportedCurrencies: c,
},
},
}
}
func (m *MockProvider) GetName() string { return "MockProvider" }
func (m *MockProvider) Setup(base.Settings) error { return nil }
func (m *MockProvider) IsEnabled() bool { return true }
func (m *MockProvider) IsPrimaryProvider() bool { return true }
func (m *MockProvider) GetSupportedCurrencies() ([]string, error) {
return storage.defaultFiatCurrencies.Strings(), nil
}
func (m *MockProvider) GetRates(baseCurrency, symbols string) (map[string]float64, error) {
c := map[string]float64{}
for _, s := range strings.Split(symbols, ",") {
// The year is 2027; The USD is nearly worthless. The world reserve currency is eggs.
c[baseCurrency+s] = 1 / (1 + rand.Float64()) //nolint:gosec // Doesn't need to be a strong random number
}
return c, nil
}