diff --git a/config/config.go b/config/config.go index 2e69eb6a..1aaf4ad5 100644 --- a/config/config.go +++ b/config/config.go @@ -16,9 +16,9 @@ import ( ) const ( - CONFIG_FILE = "config.dat" - OLD_CONFIG_FILE = "config.json" - CONFIG_TEST = "../testdata/configtest.dat" + CONFIG_FILE = "config.dat" + OLD_CONFIG_FILE = "config.json" + CONFIG_TEST_FILE = "../testdata/configtest.dat" CONFIG_FILE_ENCRYPTION_PROMPT = 0 CONFIG_FILE_ENCRYPTION_ENABLED = 1 diff --git a/config/config_encryption.go b/config/config_encryption.go index 65d1cab6..d51f55aa 100644 --- a/config/config_encryption.go +++ b/config/config_encryption.go @@ -41,7 +41,7 @@ func PromptForConfigKey() ([]byte, error) { var cryptoKey []byte for len(cryptoKey) != 32 { - fmt.Println("Enter password (32 characters):") + log.Println("Enter password (32 characters):") _, err := fmt.Scanln(&cryptoKey) if err != nil { @@ -49,7 +49,7 @@ func PromptForConfigKey() ([]byte, error) { } if len(cryptoKey) > 32 || len(cryptoKey) < 32 { - fmt.Println("Please re-enter password (32 characters):") + log.Println("Please re-enter password (32 characters):") } } nonce := make([]byte, 12) diff --git a/config/config_encryption_test.go b/config/config_encryption_test.go index 657ae28d..a194be37 100644 --- a/config/config_encryption_test.go +++ b/config/config_encryption_test.go @@ -27,7 +27,7 @@ func TestPromptForConfigKey(t *testing.T) { func TestEncryptDecryptConfigFile(t *testing.T) { //Dual function Test testKey := []byte("12345678901234567890123456789012") - testConfigData, err := common.ReadFile("../testdata/configtest.dat") + testConfigData, err := common.ReadFile(CONFIG_TEST_FILE) if err != nil { t.Errorf("Test failed. EncryptConfigFile: %s", err) } @@ -55,23 +55,24 @@ func TestEncryptDecryptConfigFile(t *testing.T) { //Dual function Test func TestConfirmJson(t *testing.T) { var result interface{} - testConfirmJson, err := common.ReadFile("../testdata/configtest.dat") + testConfirmJSON, err := common.ReadFile(CONFIG_TEST_FILE) if err != nil { - t.Errorf("Test failed. TestConfirmJson: %s", err) + t.Errorf("Test failed. testConfirmJSON: %s", err) } - err2 := ConfirmConfigJSON(testConfirmJson, &result) + + err2 := ConfirmConfigJSON(testConfirmJSON, &result) if err2 != nil { - t.Errorf("Test failed. TestConfirmJson: %s", err2) + t.Errorf("Test failed. testConfirmJSON: %s", err2) } if result == nil { - t.Errorf("Test failed. TestConfirmJson: Error Unmarshalling JSON") + t.Errorf("Test failed. testConfirmJSON: Error Unmarshalling JSON") } } func TestConfirmECS(t *testing.T) { t.Parallel() - ECStest := []byte("THORS-HAMMER") + ECStest := []byte(CONFIG_ENCRYPTION_CONFIRMATION_STRING) if !ConfirmECS(ECStest) { t.Errorf("Test failed. TestConfirmECS: Error finding ECS.") } @@ -80,7 +81,7 @@ func TestConfirmECS(t *testing.T) { func TestRemoveECS(t *testing.T) { t.Parallel() - ECStest := []byte("THORS-HAMMER") + ECStest := []byte(CONFIG_ENCRYPTION_CONFIRMATION_STRING) isremoved := RemoveECS(ECStest) if string(isremoved) != "" { diff --git a/config/config_test.go b/config/config_test.go index 57a5c608..12413d45 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -9,7 +9,7 @@ func TestGetConfigEnabledExchanges(t *testing.T) { defaultEnabledExchanges := 17 GetConfigEnabledExchanges := GetConfig() - err := GetConfigEnabledExchanges.LoadConfig("../testdata/configtest.dat") + err := GetConfigEnabledExchanges.LoadConfig(CONFIG_TEST_FILE) if err != nil { t.Error("Test failed. GetConfigEnabledExchanges load config error: " + err.Error()) } @@ -23,7 +23,7 @@ func TestGetExchangeConfig(t *testing.T) { t.Parallel() GetExchangeConfig := GetConfig() - err := GetExchangeConfig.LoadConfig("../testdata/configtest.dat") + err := GetExchangeConfig.LoadConfig(CONFIG_TEST_FILE) if err != nil { t.Errorf("Test failed. GetExchangeConfig.LoadConfig Error: %s", err.Error()) } @@ -37,7 +37,7 @@ func TestUpdateExchangeConfig(t *testing.T) { t.Parallel() UpdateExchangeConfig := GetConfig() - err := UpdateExchangeConfig.LoadConfig("../testdata/configtest.dat") + err := UpdateExchangeConfig.LoadConfig(CONFIG_TEST_FILE) if err != nil { t.Errorf("Test failed. UpdateExchangeConfig.LoadConfig Error: %s", err.Error()) } @@ -56,12 +56,12 @@ func TestCheckSMSGlobalConfigValues(t *testing.T) { t.Parallel() checkSMSGlobalConfigValues := GetConfig() - err := checkSMSGlobalConfigValues.LoadConfig("../testdata/configtest.dat") + err := checkSMSGlobalConfigValues.LoadConfig(CONFIG_TEST_FILE) if err != nil { t.Errorf("Test failed. checkSMSGlobalConfigValues.LoadConfig: %s", err) } err2 := checkSMSGlobalConfigValues.CheckSMSGlobalConfigValues() - if err2 == nil { + if err2 != nil { t.Error("Test failed. checkSMSGlobalConfigValues.CheckSMSGlobalConfigValues: Incorrect Return Value") } } @@ -70,7 +70,7 @@ func TestCheckExchangeConfigValues(t *testing.T) { t.Parallel() checkExchangeConfigValues := Config{} - err := checkExchangeConfigValues.LoadConfig("../testdata/configtest.dat") + err := checkExchangeConfigValues.LoadConfig(CONFIG_TEST_FILE) if err != nil { t.Errorf("Test failed. checkExchangeConfigValues.LoadConfig: %s", err.Error()) } @@ -85,7 +85,7 @@ func TestCheckWebserverConfigValues(t *testing.T) { t.Parallel() checkWebserverConfigValues := GetConfig() - err := checkWebserverConfigValues.LoadConfig("../testdata/configtest.dat") + err := checkWebserverConfigValues.LoadConfig(CONFIG_TEST_FILE) if err != nil { t.Errorf("Test failed. checkWebserverConfigValues.LoadConfig: %s", err.Error()) } @@ -99,7 +99,7 @@ func TestRetrieveConfigCurrencyPairs(t *testing.T) { t.Parallel() retrieveConfigCurrencyPairs := GetConfig() - err := retrieveConfigCurrencyPairs.LoadConfig("../testdata/configtest.dat") + err := retrieveConfigCurrencyPairs.LoadConfig(CONFIG_TEST_FILE) if err != nil { t.Errorf("Test failed. checkWebserverConfigValues.LoadConfig: %s", err.Error()) } @@ -113,7 +113,7 @@ func TestReadConfig(t *testing.T) { t.Parallel() readConfig := GetConfig() - err := readConfig.ReadConfig("../testdata/configtest.dat") + err := readConfig.ReadConfig(CONFIG_TEST_FILE) if err != nil { t.Error("Test failed. TestReadConfig " + err.Error()) } @@ -123,7 +123,7 @@ func TestLoadConfig(t *testing.T) { t.Parallel() loadConfig := GetConfig() - err := loadConfig.LoadConfig("../testdata/configtest.dat") + err := loadConfig.LoadConfig(CONFIG_TEST_FILE) if err != nil { t.Error("Test failed. TestLoadConfig " + err.Error()) } @@ -131,11 +131,11 @@ func TestLoadConfig(t *testing.T) { func TestSaveConfig(t *testing.T) { saveConfig := GetConfig() - err := saveConfig.LoadConfig("../testdata/configtest.dat") + err := saveConfig.LoadConfig(CONFIG_TEST_FILE) if err != nil { t.Errorf("Test failed. TestSaveConfig.LoadConfig: %s", err.Error()) } - err2 := saveConfig.SaveConfig("../testdata/configtest.dat") + err2 := saveConfig.SaveConfig(CONFIG_TEST_FILE) if err2 != nil { t.Errorf("Test failed. TestSaveConfig.SaveConfig, %s", err2.Error()) } diff --git a/events/events.go b/events/events.go index e5120129..082d6b28 100644 --- a/events/events.go +++ b/events/events.go @@ -24,7 +24,7 @@ const ( ACTION_SMS_NOTIFY = "SMS" ACTION_CONSOLE_PRINT = "CONSOLE_PRINT" ACTION_TEST = "ACTION_TEST" - CONFIG_PATH_TEST = "../testdata/configtest.dat" + CONFIG_PATH_TEST = config.CONFIG_TEST_FILE ) var ( diff --git a/exchanges/bitfinex/bitfinex_wrapper_test.go b/exchanges/bitfinex/bitfinex_wrapper_test.go index f0ecc51c..5a45809e 100644 --- a/exchanges/bitfinex/bitfinex_wrapper_test.go +++ b/exchanges/bitfinex/bitfinex_wrapper_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/thrasher-/gocryptotrader/config" + "github.com/thrasher-/gocryptotrader/currency/pair" ) func TestStart(t *testing.T) { @@ -18,7 +19,7 @@ func TestRun(t *testing.T) { func TestGetTickerPrice(t *testing.T) { getTickerPrice := Bitfinex{} - _, err := getTickerPrice.GetTickerPrice("BTCUSD") + _, err := getTickerPrice.GetTickerPrice(pair.NewCurrencyPair("BTC", "USD")) if err != nil { t.Errorf("Test Failed - Bitfinex GetTickerPrice() error: %s", err) } @@ -26,7 +27,7 @@ func TestGetTickerPrice(t *testing.T) { func TestGetOrderbookEx(t *testing.T) { getOrderBookEx := Bitfinex{} - _, err := getOrderBookEx.GetOrderbookEx("BTCUSD") + _, err := getOrderBookEx.GetOrderbookEx(pair.NewCurrencyPair("BTC", "USD")) if err != nil { t.Errorf("Test Failed - Bitfinex GetOrderbookEx() error: %s", err) } diff --git a/exchanges/exchange_test.go b/exchanges/exchange_test.go index 9b8a2ff4..69140897 100644 --- a/exchanges/exchange_test.go +++ b/exchanges/exchange_test.go @@ -69,7 +69,7 @@ func TestSetAPIKeys(t *testing.T) { func TestUpdateAvailableCurrencies(t *testing.T) { cfg := config.GetConfig() - err := cfg.LoadConfig("../testdata/configtest.dat") + err := cfg.LoadConfig(config.CONFIG_TEST_FILE) if err != nil { t.Log("SOMETHING DONE HAPPENED!") } diff --git a/exchanges/gdax/gdax_types.go b/exchanges/gdax/gdax_types.go index f5753172..61118d4f 100644 --- a/exchanges/gdax/gdax_types.go +++ b/exchanges/gdax/gdax_types.go @@ -91,7 +91,7 @@ type GDAXAccountLedgerResponse struct { Amount float64 `json:"amount,string"` Balance float64 `json:"balance,string"` Type string `json:"type"` - details interface{} `json:"details"` + Details interface{} `json:"details"` } type GDAXAccountHolds struct { @@ -156,7 +156,7 @@ type GDAXReportResponse struct { Params struct { StartDate string `json:"start_date"` EndDate string `json:"end_date"` - } `json:params"` + } `json:"params"` } type GDAXWebsocketSubscribe struct { diff --git a/exchanges/okcoin/okcoin_types.go b/exchanges/okcoin/okcoin_types.go index b8c338d3..b099e53b 100644 --- a/exchanges/okcoin/okcoin_types.go +++ b/exchanges/okcoin/okcoin_types.go @@ -104,7 +104,7 @@ type OKCoinFuturesExplosive struct { type OKCoinTrades struct { Amount float64 `json:"amount,string"` - Date int64 `json:"date` + Date int64 `json:"date"` DateMS int64 `json:"date_ms"` Price float64 `json:"price,string"` TradeID int64 `json:"tid"` diff --git a/exchanges/ticker/ticker.go b/exchanges/ticker/ticker.go index 6703f63f..576e13d7 100644 --- a/exchanges/ticker/ticker.go +++ b/exchanges/ticker/ticker.go @@ -5,7 +5,6 @@ import ( "strconv" "github.com/thrasher-/gocryptotrader/common" - "github.com/thrasher-/gocryptotrader/currency/pair" ) diff --git a/exchanges/ticker/ticker_test.go b/exchanges/ticker/ticker_test.go index 281715a2..9db6ba69 100644 --- a/exchanges/ticker/ticker_test.go +++ b/exchanges/ticker/ticker_test.go @@ -3,48 +3,50 @@ package ticker import ( "reflect" "testing" + + "github.com/thrasher-/gocryptotrader/currency/pair" ) func TestPriceToString(t *testing.T) { t.Parallel() + newPair := pair.NewCurrencyPair("BTC", "USD") priceStruct := TickerPrice{ - FirstCurrency: "BTC", - SecondCurrency: "USD", - CurrencyPair: "BTCUSD", - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, + Pair: newPair, + CurrencyPair: newPair.Pair().String(), + Last: 1200, + High: 1298, + Low: 1148, + Bid: 1195, + Ask: 1220, + Volume: 5, + PriceATH: 1337, } - newTicker := CreateNewTicker("ANX", "BTC", "USD", priceStruct) + newTicker := CreateNewTicker("ANX", newPair, priceStruct) - if newTicker.PriceToString("BTC", "USD", "last") != "1200" { + if newTicker.PriceToString(newPair, "last") != "1200" { t.Error("Test Failed - ticker PriceToString last value is incorrect") } - if newTicker.PriceToString("BTC", "USD", "high") != "1298" { + if newTicker.PriceToString(newPair, "high") != "1298" { t.Error("Test Failed - ticker PriceToString high value is incorrect") } - if newTicker.PriceToString("BTC", "USD", "low") != "1148" { + if newTicker.PriceToString(newPair, "low") != "1148" { t.Error("Test Failed - ticker PriceToString low value is incorrect") } - if newTicker.PriceToString("BTC", "USD", "bid") != "1195" { + if newTicker.PriceToString(newPair, "bid") != "1195" { t.Error("Test Failed - ticker PriceToString bid value is incorrect") } - if newTicker.PriceToString("BTC", "USD", "ask") != "1220" { + if newTicker.PriceToString(newPair, "ask") != "1220" { t.Error("Test Failed - ticker PriceToString ask value is incorrect") } - if newTicker.PriceToString("BTC", "USD", "volume") != "5" { + if newTicker.PriceToString(newPair, "volume") != "5" { t.Error("Test Failed - ticker PriceToString volume value is incorrect") } - if newTicker.PriceToString("BTC", "USD", "ath") != "1337" { + if newTicker.PriceToString(newPair, "ath") != "1337" { t.Error("Test Failed - ticker PriceToString ath value is incorrect") } - if newTicker.PriceToString("BTC", "USD", "obtuse") != "" { + if newTicker.PriceToString(newPair, "obtuse") != "" { t.Error("Test Failed - ticker PriceToString obtuse value is incorrect") } } @@ -52,23 +54,23 @@ func TestPriceToString(t *testing.T) { func TestGetTicker(t *testing.T) { t.Parallel() + newPair := pair.NewCurrencyPair("BTC", "USD") priceStruct := TickerPrice{ - FirstCurrency: "BTC", - SecondCurrency: "USD", - CurrencyPair: "BTCUSD", - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, + Pair: newPair, + CurrencyPair: newPair.Pair().String(), + Last: 1200, + High: 1298, + Low: 1148, + Bid: 1195, + Ask: 1220, + Volume: 5, + PriceATH: 1337, } - bitfinexTicker := CreateNewTicker("bitfinex", "BTC", "USD", priceStruct) + bitfinexTicker := CreateNewTicker("bitfinex", newPair, priceStruct) Tickers = append(Tickers, bitfinexTicker) - tickerPrice, err := GetTicker("bitfinex", "BTC", "USD") + tickerPrice, err := GetTicker("bitfinex", newPair) if err != nil { t.Errorf("Test Failed - Ticker GetTicker init error: %s", err) } @@ -80,20 +82,20 @@ func TestGetTicker(t *testing.T) { func TestGetTickerByExchange(t *testing.T) { t.Parallel() + newPair := pair.NewCurrencyPair("BTC", "USD") priceStruct := TickerPrice{ - FirstCurrency: "BTC", - SecondCurrency: "USD", - CurrencyPair: "BTCUSD", - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, + Pair: newPair, + CurrencyPair: newPair.Pair().String(), + Last: 1200, + High: 1298, + Low: 1148, + Bid: 1195, + Ask: 1220, + Volume: 5, + PriceATH: 1337, } - anxTicker := CreateNewTicker("ANX", "BTC", "USD", priceStruct) + anxTicker := CreateNewTicker("ANX", newPair, priceStruct) Tickers = append(Tickers, anxTicker) tickerPtr, err := GetTickerByExchange("ANX") @@ -108,20 +110,20 @@ func TestGetTickerByExchange(t *testing.T) { func TestFirstCurrencyExists(t *testing.T) { t.Parallel() + newPair := pair.NewCurrencyPair("BTC", "USD") priceStruct := TickerPrice{ - FirstCurrency: "BTC", - SecondCurrency: "USD", - CurrencyPair: "BTCUSD", - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, + Pair: newPair, + CurrencyPair: newPair.Pair().String(), + Last: 1200, + High: 1298, + Low: 1148, + Bid: 1195, + Ask: 1220, + Volume: 5, + PriceATH: 1337, } - alphaTicker := CreateNewTicker("alphapoint", "BTC", "USD", priceStruct) + alphaTicker := CreateNewTicker("alphapoint", newPair, priceStruct) Tickers = append(Tickers, alphaTicker) if !FirstCurrencyExists("alphapoint", "BTC") { @@ -135,26 +137,28 @@ func TestFirstCurrencyExists(t *testing.T) { func TestSecondCurrencyExists(t *testing.T) { t.Parallel() + newPair := pair.NewCurrencyPair("BTC", "USD") priceStruct := TickerPrice{ - FirstCurrency: "BTC", - SecondCurrency: "USD", - CurrencyPair: "BTCUSD", - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, + Pair: newPair, + CurrencyPair: newPair.Pair().String(), + Last: 1200, + High: 1298, + Low: 1148, + Bid: 1195, + Ask: 1220, + Volume: 5, + PriceATH: 1337, } - bitstampTicker := CreateNewTicker("bitstamp", "BTC", "USD", priceStruct) + bitstampTicker := CreateNewTicker("bitstamp", newPair, priceStruct) Tickers = append(Tickers, bitstampTicker) - if !SecondCurrencyExists("bitstamp", "BTC", "USD") { + if !SecondCurrencyExists("bitstamp", newPair) { t.Error("Test Failed - SecondCurrencyExists1 value return is incorrect") } - if SecondCurrencyExists("bitstamp", "BTC", "DOGS") { + + newPair.SecondCurrency = "DOGS" + if SecondCurrencyExists("bitstamp", newPair) { t.Error("Test Failed - SecondCurrencyExists2 value return is incorrect") } } @@ -162,20 +166,20 @@ func TestSecondCurrencyExists(t *testing.T) { func TestCreateNewTicker(t *testing.T) { t.Parallel() + newPair := pair.NewCurrencyPair("BTC", "USD") priceStruct := TickerPrice{ - FirstCurrency: "BTC", - SecondCurrency: "USD", - CurrencyPair: "BTCUSD", - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, + Pair: newPair, + CurrencyPair: newPair.Pair().String(), + Last: 1200, + High: 1298, + Low: 1148, + Bid: 1195, + Ask: 1220, + Volume: 5, + PriceATH: 1337, } - newTicker := CreateNewTicker("ANX", "BTC", "USD", priceStruct) + newTicker := CreateNewTicker("ANX", newPair, priceStruct) if reflect.ValueOf(newTicker).NumField() != 2 { t.Error("Test Failed - ticker CreateNewTicker struct change/or updated") @@ -187,6 +191,9 @@ func TestCreateNewTicker(t *testing.T) { t.Error("Test Failed - ticker CreateNewTicker.ExchangeName value is not ANX") } + if newTicker.Price["BTC"]["USD"].Pair.Pair().String() != "BTCUSD" { + t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Pair.Pair().String() value is not expected 'BTCUSD'") + } if reflect.TypeOf(newTicker.Price["BTC"]["USD"].Ask).String() != "float64" { t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Ask value is not a float64") } @@ -196,9 +203,6 @@ func TestCreateNewTicker(t *testing.T) { if reflect.TypeOf(newTicker.Price["BTC"]["USD"].CurrencyPair).String() != "string" { t.Error("Test Failed - ticker newTicker.Price[BTC][USD].CurrencyPair value is not a string") } - if reflect.TypeOf(newTicker.Price["BTC"]["USD"].FirstCurrency).String() != "string" { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].FirstCurrency value is not a string") - } if reflect.TypeOf(newTicker.Price["BTC"]["USD"].High).String() != "float64" { t.Error("Test Failed - ticker newTicker.Price[BTC][USD].High value is not a float64") } @@ -211,9 +215,6 @@ func TestCreateNewTicker(t *testing.T) { if reflect.TypeOf(newTicker.Price["BTC"]["USD"].PriceATH).String() != "float64" { t.Error("Test Failed - ticker newTicker.Price[BTC][USD].PriceATH value is not a float64") } - if reflect.TypeOf(newTicker.Price["BTC"]["USD"].SecondCurrency).String() != "string" { - t.Error("Test Failed - ticker newTicker.Price[BTC][USD].SecondCurrency value is not a string") - } if reflect.TypeOf(newTicker.Price["BTC"]["USD"].Volume).String() != "float64" { t.Error("Test Failed - ticker newTicker.Price[BTC][USD].Volume value is not a float64") } @@ -222,18 +223,18 @@ func TestCreateNewTicker(t *testing.T) { func TestProcessTicker(t *testing.T) { //non-appending function to tickers t.Parallel() + newPair := pair.NewCurrencyPair("BTC", "USD") priceStruct := TickerPrice{ - FirstCurrency: "BTC", - SecondCurrency: "USD", - CurrencyPair: "BTCUSD", - Last: 1200, - High: 1298, - Low: 1148, - Bid: 1195, - Ask: 1220, - Volume: 5, - PriceATH: 1337, + Pair: newPair, + CurrencyPair: newPair.Pair().String(), + Last: 1200, + High: 1298, + Low: 1148, + Bid: 1195, + Ask: 1220, + Volume: 5, + PriceATH: 1337, } - ProcessTicker("btcc", "BTC", "USD", priceStruct) + ProcessTicker("btcc", newPair, priceStruct) } diff --git a/main.go b/main.go index 7e65dbde..0fe9af7d 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - // "github.com/gorilla/mux" "log" "net/http" "os" diff --git a/smsglobal/smsglobal_test.go b/smsglobal/smsglobal_test.go index dbbdcc18..288cced3 100644 --- a/smsglobal/smsglobal_test.go +++ b/smsglobal/smsglobal_test.go @@ -8,7 +8,7 @@ import ( func TestGetEnabledSMSContacts(t *testing.T) { cfg := config.GetConfig() - err := cfg.LoadConfig("../testdata/configtest.dat") + err := cfg.LoadConfig(config.CONFIG_TEST_FILE) if err != nil { t.Errorf("Test Failed. GetEnabledSMSContacts: \nFunction return is incorrect with, %s.", err) } @@ -21,7 +21,7 @@ func TestGetEnabledSMSContacts(t *testing.T) { func TestSMSSendToAll(t *testing.T) { cfg := config.GetConfig() - err := cfg.LoadConfig("../testdata/configtest.dat") + err := cfg.LoadConfig(config.CONFIG_TEST_FILE) if err != nil { t.Errorf("Test Failed. SMSSendToAll: \nFunction return is incorrect with, %s.", err) } @@ -31,7 +31,7 @@ func TestSMSSendToAll(t *testing.T) { func TestSMSGetNumberByName(t *testing.T) { cfg := config.GetConfig() - err := cfg.LoadConfig("../testdata/configtest.dat") + err := cfg.LoadConfig(config.CONFIG_TEST_FILE) if err != nil { t.Errorf("Test Failed. SMSGetNumberByName: \nFunction return is incorrect with, %s.", err) } @@ -43,7 +43,7 @@ func TestSMSGetNumberByName(t *testing.T) { func TestSMSNotify(t *testing.T) { cfg := config.GetConfig() - err := cfg.LoadConfig("../testdata/configtest.dat") + err := cfg.LoadConfig(config.CONFIG_TEST_FILE) if err != nil { t.Errorf("Test Failed. SMSNotify: \nFunction return is incorrect with, %s.", err) } diff --git a/testdata/configtest.dat b/testdata/configtest.dat index 10d9ed16..a30244a5 100644 --- a/testdata/configtest.dat +++ b/testdata/configtest.dat @@ -7,22 +7,26 @@ { "Address": "1JCe8z4jJVNXSjohjM4i9Hh813dLCNx2Sy", "CoinType": "BTC", - "Balance": 124178.0002442 + "Balance": 124178.0002442, + "Decscription": "" }, { "Address": "3Nxwenay9Z8Lc9JBiywExpnEFiLp6Afp8v", "CoinType": "BTC", - "Balance": 103439.83659727 + "Balance": 103439.83659727, + "Decscription": "" }, { "Address": "LgY8ahfHRhvjVQC1zJnBhFMG5pCTMuKRqh", "CoinType": "LTC", - "Balance": 3000000.05 + "Balance": 3.00000005e+06, + "Decscription": "" }, { "Address": "0xb794f5ea0ba39494ce839613fffba74279579268", "CoinType": "ETH", - "Balance": 5774999.820458524 + "Balance": 5.774999820458524e+06, + "Decscription": "" } ] },