mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-29 15:10:37 +00:00
* 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
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package exchange
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gorilla/websocket"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/thrasher-corp/gocryptotrader/config"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/binance"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
|
|
)
|
|
|
|
// TestSetup exercises Setup
|
|
func TestSetup(t *testing.T) {
|
|
b := new(binance.Binance)
|
|
require.NoError(t, Setup(b), "Setup must not error")
|
|
assert.NotNil(t, b.Websocket, "Websocket should not be nil after Setup")
|
|
|
|
e := new(sharedtestvalues.CustomEx)
|
|
assert.ErrorIs(t, Setup(e), config.ErrExchangeNotFound, "Setup should error correctly on a missing exchange")
|
|
}
|
|
|
|
// TestMockHTTPInstance exercises MockHTTPInstance
|
|
func TestMockHTTPInstance(t *testing.T) {
|
|
b := new(binance.Binance)
|
|
require.NoError(t, Setup(b), "Test exchange Setup must not error")
|
|
require.NoError(t, MockHTTPInstance(b), "MockHTTPInstance must not error")
|
|
}
|
|
|
|
// TestMockWsInstance exercises MockWsInstance
|
|
func TestMockWsInstance(t *testing.T) {
|
|
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")
|
|
}
|