mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 15:10:13 +00:00
* Speeds up tests * Reduces time.Sleeps, lowers CreateTestBot complexity. Breaks things * Removal of unecessary config reads. Parallel tests. Lower times * Speeds up recent trades results * mini update * zoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooom * Removes the dupes * Lint * post cherrypick * Fix rare kraken data race * Fixes banking global issues. Fixes postgres trades * rmline for appveyor test * Expands timeout in event that channel is closed before send * Fix data race * No rows, no bows and definitely no shows * Removes parallel from createsnapshot tests * Extends timedmutext test a smidge. Exchange fatality * Shorter end timeframe and bigger candle
82 lines
2.1 KiB
Go
82 lines
2.1 KiB
Go
package engine
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/bitfinex"
|
|
)
|
|
|
|
func TestSetupExchangeManager(t *testing.T) {
|
|
t.Parallel()
|
|
m := SetupExchangeManager()
|
|
if m == nil {
|
|
t.Fatalf("unexpected response")
|
|
}
|
|
if m.exchanges == nil {
|
|
t.Error("unexpected response")
|
|
}
|
|
}
|
|
|
|
func TestExchangeManagerAdd(t *testing.T) {
|
|
t.Parallel()
|
|
m := SetupExchangeManager()
|
|
b := new(bitfinex.Bitfinex)
|
|
b.SetDefaults()
|
|
m.Add(b)
|
|
if exch := m.GetExchanges(); exch[0].GetName() != "Bitfinex" {
|
|
t.Error("unexpected exchange name")
|
|
}
|
|
}
|
|
|
|
func TestExchangeManagerGetExchanges(t *testing.T) {
|
|
t.Parallel()
|
|
m := SetupExchangeManager()
|
|
if exchanges := m.GetExchanges(); exchanges != nil {
|
|
t.Error("unexpected value")
|
|
}
|
|
b := new(bitfinex.Bitfinex)
|
|
b.SetDefaults()
|
|
m.Add(b)
|
|
if exch := m.GetExchanges(); exch[0].GetName() != "Bitfinex" {
|
|
t.Error("unexpected exchange name")
|
|
}
|
|
}
|
|
|
|
func TestExchangeManagerRemoveExchange(t *testing.T) {
|
|
t.Parallel()
|
|
m := SetupExchangeManager()
|
|
if err := m.RemoveExchange("Bitfinex"); err != ErrNoExchangesLoaded {
|
|
t.Error("no exchanges should be loaded")
|
|
}
|
|
b := new(bitfinex.Bitfinex)
|
|
b.SetDefaults()
|
|
m.Add(b)
|
|
if err := m.RemoveExchange("Bitstamp"); err != ErrExchangeNotFound {
|
|
t.Error("Bitstamp exchange should return an error")
|
|
}
|
|
if err := m.RemoveExchange("BiTFiNeX"); err != nil {
|
|
t.Error("exchange should have been removed")
|
|
}
|
|
if m.Len() != 0 {
|
|
t.Error("exchange manager len should be 0")
|
|
}
|
|
}
|
|
|
|
func TestNewExchangeByName(t *testing.T) {
|
|
m := SetupExchangeManager()
|
|
exchanges := []string{"binance", "bitfinex", "bitflyer", "bithumb", "bitmex", "bitstamp", "bittrex", "btc markets", "btse", "coinbene", "coinut", "exmo", "coinbasepro", "ftx", "gateio", "gemini", "hitbtc", "huobi", "itbit", "kraken", "lakebtc", "lbank", "localbitcoins", "okcoin international", "okex", "poloniex", "yobit", "zb", "fake"}
|
|
for i := range exchanges {
|
|
exch, err := m.NewExchangeByName(exchanges[i])
|
|
if err != nil && exchanges[i] != "fake" {
|
|
t.Fatal(err)
|
|
}
|
|
if err == nil {
|
|
exch.SetDefaults()
|
|
if !strings.EqualFold(exch.GetName(), exchanges[i]) {
|
|
t.Error("did not load expected exchange")
|
|
}
|
|
}
|
|
}
|
|
}
|