Skip to content

Commit

Permalink
WIP: Flush channels test
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Feb 19, 2024
1 parent a9c1cae commit 6f49e02
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions exchanges/stream/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1000,14 +1000,13 @@ func TestFlushChannels(t *testing.T) {
assert.ErrorIs(t, err, ErrNotConnected, "FlushChannels should error correctly")

w := Websocket{
connector: connect,
ShutdownC: make(chan struct{}),
Subscriber: newgen.SUBME,
Unsubscriber: newgen.UNSUBME,
Wg: new(sync.WaitGroup),
features: &protocol.Features{
// No features
},
connector: connect,
subscriptions: subscription.NewStore(),
ShutdownC: make(chan struct{}),
Subscriber: newgen.SUBME,
Unsubscriber: newgen.UNSUBME,
Wg: new(sync.WaitGroup),
features: &protocol.Features{},
trafficTimeout: time.Second * 30, // Added for when we utilise connect()
// in FlushChannels() so the traffic monitor doesn't time out and turn
// this to an unconnected state
Expand All @@ -1029,17 +1028,17 @@ func TestFlushChannels(t *testing.T) {
w.GenerateSubs = func() (subscription.List, error) {
return subscription.List{{Channel: "test"}}, nil
}
err = w.FlushChannels()
assert.NoError(t, err, "FlushChannels should not error")
err = web.FlushChannels()
require.NoError(t, err, "Flush Channels must not error")

w.features.FullPayloadSubscribe = true
w.GenerateSubs = problemFunc
err = w.FlushChannels() // error on full subscribeToChannels
assert.ErrorIs(t, err, errDastardlyReason, "FlushChannels should error correctly")

w.GenerateSubs = noSub
err = w.FlushChannels() // No subs to unsub
assert.NoError(t, err, "FlushChannels should not error")
err = w.FlushChannels() // No subs to sub
assert.NoError(t, err, "Flush Channels should not error")

web.GenerateSubs = newgen.generateSubs
subs, err := web.GenerateSubs()
Expand Down

0 comments on commit 6f49e02

Please sign in to comment.