Files
gocryptotrader/config/versions/v3_test.go
Ryan O'Hara-Reid 6613c56738 stream/buffer: remove time.ticker publish limiter for websocket orderbook updates (#1681)
* stream/buffer: remove publish period for for signalling change through data handler

* Add config upgrade and downgrade

* linter: fix

* GK: nits

* Update config/versions/v3.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update config/versions/v3.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update config/versions/v3.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update config/versions/v3.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update config/versions/v3.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* config: fix up commited suggestion

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2025-02-10 16:15:33 +11:00

43 lines
1.4 KiB
Go

package versions
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
func TestVersion3UpgradeExchange(t *testing.T) {
t.Parallel()
got, err := (&Version3{}).UpgradeExchange(context.Background(), nil)
require.NoError(t, err)
require.Nil(t, got)
payload := []byte(`{"orderbook": {"verificationBypass": false,"websocketBufferLimit": 5,"websocketBufferEnabled": false,"publishPeriod": 10000000000}}`)
expected := []byte(`{"orderbook": {"verificationBypass": false,"websocketBufferLimit": 5,"websocketBufferEnabled": false}}`)
got, err = (&Version3{}).UpgradeExchange(context.Background(), payload)
require.NoError(t, err)
require.Equal(t, expected, got)
}
func TestVersion3DowngradeExchange(t *testing.T) {
t.Parallel()
got, err := (&Version3{}).DowngradeExchange(context.Background(), nil)
require.NoError(t, err)
require.Nil(t, got)
payload := []byte(`{"orderbook": {"verificationBypass": false,"websocketBufferLimit": 5,"websocketBufferEnabled": false}}`)
expected := []byte(`{"orderbook": {"verificationBypass": false,"websocketBufferLimit": 5,"websocketBufferEnabled": false,"publishPeriod":10000000000}}`)
got, err = (&Version3{}).DowngradeExchange(context.Background(), payload)
require.NoError(t, err)
require.Equal(t, expected, got)
}
func TestVersion3Exchanges(t *testing.T) {
t.Parallel()
assert := require.New(t)
assert.Equal([]string{"*"}, (&Version3{}).Exchanges())
}