Huobi: Fix invalid contract type error when autoUpdatePairs is false (#1707)

We were relying on autoUpdatePairs to fetch contract types before we
need them. If the user disables it in config, we'll get them upfront.
This commit is contained in:
Gareth Kirwan
2024-11-11 05:12:18 +01:00
committed by GitHub
parent 4de4e3dc14
commit 56fa304e19
2 changed files with 27 additions and 0 deletions

View File

@@ -2991,3 +2991,19 @@ func TestChannelName(t *testing.T) {
assert.Panics(t, func() { channelName(&subscription.Subscription{Channel: wsOrderbookChannel}, p) })
assert.Panics(t, func() { channelName(&subscription.Subscription{Channel: subscription.MyAccountChannel}, p) }, "Should panic on V2 endpoints until implemented")
}
func TestBootstrap(t *testing.T) {
t.Parallel()
h := new(HUOBI)
require.NoError(t, testexch.Setup(h), "Test Instance Setup must not fail")
c, err := h.Bootstrap(context.Background())
require.NoError(t, err)
assert.True(t, c, "Bootstrap should return true to continue")
h.futureContractCodes = nil
h.Features.Enabled.AutoPairUpdates = false
_, err = h.Bootstrap(context.Background())
require.NoError(t, err)
require.NotNil(t, h.futureContractCodes)
}

View File

@@ -187,6 +187,17 @@ func (h *HUOBI) SetDefaults() {
h.WebsocketOrderbookBufferLimit = exchange.DefaultWebsocketOrderbookBufferLimit
}
// Bootstrap ensures that future contract expiry codes are loaded if AutoPairUpdates is not enabled
func (h *HUOBI) Bootstrap(_ context.Context) (continueBootstrap bool, err error) {
continueBootstrap = true
if !h.GetEnabledFeatures().AutoPairUpdates && h.SupportsAsset(asset.Futures) {
_, err = h.FetchTradablePairs(context.Background(), asset.Futures)
}
return
}
// Setup sets user configuration
func (h *HUOBI) Setup(exch *config.Exchange) error {
err := exch.Validate()