mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 23:16:54 +00:00
Kraken: Subscription improvements (#1587)
* Convert: Fix TimeFromUnixTimestampDecimal using local All parsed times should be in UTC * Subscriptions: Add IgnoringAssetsKey * Tests: Pass tb to curried WS handlers * Websocket: Make ErrNoMessageListener a public error * Kraken: Fix URLMap ignored for websocket URLs * Kraken: Move SeedAssets from Setup to Bootstrap Having SeedAssets in Setup is cruel and unusual because it calls the API. Most other interactive data seeding happens in Bootstrap. This made it so that fixing and creating unit tests for Kraken was painfully slow, particularly on flaky internet. * Kraken: Remove convert test Duplicate of convert_test.go TestTimeFromUnixTimestampDecimal * Kraken: Test config upgrades * Kraken: Sub Channel improvements * Use Websocket subscriptionChannels instead of local slice * Remove ChannelID - Deprecated in docs * Simplify ping handlers and hardcodes message * Add Depth as configurable orderbook channel param * Simplify auth/non-auth channel updates * Add configurable Book depth * Add configurable Candle timeframes Kraken: Simplify all WS handlers with reqId * Kraken: Subscription templating * Generate N+ subs for pairs If we generate one sub for all pairs, but then fan it out in the responses, we end up with a mis-match between the sub store and GenerateSubs, and when we do FlushChannels it will try to resub everything again. * Kraken: Rename channelName var throughout Avoid shadowing func of same name * Kraken: Add TestEnforceStandardChannelNames * Websocket: Fix Resubscribe erroring Duplicate
This commit is contained in:
@@ -89,7 +89,7 @@ func MockHTTPInstance(e exchange.IBotExchange) error {
|
||||
var upgrader = websocket.Upgrader{}
|
||||
|
||||
// WsMockFunc is a websocket handler to be called with each websocket message
|
||||
type WsMockFunc func([]byte, *websocket.Conn) error
|
||||
type WsMockFunc func(testing.TB, []byte, *websocket.Conn) error
|
||||
|
||||
// MockWsInstance creates a new Exchange instance with a mock websocket instance and HTTP server
|
||||
// It accepts an exchange package type argument and a http.HandlerFunc
|
||||
@@ -150,7 +150,7 @@ func WsMockUpgrader(tb testing.TB, w http.ResponseWriter, r *http.Request, wsHan
|
||||
}
|
||||
require.NoError(tb, err, "ReadMessage should not error")
|
||||
|
||||
err = wsHandler(p, c)
|
||||
err = wsHandler(tb, p, c)
|
||||
assert.NoError(tb, err, "WS Mock Function should not error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,6 @@ func TestMockHTTPInstance(t *testing.T) {
|
||||
|
||||
// TestMockWsInstance exercises MockWsInstance
|
||||
func TestMockWsInstance(t *testing.T) {
|
||||
b := MockWsInstance[binance.Binance](t, CurryWsMockUpgrader(t, func(_ []byte, _ *websocket.Conn) error { return nil }))
|
||||
b := MockWsInstance[binance.Binance](t, CurryWsMockUpgrader(t, func(_ testing.TB, _ []byte, _ *websocket.Conn) error { return nil }))
|
||||
require.NotNil(t, b, "MockWsInstance must not be nil")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user