mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 23:16:52 +00:00
* Initial overhaul of websocket connection and feeds * Added proxy support * Piped to routines.go * Added new websocket file in exchanges Refactored orderbook handling into exchange_websocket.go Added better error responses for binance_websocket.go General clean for binance_websocket.go * General fixes - bitfinex_websocket.go Refactored orderbook cache code - bitfinex_websocket.go Removed fatal error with unhandled type - routines.go * Added general improvements to bitmex_websocket.go Refactored orderbook handling to exchange_websocket.go Added variable in Item struct in orderbook.go for looking up orders by ID * Fix issue when routines are blocked due to Data Handler not started Updated traffic handler General fixes for bitstamp_websocket.go * General fixes for coinbasepro_websocket.go * General fixes for coinut_websocket.go Fixed error return in exchange_websocket.go * Removed comments in coinut_wrapper.go Refactor orderbook logic from hitbtc_websocket.go to exchange_websocket.go * General fixes * Removed comments General fixes * Updated routines.go * After rebase fix * Fixed update config pairs in okcoin.go * fixed config currency issue in okcoin.go for okcoin China * exchange_websocket.go *Removed unused const dec *Removed state change routine *Improved trafficMonitor routine *Increased verbosity for error returns *Removed uneeded mutex locks exchange_websocket_test.go *Added new tests for websocket and orderbook updating routines.go *Removed string cased * Fixed race conditions on sync.waitgroup in exchanges_websocket.go * Changes variable name in config.go * Removes unnecessary comment * Removes indefinite lock on error return * Removes unnecessary comment * Adds support for BTCC websocket Drops support for BTCC REST * Rewords comment in exchange_websocket.go Moves types to poloniex_types.go * Moves types to coinut_types.go * Removes uneeded range for accessing array variables for coinbase_websocket.go Removes comments in coinut_types.go * Adds verbosity flag to GCT Suppresses verbose output from routines.go * Fixes setting proxy for REST and Websocket per exchange Upgrades error handling Drops unused *url.Url variable in exchange type * Adds test for setting proxy * Fixes bug that closes connection due to incorrect timeout time through a proxy connection * Clarify verbose flag message
135 lines
3.5 KiB
Go
135 lines
3.5 KiB
Go
package anx
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/thrasher-/gocryptotrader/config"
|
|
)
|
|
|
|
var anx ANX
|
|
|
|
func TestSetDefaults(t *testing.T) {
|
|
anx.SetDefaults()
|
|
|
|
if anx.Name != "ANX" {
|
|
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
|
|
}
|
|
if anx.Enabled != false {
|
|
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
|
|
}
|
|
if anx.TakerFee != 0.6 {
|
|
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
|
|
}
|
|
if anx.MakerFee != 0.3 {
|
|
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
|
|
}
|
|
if anx.Verbose != false {
|
|
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
|
|
}
|
|
if anx.Websocket.IsEnabled() != false {
|
|
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
|
|
}
|
|
if anx.RESTPollingDelay != 10 {
|
|
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
|
|
}
|
|
}
|
|
|
|
func TestSetup(t *testing.T) {
|
|
anxSetupConfig := config.GetConfig()
|
|
anxSetupConfig.LoadConfig("../../testdata/configtest.json")
|
|
anxConfig, err := anxSetupConfig.GetExchangeConfig("ANX")
|
|
if err != nil {
|
|
t.Error("Test Failed - ANX Setup() init error")
|
|
}
|
|
anx.Setup(anxConfig)
|
|
|
|
if anx.Enabled != true {
|
|
t.Error("Test Failed - ANX Setup() incorrect values set")
|
|
}
|
|
if anx.AuthenticatedAPISupport != false {
|
|
t.Error("Test Failed - ANX Setup() incorrect values set")
|
|
}
|
|
if len(anx.APIKey) != 0 {
|
|
t.Error("Test Failed - ANX Setup() incorrect values set")
|
|
}
|
|
if len(anx.APISecret) != 0 {
|
|
t.Error("Test Failed - ANX Setup() incorrect values set")
|
|
}
|
|
if anx.RESTPollingDelay != 10 {
|
|
t.Error("Test Failed - ANX Setup() incorrect values set")
|
|
}
|
|
if anx.Verbose != false {
|
|
t.Error("Test Failed - ANX Setup() incorrect values set")
|
|
}
|
|
if anx.Websocket.IsEnabled() != false {
|
|
t.Error("Test Failed - ANX Setup() incorrect values set")
|
|
}
|
|
if len(anx.BaseCurrencies) <= 0 {
|
|
t.Error("Test Failed - ANX Setup() incorrect values set")
|
|
}
|
|
if len(anx.AvailablePairs) <= 0 {
|
|
t.Error("Test Failed - ANX Setup() incorrect values set")
|
|
}
|
|
if len(anx.EnabledPairs) <= 0 {
|
|
t.Error("Test Failed - ANX Setup() incorrect values set")
|
|
}
|
|
}
|
|
|
|
func TestGetCurrencies(t *testing.T) {
|
|
_, err := anx.GetCurrencies()
|
|
if err != nil {
|
|
t.Fatalf("Test failed. TestGetCurrencies failed. Err: %s", err)
|
|
}
|
|
}
|
|
|
|
func TestGetTradablePairs(t *testing.T) {
|
|
_, err := anx.GetTradablePairs()
|
|
if err != nil {
|
|
t.Fatalf("Test failed. TestGetTradablePairs failed. Err: %s", err)
|
|
}
|
|
}
|
|
|
|
func TestGetFee(t *testing.T) {
|
|
makerFeeExpected, takerFeeExpected := 0.3, 0.6
|
|
|
|
if anx.GetFee(true) != makerFeeExpected {
|
|
t.Error("Test Failed - ANX GetFee() incorrect return value")
|
|
}
|
|
if anx.GetFee(false) != takerFeeExpected {
|
|
t.Error("Test Failed - ANX GetFee() incorrect return value")
|
|
}
|
|
}
|
|
|
|
func TestGetTicker(t *testing.T) {
|
|
ticker, err := anx.GetTicker("BTCUSD")
|
|
if err != nil {
|
|
t.Errorf("Test Failed - ANX GetTicker() error: %s", err)
|
|
}
|
|
if ticker.Result != "success" {
|
|
t.Error("Test Failed - ANX GetTicker() unsuccessful")
|
|
}
|
|
}
|
|
|
|
func TestGetDepth(t *testing.T) {
|
|
ticker, err := anx.GetDepth("BTCUSD")
|
|
if err != nil {
|
|
t.Errorf("Test Failed - ANX GetDepth() error: %s", err)
|
|
}
|
|
if ticker.Result != "success" {
|
|
t.Error("Test Failed - ANX GetDepth() unsuccessful")
|
|
}
|
|
}
|
|
|
|
func TestGetAPIKey(t *testing.T) {
|
|
apiKey, apiSecret, err := anx.GetAPIKey("userName", "passWord", "", "1337")
|
|
if err == nil {
|
|
t.Error("Test Failed - ANX GetAPIKey() Incorrect")
|
|
}
|
|
if apiKey != "" {
|
|
t.Error("Test Failed - ANX GetAPIKey() Incorrect")
|
|
}
|
|
if apiSecret != "" {
|
|
t.Error("Test Failed - ANX GetAPIKey() Incorrect")
|
|
}
|
|
}
|