Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thrasher- committed Apr 21, 2017
1 parent fb6d966 commit 77ca9cc
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 146 deletions.
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions config/config_encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ 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 {
return nil, err
}

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)
Expand Down
17 changes: 9 additions & 8 deletions config/config_encryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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.")
}
Expand All @@ -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) != "" {
Expand Down
24 changes: 12 additions & 12 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand All @@ -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())
}
Expand All @@ -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())
}
Expand All @@ -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")
}
}
Expand All @@ -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())
}
Expand All @@ -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())
}
Expand All @@ -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())
}
Expand All @@ -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())
}
Expand All @@ -123,19 +123,19 @@ 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())
}
}

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())
}
Expand Down
2 changes: 1 addition & 1 deletion events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
5 changes: 3 additions & 2 deletions exchanges/bitfinex/bitfinex_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/pair"
)

func TestStart(t *testing.T) {
Expand All @@ -18,15 +19,15 @@ 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)
}
}

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)
}
Expand Down
2 changes: 1 addition & 1 deletion exchanges/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
}
Expand Down
4 changes: 2 additions & 2 deletions exchanges/gdax/gdax_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion exchanges/okcoin/okcoin_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 0 additions & 1 deletion exchanges/ticker/ticker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strconv"

"github.com/thrasher-/gocryptotrader/common"

"github.com/thrasher-/gocryptotrader/currency/pair"
)

Expand Down
Loading

0 comments on commit 77ca9cc

Please sign in to comment.