subscriptions: Add templating support and integrate with Binance (#1568)

* Subscriptions: Add List.AssetPairs

* Subscriptions: Add Template and QualifiedChannel

These fields separate the concept of what the channel is from the
qualified resource name

* Subscriptions: Add List.SetStates()

* Subscriptions: Add List.QualifiedChannels

* Subscriptions: Rename testsubs.EqualLists

* Binance: Switch to ExpandTemplates

* Binance: Update ConfigTest format

* Subscriptions: Test Coverage improvements

* Subscriptions: Reenterant List.ExpandTemplates

* Subscriptions: Move templates from subscriptions to exchanges

* Binance: Inline subscription template and improvements
This commit is contained in:
Gareth Kirwan
2024-07-09 12:53:00 +07:00
committed by GitHub
parent 00c5c95468
commit c601575c66
27 changed files with 886 additions and 232 deletions

View File

@@ -2818,11 +2818,7 @@ func TestGetCachedOpenInterest(t *testing.T) {
// TestSetSubscriptionsFromConfig tests the setting and loading of subscriptions from config and exchange defaults
func TestSetSubscriptionsFromConfig(t *testing.T) {
t.Parallel()
b := Base{
Config: &config.Exchange{
Features: &config.FeaturesConfig{},
},
}
b := Base{Config: &config.Exchange{Features: &config.FeaturesConfig{}}}
subs := subscription.List{
{Channel: subscription.CandlesChannel, Interval: kline.OneDay, Enabled: true},
{Channel: subscription.OrderbookChannel, Enabled: false},
@@ -2900,6 +2896,17 @@ func TestGetDefaultConfig(t *testing.T) {
assert.Equal(t, cpy, exch.Requester)
}
// TestCanUseAuthenticatedWebsocketEndpoints exercises CanUseAuthenticatedWebsocketEndpoints
func TestCanUseAuthenticatedWebsocketEndpoints(t *testing.T) {
t.Parallel()
e := &FakeBase{}
assert.False(t, e.CanUseAuthenticatedWebsocketEndpoints(), "CanUseAuthenticatedWebsocketEndpoints should return false with nil websocket")
e.Websocket = stream.NewWebsocket()
assert.False(t, e.CanUseAuthenticatedWebsocketEndpoints())
e.Websocket.SetCanUseAuthenticatedEndpoints(true)
assert.True(t, e.CanUseAuthenticatedWebsocketEndpoints())
}
// FakeBase is used to override functions
type FakeBase struct{ Base }