Huobi: Add subscription configuration (#1604)

* Huobi: Update test config format

* Huobi: Add subscription configuration

* Huobi: Add subscription documentation

* Huobi: Clarify OB sub Levels usage

* Huobi: Enable websocket for tests

* Subscriptions: Rename ErrPrivateChannelName

Rename ErrPrivateChannelName to ErrUseConstChannelName
This commit is contained in:
Gareth Kirwan
2024-11-11 04:19:25 +01:00
committed by GitHub
parent d4c4bf1bcd
commit a2a7fed273
9 changed files with 209 additions and 98 deletions

View File

@@ -1001,7 +1001,7 @@ func TestWsSubscribe(t *testing.T) {
Channel: c,
Pairs: currency.Pairs{spotTestPair},
}})
assert.ErrorIs(t, err, subscription.ErrPrivateChannelName, "Must error when trying to use a private channel name")
assert.ErrorIs(t, err, subscription.ErrUseConstChannelName, "Must error when trying to use a private channel name")
assert.ErrorContains(t, err, c+" => subscription.CandlesChannel", "Must error when trying to use a private channel name")
}
}
@@ -1703,6 +1703,6 @@ func TestEnforceStandardChannelNames(t *testing.T) {
}
for _, n := range []string{krakenWsOrderbook, krakenWsOHLC, krakenWsTrade, krakenWsOwnTrades, krakenWsOpenOrders, krakenWsOrderbook + "-5"} {
err := enforceStandardChannelNames(&subscription.Subscription{Channel: n})
assert.ErrorIsf(t, err, subscription.ErrPrivateChannelName, "Private channel names should not be allowed for %s", n)
assert.ErrorIsf(t, err, subscription.ErrUseConstChannelName, "Private channel names should not be allowed for %s", n)
}
}

View File

@@ -1237,7 +1237,7 @@ func channelName(s *subscription.Subscription) string {
func enforceStandardChannelNames(s *subscription.Subscription) error {
name := strings.Split(s.Channel, "-") // Protect against attempted usage of book-N as a channel name
if n, ok := reverseChannelNames[name[0]]; ok && n != s.Channel {
return fmt.Errorf("%w: %s => subscription.%s%sChannel", subscription.ErrPrivateChannelName, s.Channel, bytes.ToUpper([]byte{n[0]}), n[1:])
return fmt.Errorf("%w: %s => subscription.%s%sChannel", subscription.ErrUseConstChannelName, s.Channel, bytes.ToUpper([]byte{n[0]}), n[1:])
}
return nil
}