mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 07:26:48 +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
232 lines
4.9 KiB
Go
232 lines
4.9 KiB
Go
package bittrex
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/thrasher-/gocryptotrader/config"
|
|
)
|
|
|
|
// Please supply you own test keys here to run better tests.
|
|
const (
|
|
apiKey = "Testy"
|
|
apiSecret = "TestyTesty"
|
|
)
|
|
|
|
var b Bittrex
|
|
|
|
func TestSetDefaults(t *testing.T) {
|
|
b.SetDefaults()
|
|
if b.GetName() != "Bittrex" {
|
|
t.Error("Test Failed - Bittrex - SetDefaults() error")
|
|
}
|
|
}
|
|
|
|
func TestSetup(t *testing.T) {
|
|
cfg := config.GetConfig()
|
|
cfg.LoadConfig("../../testdata/configtest.json")
|
|
bConfig, err := cfg.GetExchangeConfig("Bittrex")
|
|
if err != nil {
|
|
t.Error("Test Failed - Bittrex Setup() init error")
|
|
}
|
|
|
|
b.Setup(bConfig)
|
|
|
|
if !b.IsEnabled() || b.AuthenticatedAPISupport ||
|
|
b.RESTPollingDelay != time.Duration(10) || b.Verbose ||
|
|
b.Websocket.IsEnabled() || len(b.BaseCurrencies) < 1 ||
|
|
len(b.AvailablePairs) < 1 || len(b.EnabledPairs) < 1 {
|
|
t.Error("Test Failed - Bittrex Setup values not set correctly")
|
|
}
|
|
}
|
|
|
|
func TestGetMarkets(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := b.GetMarkets()
|
|
if err != nil {
|
|
t.Errorf("Test Failed - Bittrex - GetMarkets() error: %s", err)
|
|
}
|
|
}
|
|
|
|
func TestGetCurrencies(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := b.GetCurrencies()
|
|
if err != nil {
|
|
t.Errorf("Test Failed - Bittrex - GetCurrencies() error: %s", err)
|
|
}
|
|
}
|
|
|
|
func TestGetTicker(t *testing.T) {
|
|
t.Parallel()
|
|
btc := "btc-ltc"
|
|
|
|
_, err := b.GetTicker(btc)
|
|
if err != nil {
|
|
t.Errorf("Test Failed - Bittrex - GetTicker() error: %s", err)
|
|
}
|
|
}
|
|
|
|
func TestGetMarketSummaries(t *testing.T) {
|
|
t.Parallel()
|
|
_, err := b.GetMarketSummaries()
|
|
if err != nil {
|
|
t.Errorf("Test Failed - Bittrex - GetMarketSummaries() error: %s", err)
|
|
}
|
|
}
|
|
|
|
func TestGetMarketSummary(t *testing.T) {
|
|
t.Parallel()
|
|
pairOne := "BTC-LTC"
|
|
|
|
_, err := b.GetMarketSummary(pairOne)
|
|
if err != nil {
|
|
t.Errorf("Test Failed - Bittrex - GetMarketSummary() error: %s", err)
|
|
}
|
|
}
|
|
|
|
func TestGetOrderbook(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.GetOrderbook("btc-ltc")
|
|
if err != nil {
|
|
t.Errorf("Test Failed - Bittrex - GetOrderbook() error: %s", err)
|
|
}
|
|
}
|
|
|
|
func TestGetMarketHistory(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.GetMarketHistory("btc-ltc")
|
|
if err != nil {
|
|
t.Errorf("Test Failed - Bittrex - GetMarketHistory() error: %s", err)
|
|
}
|
|
}
|
|
|
|
func TestPlaceBuyLimit(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.PlaceBuyLimit("btc-ltc", 1, 1)
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - PlaceBuyLimit() error")
|
|
}
|
|
}
|
|
|
|
func TestPlaceSellLimit(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.PlaceSellLimit("btc-ltc", 1, 1)
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - PlaceSellLimit() error")
|
|
}
|
|
}
|
|
|
|
func TestGetOpenOrders(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.GetOpenOrders("")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetOrder() error")
|
|
}
|
|
_, err = b.GetOpenOrders("btc-ltc")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetOrder() error")
|
|
}
|
|
}
|
|
|
|
func TestCancelOrder(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.CancelOrder("blaaaaaaa")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - CancelOrder() error")
|
|
}
|
|
}
|
|
|
|
func TestGetAccountBalances(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.GetAccountBalances()
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetAccountBalances() error")
|
|
}
|
|
}
|
|
|
|
func TestGetAccountBalanceByCurrency(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.GetAccountBalanceByCurrency("btc")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetAccountBalanceByCurrency() error")
|
|
}
|
|
}
|
|
|
|
func TestGetDepositAddress(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.GetDepositAddress("btc")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetDepositAddress() error")
|
|
}
|
|
}
|
|
|
|
func TestWithdraw(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.Withdraw("btc", "something", "someplace", 1)
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - Withdraw() error")
|
|
}
|
|
}
|
|
|
|
func TestGetOrder(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.GetOrder("0cb4c4e4-bdc7-4e13-8c13-430e587d2cc1")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetOrder() error")
|
|
}
|
|
_, err = b.GetOrder("")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetOrder() error")
|
|
}
|
|
}
|
|
|
|
func TestGetOrderHistory(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.GetOrderHistory("")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetOrderHistory() error")
|
|
}
|
|
_, err = b.GetOrderHistory("btc-ltc")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetOrderHistory() error")
|
|
}
|
|
}
|
|
|
|
func TestGetwithdrawalHistory(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.GetWithdrawalHistory("")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetWithdrawalHistory() error")
|
|
}
|
|
_, err = b.GetWithdrawalHistory("btc-ltc")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetWithdrawalHistory() error")
|
|
}
|
|
}
|
|
|
|
func TestGetDepositHistory(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := b.GetDepositHistory("")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetDepositHistory() error")
|
|
}
|
|
_, err = b.GetDepositHistory("btc-ltc")
|
|
if err == nil {
|
|
t.Error("Test Failed - Bittrex - GetDepositHistory() error")
|
|
}
|
|
}
|