From 0eb35c8ce73e477d573667ad8379eb3c091ec80a Mon Sep 17 00:00:00 2001 From: Chenyao Yu <4844716+chenyaoy@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:55:42 -0500 Subject: [PATCH] fix tests --- .../pricefeed/client/price_fetcher/mutable_state_test.go | 6 +++--- .../pricefeed/client/price_fetcher/price_fetcher_test.go | 9 +++++---- .../client/types/mutable_exchange_market_config_test.go | 5 +++-- .../pricefeed/client/types/mutable_market_config_test.go | 5 +++-- .../types/price_feed_mutable_market_configs_test.go | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go b/protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go index 9d1698d269..aafcd6139d 100644 --- a/protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go +++ b/protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go @@ -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) } @@ -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) diff --git a/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go b/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go index e246da4edf..4ddd47053a 100644 --- a/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go +++ b/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go @@ -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" @@ -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) @@ -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) @@ -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) diff --git a/protocol/daemons/pricefeed/client/types/mutable_exchange_market_config_test.go b/protocol/daemons/pricefeed/client/types/mutable_exchange_market_config_test.go index a74972616c..a9cfc2e5b3 100644 --- a/protocol/daemons/pricefeed/client/types/mutable_exchange_market_config_test.go +++ b/protocol/daemons/pricefeed/client/types/mutable_exchange_market_config_test.go @@ -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 ( @@ -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)) } diff --git a/protocol/daemons/pricefeed/client/types/mutable_market_config_test.go b/protocol/daemons/pricefeed/client/types/mutable_market_config_test.go index e832208de5..ca86d902bd 100644 --- a/protocol/daemons/pricefeed/client/types/mutable_market_config_test.go +++ b/protocol/daemons/pricefeed/client/types/mutable_market_config_test.go @@ -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) { @@ -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) } diff --git a/protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go b/protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go index 47cba5f48a..654da7c34e 100644 --- a/protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go +++ b/protocol/daemons/pricefeed/client/types/price_feed_mutable_market_configs_test.go @@ -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) }