Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyaoy committed Nov 26, 2024
1 parent c9dd185 commit 0eb35c8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestGetMutableExchangeConfig(t *testing.T) {

mutableExchangeConfig := pf.mutableState.GetMutableExchangeConfig()

require.NotSame(t, mutableExchangeConfig, pf.mutableState.mutableExchangeConfig)
require.NotSame(t, &mutableExchangeConfig, &pf.mutableState.mutableExchangeConfig)
require.Equal(t, pf.mutableState.mutableExchangeConfig, mutableExchangeConfig)
}

Expand All @@ -110,8 +110,8 @@ func TestGetTaskLoopDefinition(t *testing.T) {
taskLoopDefinition := pf.getTaskLoopDefinition()

// The taskLoopDefinition should use copies of shared state
require.NotSame(t, pf.mutableState.mutableExchangeConfig, taskLoopDefinition.mutableExchangeConfig)
require.NotSame(t, pf.mutableState.marketExponents, taskLoopDefinition.marketExponents)
require.NotSame(t, &pf.mutableState.mutableExchangeConfig, &taskLoopDefinition.mutableExchangeConfig)
require.NotSame(t, &pf.mutableState.marketExponents, &taskLoopDefinition.marketExponents)

require.Equal(t, pf.mutableState.mutableExchangeConfig, taskLoopDefinition.mutableExchangeConfig)
require.Equal(t, pf.mutableState.marketExponents, taskLoopDefinition.marketExponents)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package price_fetcher

import (
"errors"
daemontypes "github.com/dydxprotocol/v4-chain/protocol/daemons/types"
"testing"

daemontypes "github.com/dydxprotocol/v4-chain/protocol/daemons/types"

"cosmossdk.io/math"
pricefeed_cosntants "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants"
"github.com/dydxprotocol/v4-chain/protocol/testutil/daemons/pricefeed"
Expand Down Expand Up @@ -210,7 +211,7 @@ func TestGetTaskLoopDefinition_SingleMarketExchange(t *testing.T) {
taskLoopDefinition := pf.getTaskLoopDefinition()

// Expect that the definition uses a copy of the mutableExchangeConfig for synchronization purposes.
require.NotSame(t, pf.mutableState.mutableExchangeConfig, taskLoopDefinition.mutableExchangeConfig)
require.NotSame(t, &pf.mutableState.mutableExchangeConfig, &taskLoopDefinition.mutableExchangeConfig)
require.Equal(t, expectedExchangeConfig, taskLoopDefinition.mutableExchangeConfig)
require.Equal(t, expectedMarketExponents, taskLoopDefinition.marketExponents)
require.Equal(t, []types.MarketId{constants.MarketId7, constants.MarketId8}, taskLoopDefinition.marketIds)
Expand All @@ -220,7 +221,7 @@ func TestGetTaskLoopDefinition_SingleMarketExchange(t *testing.T) {

// Sanity checks:

require.NotSame(t, pf.mutableState.mutableExchangeConfig, taskLoopDefinition.mutableExchangeConfig)
require.NotSame(t, &pf.mutableState.mutableExchangeConfig, &taskLoopDefinition.mutableExchangeConfig)
require.Equal(t, expectedExchangeConfig, taskLoopDefinition.mutableExchangeConfig)
require.Equal(t, expectedMarketExponents, taskLoopDefinition.marketExponents)

Expand Down Expand Up @@ -248,7 +249,7 @@ func TestGetTaskLoopDefinition_MultiMarketExchange(t *testing.T) {
expectedExchangeConfig := &constants.Exchange1_3Markets_MutableExchangeMarketConfig

// Expect that the definition uses a copy of the mutableExchangeConfig for synchronization purposes.
require.NotSame(t, expectedExchangeConfig, taskLoopDefinition.mutableExchangeConfig)
require.NotSame(t, &expectedExchangeConfig, &taskLoopDefinition.mutableExchangeConfig)
require.Equal(t, expectedExchangeConfig, taskLoopDefinition.mutableExchangeConfig)
require.Equal(t, expectedExponents, taskLoopDefinition.marketExponents)
require.Equal(t, expectedMarkets, taskLoopDefinition.marketIds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package types_test

import (
"fmt"
"testing"

"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types"
"github.com/dydxprotocol/v4-chain/protocol/testutil/daemons/pricefeed/exchange_config"
"github.com/stretchr/testify/require"
"testing"
)

const (
Expand Down Expand Up @@ -35,7 +36,7 @@ func TestMutableExchangeMarketConfig_Copy(t *testing.T) {
},
}
mmecCopy := mutableMarketExchangeConfig.Copy()
require.NotSame(t, mutableMarketExchangeConfig, mmecCopy)
require.NotSame(t, &mutableMarketExchangeConfig, &mmecCopy)
require.True(t, mutableMarketExchangeConfig.Equal(mmecCopy))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package types_test

import (
"errors"
"testing"

"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types"
"github.com/dydxprotocol/v4-chain/protocol/testutil/constants"
"github.com/stretchr/testify/require"
"testing"
)

func TestCopy(t *testing.T) {
Expand All @@ -18,7 +19,7 @@ func TestCopy(t *testing.T) {

mmcCopy := mmc.Copy()

require.NotSame(t, mmc, mmcCopy)
require.NotSame(t, &mmc, &mmcCopy)
require.Equal(t, mmc, mmcCopy)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestGetExchangeMarketConfigCopy_Mixed(t *testing.T) {
require.Error(t, err, tc.ExpectedError.Error())
} else {
// Validate that this method returns a copy and not the original.
require.NotSame(t, tc.Expected, actual)
require.NotSame(t, &tc.Expected, &actual)
require.Equal(t, tc.Expected, actual)
require.NoError(t, err)
}
Expand Down

0 comments on commit 0eb35c8

Please sign in to comment.