mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Merge pull request #173 from marcofranssen/hotfix/lowercase-missed-configs
Hotfix/lowercase missed configs
This commit is contained in:
@@ -138,7 +138,7 @@ type ExchangeConfig struct {
|
||||
// BankAccount holds differing bank account details by supported funding
|
||||
// currency
|
||||
type BankAccount struct {
|
||||
Enabled bool `json:",omitempty"`
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
BankName string `json:"bankName"`
|
||||
BankAddress string `json:"bankAddress"`
|
||||
AccountName string `json:"accountName"`
|
||||
@@ -228,7 +228,7 @@ func (c *Config) GetCurrencyConfig() CurrencyConfig {
|
||||
|
||||
// GetExchangeBankAccounts returns banking details associated with an exchange
|
||||
// for depositing funds
|
||||
func (c *Config) GetExchangeBankAccounts(exchangeName, depositingCurrency string) (BankAccount, error) {
|
||||
func (c *Config) GetExchangeBankAccounts(exchangeName string, depositingCurrency string) (BankAccount, error) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
@@ -264,7 +264,7 @@ func (c *Config) UpdateExchangeBankAccounts(exchangeName string, bankCfg []BankA
|
||||
|
||||
// GetClientBankAccounts returns banking details used for a given exchange
|
||||
// and currency
|
||||
func (c *Config) GetClientBankAccounts(exchangeName, targetCurrency string) (BankAccount, error) {
|
||||
func (c *Config) GetClientBankAccounts(exchangeName string, targetCurrency string) (BankAccount, error) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -6,18 +6,18 @@ import (
|
||||
|
||||
// Settings enforces standard variables across the provider packages
|
||||
type Settings struct {
|
||||
Name string
|
||||
Enabled bool
|
||||
Verbose bool
|
||||
RESTPollingDelay time.Duration
|
||||
APIKey string
|
||||
APIKeyLvl int
|
||||
PrimaryProvider bool
|
||||
Name string `json:"name"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Verbose bool `json:"verbose"`
|
||||
RESTPollingDelay time.Duration `json:"restPollingDelay"`
|
||||
APIKey string `json:"apiKey"`
|
||||
APIKeyLvl int `json:"apiKeyLvl"`
|
||||
PrimaryProvider bool `json:"primaryProvider"`
|
||||
}
|
||||
|
||||
// Base enforces standard variables across the provider packages
|
||||
type Base struct {
|
||||
Settings
|
||||
Settings `json:"settings"`
|
||||
}
|
||||
|
||||
// GetName returns name of provider
|
||||
|
||||
@@ -884,7 +884,7 @@ type TradeGetBucketedParams struct {
|
||||
Start int32 `json:"start,omitempty"`
|
||||
|
||||
// StartTime - Starting date filter for results.
|
||||
StartTime string `json:"symbol,omitempty"`
|
||||
StartTime string `json:"startTime,omitempty"`
|
||||
|
||||
// Symbol - Instrument symbol. Send a bare series (e.g. XBU) to get data for
|
||||
// the nearest expiring contract in that series.You can also send a timeframe,
|
||||
|
||||
@@ -41,11 +41,11 @@ type AllEnabledExchangeAccounts struct {
|
||||
Data []exchange.AccountInfo `json:"data"`
|
||||
}
|
||||
|
||||
// RESTfulJSONResponse outputs a JSON response of the req interface
|
||||
func RESTfulJSONResponse(w http.ResponseWriter, r *http.Request, req interface{}) error {
|
||||
// RESTfulJSONResponse outputs a JSON response of the response interface
|
||||
func RESTfulJSONResponse(w http.ResponseWriter, r *http.Request, response interface{}) error {
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return json.NewEncoder(w).Encode(req)
|
||||
return json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
// RESTfulError prints the REST method and error
|
||||
|
||||
52
restful_server_test.go
Normal file
52
restful_server_test.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
)
|
||||
|
||||
func loadConfig(t *testing.T) *config.Config {
|
||||
cfg := config.GetConfig()
|
||||
err := cfg.LoadConfig(strings.Replace(config.ConfigTestFile, "..", ".", 1))
|
||||
if err != nil {
|
||||
t.Error("Test failed. GetCurrencyConfig LoadConfig error", err)
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
func makeHTTPGetRequest(t *testing.T, url string, response interface{}) *http.Response {
|
||||
req := httptest.NewRequest("GET", "http://localhost:9050/config/all", nil)
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
err := RESTfulJSONResponse(w, req, response)
|
||||
if err != nil {
|
||||
t.Error("Test failed. Failed to make response.", err)
|
||||
}
|
||||
return w.Result()
|
||||
}
|
||||
|
||||
// TestConfigAllJsonResponse test if config/all restful json response is valid
|
||||
func TestConfigAllJsonResponse(t *testing.T) {
|
||||
cfg := loadConfig(t)
|
||||
resp := makeHTTPGetRequest(t, "http://localhost:9050/config/all", cfg)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Error("Test failed. Body not readable", err)
|
||||
}
|
||||
var responseConfig config.Config
|
||||
jsonErr := json.Unmarshal(body, &responseConfig)
|
||||
if jsonErr != nil {
|
||||
t.Error("Test failed. Response not parseable as json", err)
|
||||
}
|
||||
|
||||
if reflect.DeepEqual(responseConfig, cfg) {
|
||||
t.Error("Test failed. Json not equal to config")
|
||||
}
|
||||
}
|
||||
56
testdata/configtest.json
vendored
56
testdata/configtest.json
vendored
@@ -5,40 +5,40 @@
|
||||
"currencyConfig": {
|
||||
"forexProviders": [
|
||||
{
|
||||
"Name": "CurrencyConverter",
|
||||
"Enabled": true,
|
||||
"Verbose": false,
|
||||
"RESTPollingDelay": 600,
|
||||
"APIKey": "",
|
||||
"APIKeyLvl": 0,
|
||||
"PrimaryProvider": true
|
||||
"name": "CurrencyConverter",
|
||||
"enabled": true,
|
||||
"verbose": false,
|
||||
"restPollingDelay": 600,
|
||||
"apiKey": "",
|
||||
"apiKeyLvl": 0,
|
||||
"primaryProvider": true
|
||||
},
|
||||
{
|
||||
"Name": "CurrencyLayer",
|
||||
"Enabled": false,
|
||||
"Verbose": false,
|
||||
"RESTPollingDelay": 600,
|
||||
"APIKey": "Key",
|
||||
"APIKeyLvl": -1,
|
||||
"PrimaryProvider": false
|
||||
"name": "CurrencyLayer",
|
||||
"enabled": false,
|
||||
"verbose": false,
|
||||
"restPollingDelay": 600,
|
||||
"apiKey": "Key",
|
||||
"apiKeyLvl": -1,
|
||||
"primaryProvider": false
|
||||
},
|
||||
{
|
||||
"Name": "Fixer",
|
||||
"Enabled": false,
|
||||
"Verbose": false,
|
||||
"RESTPollingDelay": 600,
|
||||
"APIKey": "Key",
|
||||
"APIKeyLvl": -1,
|
||||
"PrimaryProvider": false
|
||||
"name": "Fixer",
|
||||
"enabled": false,
|
||||
"verbose": false,
|
||||
"restPollingDelay": 600,
|
||||
"apiKey": "Key",
|
||||
"apiKeyLvl": -1,
|
||||
"primaryProvider": false
|
||||
},
|
||||
{
|
||||
"Name": "OpenExchangeRates",
|
||||
"Enabled": false,
|
||||
"Verbose": false,
|
||||
"RESTPollingDelay": 600,
|
||||
"APIKey": "Key",
|
||||
"APIKeyLvl": -1,
|
||||
"PrimaryProvider": false
|
||||
"name": "OpenExchangeRates",
|
||||
"enabled": false,
|
||||
"verbose": false,
|
||||
"restPollingDelay": 600,
|
||||
"apiKey": "Key",
|
||||
"apiKeyLvl": -1,
|
||||
"primaryProvider": false
|
||||
}
|
||||
],
|
||||
"cryptocurrencies": "BTC,LTC,ETH,DOGE,DASH,XRP,XMR",
|
||||
|
||||
Reference in New Issue
Block a user