Skip to content

Commit

Permalink
GCTWrapper: Improve TestMain clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Nov 27, 2024
1 parent 8ebcd96 commit dbb679e
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions gctscript/wrappers/gct/gctwrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,41 @@ func TestMain(m *testing.M) {
var err error
engine.Bot, err = engine.NewFromSettings(&settings, nil)
if err != nil {
log.Print(err)
os.Exit(1)
log.Fatalf("Error from engine.NewFromSettings: %s", err)
}
em := engine.NewExchangeManager()
exch, err := em.NewExchangeByName(exch.Value)
if err != nil {
log.Print(err)
os.Exit(1)
log.Fatalf("Error from NewExchangeByName: %s", err)
}
cfg, err := exchange.GetDefaultConfig(context.Background(), exch)
if err != nil {
log.Fatal(err)
log.Fatalf("Error during GetDefaultConfig: %s", err)
}
err = exch.Setup(cfg)
if err != nil {
log.Fatal(err)
if err = exch.Setup(cfg); err != nil {
log.Fatalf("Error during exch.Setup: %s", err)
}
err = em.Add(exch)
if !errors.Is(err, nil) {
log.Fatalf("received: '%v' but expected: '%v'", err, nil)
if err = em.Add(exch); err != nil {
log.Fatalf("Error during ExchangeManager.Add: %s", err)
}
engine.Bot.ExchangeManager = em
engine.Bot.WithdrawManager, err = engine.SetupWithdrawManager(em, nil, true)
if err != nil {
log.Print(err)
os.Exit(1)
log.Fatalf("Error during engine.SetupWithdrawManage: %s", err)
}

engine.Bot.DepositAddressManager = engine.SetupDepositAddressManager()
err = engine.Bot.DepositAddressManager.Sync(engine.Bot.GetAllExchangeCryptocurrencyDepositAddresses())
if err != nil {
log.Print(err)
os.Exit(1)
log.Fatalf("Error syncing DepositAddressManager: %s", err)
}

engine.Bot.OrderManager, err = engine.SetupOrderManager(em, &engine.CommunicationManager{}, &engine.Bot.ServicesWG, &config.OrderManager{})
if err != nil {
log.Print(err)
os.Exit(1)
log.Fatalf("Error during SetupOrderManager: %s", err)
}
err = engine.Bot.OrderManager.Start()
if err != nil {
log.Print(err)
os.Exit(1)
if err = engine.Bot.OrderManager.Start(); err != nil {
log.Fatalf("Error starting OrderManager: %s", err)
}
modules.SetModuleWrapper(Setup())
os.Exit(m.Run())
Expand Down

0 comments on commit dbb679e

Please sign in to comment.