mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Improvement: Speeding up slow tests (#707)
* 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
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/config"
|
||||
)
|
||||
@@ -165,8 +166,15 @@ func TestStartStopTwoDoesNotCausePanic(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCheckExchangeExists(t *testing.T) {
|
||||
e := CreateTestBot(t)
|
||||
|
||||
t.Parallel()
|
||||
em := SetupExchangeManager()
|
||||
exch, err := em.NewExchangeByName(testExchange)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received '%v' expected '%v'", err, nil)
|
||||
}
|
||||
exch.SetDefaults()
|
||||
em.Add(exch)
|
||||
e := &Engine{ExchangeManager: em}
|
||||
if e.GetExchangeByName(testExchange) == nil {
|
||||
t.Errorf("TestGetExchangeExists: Unable to find exchange")
|
||||
}
|
||||
@@ -177,12 +185,16 @@ func TestCheckExchangeExists(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetExchangeByName(t *testing.T) {
|
||||
e := CreateTestBot(t)
|
||||
|
||||
exch := e.GetExchangeByName(testExchange)
|
||||
if exch == nil {
|
||||
t.Errorf("TestGetExchangeByName: Failed to get exchange")
|
||||
t.Parallel()
|
||||
em := SetupExchangeManager()
|
||||
exch, err := em.NewExchangeByName(testExchange)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received '%v' expected '%v'", err, nil)
|
||||
}
|
||||
exch.SetDefaults()
|
||||
exch.SetEnabled(true)
|
||||
em.Add(exch)
|
||||
e := &Engine{ExchangeManager: em}
|
||||
|
||||
if !exch.IsEnabled() {
|
||||
t.Errorf("TestGetExchangeByName: Unexpected result")
|
||||
@@ -205,9 +217,19 @@ func TestGetExchangeByName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUnloadExchange(t *testing.T) {
|
||||
e := CreateTestBot(t)
|
||||
|
||||
err := e.UnloadExchange("asdf")
|
||||
t.Parallel()
|
||||
em := SetupExchangeManager()
|
||||
exch, err := em.NewExchangeByName(testExchange)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received '%v' expected '%v'", err, nil)
|
||||
}
|
||||
exch.SetDefaults()
|
||||
exch.SetEnabled(true)
|
||||
em.Add(exch)
|
||||
e := &Engine{ExchangeManager: em,
|
||||
Config: &config.Config{Exchanges: []config.ExchangeConfig{{Name: testExchange}}},
|
||||
}
|
||||
err = e.UnloadExchange("asdf")
|
||||
if !errors.Is(err, config.ErrExchangeNotFound) {
|
||||
t.Errorf("error '%v', expected '%v'", err, config.ErrExchangeNotFound)
|
||||
}
|
||||
@@ -225,30 +247,29 @@ func TestUnloadExchange(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDryRunParamInteraction(t *testing.T) {
|
||||
bot := CreateTestBot(t)
|
||||
|
||||
// Simulate overiding default settings and ensure that enabling exchange
|
||||
// verbose mode will be set on Bitfinex
|
||||
var err error
|
||||
if err = bot.UnloadExchange(testExchange); err != nil {
|
||||
t.Parallel()
|
||||
bot := &Engine{
|
||||
ExchangeManager: SetupExchangeManager(),
|
||||
Settings: Settings{},
|
||||
Config: &config.Config{
|
||||
Exchanges: []config.ExchangeConfig{
|
||||
{
|
||||
Name: testExchange,
|
||||
WebsocketTrafficTimeout: time.Second,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := bot.LoadExchange(testExchange, false, nil); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
bot.Settings.CheckParamInteraction = false
|
||||
bot.Settings.EnableExchangeVerbose = false
|
||||
if err = bot.LoadExchange(testExchange, false, nil); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
exchCfg, err := bot.Config.GetExchangeConfig(testExchange)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if exchCfg.Verbose {
|
||||
t.Error("verbose should have been disabled")
|
||||
}
|
||||
|
||||
if err = bot.UnloadExchange(testExchange); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -267,7 +288,6 @@ func TestDryRunParamInteraction(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if !bot.Settings.EnableDryRun ||
|
||||
!exchCfg.Verbose {
|
||||
t.Error("dryrun should be true and verbose should be true")
|
||||
|
||||
Reference in New Issue
Block a user