Skip to content

Commit

Permalink
linter: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shazbert committed Jan 13, 2025
1 parent 789da79 commit 9587c5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions config/versions/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func init() {
Manager.registerVersion(3, &Version3{})
}

// // Exchanges returns all exchanges: "*"
// Exchanges returns all exchanges: "*"
func (v *Version3) Exchanges() []string { return []string{"*"} }

// UpgradeExchange will remove the orderbook and publishPeriod from the exchange config
Expand All @@ -30,7 +30,7 @@ var defaultOrderbookPublishPeriod = time.Second * 10
// DowngradeExchange will downgrade the exchange config with the default orderbook publish period
func (v *Version3) DowngradeExchange(_ context.Context, e []byte) ([]byte, error) {
if _, _, _, err := jsonparser.Get(e, "orderbook"); err != nil {
return e, nil
return e, nil //nolint:nilerr // No error, just return the original config
}
out, err := json.Marshal(defaultOrderbookPublishPeriod)
if err != nil {
Expand Down
13 changes: 7 additions & 6 deletions config/versions/v3_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package versions

import (
"context"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -9,29 +10,29 @@ import (
func TestVersion3UpgradeExchange(t *testing.T) {
t.Parallel()

got, err := (&Version3{}).UpgradeExchange(nil, nil)
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(nil, payload)
got, err = (&Version3{}).UpgradeExchange(context.Background(), payload)
require.NoError(t, err)
require.Equal(t, got, expected)
require.Equal(t, expected, got)
}

func TestVersion3DowngradeExchange(t *testing.T) {
t.Parallel()

got, err := (&Version3{}).DowngradeExchange(nil, nil)
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(nil, payload)
got, err = (&Version3{}).DowngradeExchange(context.Background(), payload)
require.NoError(t, err)
require.Equal(t, got, expected)
require.Equal(t, expected, got)
}

func TestVersion3Exchanges(t *testing.T) {
Expand Down

0 comments on commit 9587c5e

Please sign in to comment.