Files
gocryptotrader/exchanges/blackbox_test.go
Gareth Kirwan d7818ea956 Exchanges: Remove bespoke pair upgrade handling and abstract Start/Run (#1424)
* Exchanges: Remove Pair upgrade handling

Now redundant behind #1401. These paths should never be met.

Several legacy coin upgrade paths being deprecated as well: ZUSD and CNY
Expecting any users with bad config from 3+ years ago would have to
reset anyway.

Also: At the time the intention of this was to upgrade the config
format.
However now, instead, it'd mostly serve to reset enabled pairs if
there's a config mistake, which doesn't feel right.

* Kraken: Fix typo in Kraken type struct

* Exchanges: Abstract exchange Start() and Run()

* Exchanges: Add test for abstracted Start

* Exchanges: Move Start to Bootstrap

* Simplify waitgroup usage
* Add call to exchange.Bootstrap to allow overide or supplementation

* Exchanges: Concurrent common bootstap actions

* Gateio: Remove incorrect Run in test

* GateIO: Fix pair dependencies in tests

This ensures that the pairs are initialised no more than needed and
kind-of just-in-time.
Better pattern might be to use a function to get these pairs when we
need them.

* Exchanges: Complete UpdatePairs before ExecLims

If we're going to update pairs, it needs to complete before we check for
limits to avoid errors on old pairs

* Exchanges: Remove Start and Run from tmpl

Since they're replaced by bootstrap now and shouldn't need customisation
normally

* Alphapoint: Move Start to Bootstrap

* GateIO: Fix linter shadow var
2024-01-31 19:29:36 +11:00

32 lines
719 B
Go

package exchange_test
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
shared "github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
)
type mockEx struct {
shared.CustomEx
flow chan int
}
func (m *mockEx) UpdateTradablePairs(_ context.Context, _ bool) error {
m.flow <- 42
return nil
}
func TestBootstrap(t *testing.T) {
m := &mockEx{
shared.CustomEx{},
make(chan int, 1),
}
m.Features.Enabled.AutoPairUpdates = true
err := exchange.Bootstrap(context.TODO(), m)
assert.NoError(t, err, "Bootstrap should not error")
assert.Equal(t, 42, <-m.flow, "UpdateTradablePairs should be called on the exchange")
}