mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-07 07:26:48 +00:00
Various fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) != "" {
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user