From 315890faea4c9b034a25e349e201eb03667af688 Mon Sep 17 00:00:00 2001 From: Lukasz Cwik <126621805+lcwik@users.noreply.github.com> Date: Wed, 18 Oct 2023 15:28:18 -0700 Subject: [PATCH] [CORE-29] Migrate from stoppable to BaseApp#Stop. (#660) --- protocol/app/app.go | 19 +++++--- protocol/app/app_test.go | 9 ++++ protocol/app/stoppable/stoppable.go | 46 ------------------- protocol/app/stoppable/stoppable_test.go | 42 ----------------- .../client/client_integration_test.go | 1 - .../daemons/pricefeed/client/client_test.go | 1 - protocol/daemons/server/liquidation_test.go | 2 + protocol/daemons/server/pricefeed_test.go | 4 ++ protocol/daemons/server/server.go | 6 +-- protocol/daemons/server/server_test.go | 15 +++--- protocol/testutil/prices/cli/util.go | 5 -- protocol/x/blocktime/client/cli/query_test.go | 5 -- protocol/x/bridge/client/cli/query_test.go | 6 --- .../clob/client/cli/cancel_order_cli_test.go | 6 --- .../clob/client/cli/liquidations_cli_test.go | 6 --- .../x/clob/client/cli/place_order_cli_test.go | 6 --- .../x/clob/client/cli/query_clob_pair_test.go | 6 --- protocol/x/delaymsg/client/cli/query_test.go | 5 -- .../client/cli/query_epoch_info_test.go | 5 -- protocol/x/feetiers/client/cli/query_test.go | 5 -- .../client/cli/query_perpetual_test.go | 5 -- .../x/prices/client/cli/prices_cli_test.go | 6 --- .../x/rewards/client/cli/query_params_test.go | 5 -- .../x/sending/client/cli/sending_cli_test.go | 6 --- protocol/x/stats/client/cli/query_test.go | 5 -- .../client/cli/query_subaccount_test.go | 5 -- .../vest/client/cli/query_vest_entry_test.go | 5 -- 27 files changed, 36 insertions(+), 201 deletions(-) delete mode 100644 protocol/app/stoppable/stoppable.go delete mode 100644 protocol/app/stoppable/stoppable_test.go diff --git a/protocol/app/app.go b/protocol/app/app.go index a760721f82..d0c557d91d 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -14,7 +14,6 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" sdklog "cosmossdk.io/log" - dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" @@ -95,8 +94,7 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/app/middleware" "github.com/dydxprotocol/v4-chain/protocol/app/prepare" "github.com/dydxprotocol/v4-chain/protocol/app/process" - // Lib - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" + "github.com/dydxprotocol/v4-chain/protocol/lib" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" timelib "github.com/dydxprotocol/v4-chain/protocol/lib/time" @@ -284,6 +282,8 @@ type App struct { // delayed until after the gRPC service is initialized so that the gRPC service will be available and the daemons // can correctly operate. startDaemons func() + + PriceFeedClient *pricefeedclient.Client } // assertAppPreconditions assert invariants required for an application to start. @@ -546,7 +546,6 @@ func New( grpc.NewServer(), &daemontypes.FileHandlerImpl{}, daemonFlags.Shared.SocketAddress, - appFlags.GrpcAddress, ) // Setup server for pricefeed messages. The server will wait for gRPC messages containing price // updates and then encode them into an in-memory cache shared by the prices module. @@ -602,7 +601,7 @@ func New( // Start pricefeed client for sending prices for the pricefeed server to consume. These prices // are retrieved via third-party APIs like Binance and then are encoded in-memory and // periodically sent via gRPC to a shared socket with the server. - client := pricefeedclient.StartNewClient( + app.PriceFeedClient = pricefeedclient.StartNewClient( // The client will use `context.Background` so that it can have a different context from // the main application. context.Background(), @@ -614,7 +613,6 @@ func New( constants.StaticExchangeDetails, &pricefeedclient.SubTaskRunnerImpl{}, ) - stoppable.RegisterServiceForTestCleanup(appFlags.GrpcAddress, client) } // Start Bridge Daemon. @@ -1418,8 +1416,15 @@ func (app *App) setAnteHandler(txConfig client.TxConfig) { app.SetAnteHandler(anteHandler) } +// Close invokes an ordered shutdown of routines. func (app *App) Close() error { - return app.BaseApp.Close() + if app.PriceFeedClient != nil { + app.PriceFeedClient.Stop() + } + if app.Server != nil { + app.Server.Stop() + } + return nil } // RegisterSwaggerAPI registers swagger route with API Server diff --git a/protocol/app/app_test.go b/protocol/app/app_test.go index 27a5e11374..208a313b34 100644 --- a/protocol/app/app_test.go +++ b/protocol/app/app_test.go @@ -1,6 +1,7 @@ package app_test import ( + "gopkg.in/typ.v4/slices" "reflect" "strings" "testing" @@ -94,6 +95,14 @@ func TestAppIsFullyInitialized(t *testing.T) { t.Run(name, func(t *testing.T) { dydxApp := testapp.DefaultTestApp(tc.customFlags) uninitializedFields := getUninitializedStructFields(reflect.ValueOf(*dydxApp)) + + // Note that the PriceFeedClient is currently hard coded as disabled in GetDefaultTestAppOptions. + // Normally it would be only disabled for non-validating full nodes or for nodes where the + // price feed client is explicitly disabled. + if idx := slices.Index(uninitializedFields, "PriceFeedClient"); idx >= 0 { + slices.Remove(&uninitializedFields, idx) + } + require.Len( t, uninitializedFields, diff --git a/protocol/app/stoppable/stoppable.go b/protocol/app/stoppable/stoppable.go deleted file mode 100644 index 5551ade5b5..0000000000 --- a/protocol/app/stoppable/stoppable.go +++ /dev/null @@ -1,46 +0,0 @@ -package stoppable - -import ( - "sync" - "testing" -) - -var ( - servicesRequiringCleanup = make(map[string][]Stoppable) - lock sync.Mutex -) - -// Stoppable is an interface for objects that can be stopped. A global map of these objects is maintained here. This -// map is used to stop all running services that aren't cleaned up by the Network test object for our cli test suite. -// Services are organized by a uuid per test case, which is that test's GRPC address, since the network package chooses -// these to not overlap, and these are easily accessible to the protocol from the app.New method, where many services -// are started, and which does not have a reference to an sdk context. -type Stoppable interface { - Stop() -} - -// RegisterServiceForTestCleanup registers a service for cleanup. All services are organized by a uuid per test case. -func RegisterServiceForTestCleanup(testUuid string, service Stoppable) { - lock.Lock() - defer lock.Unlock() - - if _, ok := servicesRequiringCleanup[testUuid]; !ok { - servicesRequiringCleanup[testUuid] = []Stoppable{} - } - servicesRequiringCleanup[testUuid] = append(servicesRequiringCleanup[testUuid], service) -} - -// StopServices stops all services that were registered for cleanup for a given test, identified by uuid. -// It also removes the services from the global map. -func StopServices(t *testing.T, testUuid string) { - lock.Lock() - defer lock.Unlock() - - t.Log("Stopping services for test", "uuid", testUuid) - if services, ok := servicesRequiringCleanup[testUuid]; ok { - for _, service := range services { - service.Stop() - } - delete(servicesRequiringCleanup, testUuid) - } -} diff --git a/protocol/app/stoppable/stoppable_test.go b/protocol/app/stoppable/stoppable_test.go deleted file mode 100644 index ffc8ffc2cc..0000000000 --- a/protocol/app/stoppable/stoppable_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package stoppable_test - -import ( - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" - "github.com/stretchr/testify/require" - "testing" -) - -type TestStoppable struct { - stopCalled bool -} - -func (m *TestStoppable) Stop() { - if m.stopCalled { - panic("Stop called twice") - } - m.stopCalled = true -} - -func TestStopServices(t *testing.T) { - testStoppable := &TestStoppable{} - testStoppable2 := &TestStoppable{} - testStoppableSeparateTest := &TestStoppable{} - stoppable.RegisterServiceForTestCleanup("test", testStoppable) - stoppable.RegisterServiceForTestCleanup("test", testStoppable2) - stoppable.RegisterServiceForTestCleanup("test2", testStoppableSeparateTest) - - // Stop test services, verify. - stoppable.StopServices(t, "test") - - // Verify test services stopped, test2 services unaffected. - require.True(t, testStoppable.stopCalled) - require.True(t, testStoppable2.stopCalled) - require.False(t, testStoppableSeparateTest.stopCalled) - - // Stop test services again. This should not cause any panics. - stoppable.StopServices(t, "test") - - // Stop test2 services, verify. - stoppable.StopServices(t, "test2") - require.True(t, testStoppableSeparateTest.stopCalled) -} diff --git a/protocol/daemons/pricefeed/client/client_integration_test.go b/protocol/daemons/pricefeed/client/client_integration_test.go index 551452e0d9..1cf2908237 100644 --- a/protocol/daemons/pricefeed/client/client_integration_test.go +++ b/protocol/daemons/pricefeed/client/client_integration_test.go @@ -277,7 +277,6 @@ func (s *PriceDaemonIntegrationTestSuite) SetupTest() { grpc.NewServer(), &daemontypes.FileHandlerImpl{}, s.daemonFlags.Shared.SocketAddress, - "test", ) s.daemonServer.ExpectPricefeedDaemon(servertypes.MaximumAcceptableUpdateDelay(s.daemonFlags.Price.LoopDelayMs)) s.exchangePriceCache = pricefeedserver_types.NewMarketToExchangePrices(pricefeed_types.MaxPriceAge) diff --git a/protocol/daemons/pricefeed/client/client_test.go b/protocol/daemons/pricefeed/client/client_test.go index ca000d2ca1..1d95d77fef 100644 --- a/protocol/daemons/pricefeed/client/client_test.go +++ b/protocol/daemons/pricefeed/client/client_test.go @@ -299,7 +299,6 @@ func TestStop(t *testing.T) { grpc.NewServer(), &daemontypes.FileHandlerImpl{}, daemonFlags.Shared.SocketAddress, - "test", ) daemonServer.WithPriceFeedMarketToExchangePrices( pricefeed_types.NewMarketToExchangePrices(5 * time.Second), diff --git a/protocol/daemons/server/liquidation_test.go b/protocol/daemons/server/liquidation_test.go index d8185a5c23..a34a1e6009 100644 --- a/protocol/daemons/server/liquidation_test.go +++ b/protocol/daemons/server/liquidation_test.go @@ -18,6 +18,7 @@ func TestLiquidateSubaccounts_Empty_Update(t *testing.T) { liquidatableSubaccountIds := liquidationtypes.NewLiquidatableSubaccountIds() s := createServerWithMocks( + t, mockGrpcServer, mockFileHandler, ).WithLiquidatableSubaccountIds( @@ -36,6 +37,7 @@ func TestLiquidateSubaccounts_Multiple_Subaccount_Ids(t *testing.T) { liquidatableSubaccountIds := liquidationtypes.NewLiquidatableSubaccountIds() s := createServerWithMocks( + t, mockGrpcServer, mockFileHandler, ).WithLiquidatableSubaccountIds( diff --git a/protocol/daemons/server/pricefeed_test.go b/protocol/daemons/server/pricefeed_test.go index 9be9976e91..0eb8c3af52 100644 --- a/protocol/daemons/server/pricefeed_test.go +++ b/protocol/daemons/server/pricefeed_test.go @@ -23,6 +23,7 @@ func TestUpdateMarketPrices_Valid(t *testing.T) { mockFileHandler := &mocks.FileHandler{} s := createServerWithMocks( + t, mockGrpcServer, mockFileHandler, ).WithPriceFeedMarketToExchangePrices( @@ -43,6 +44,7 @@ func TestUpdateMarketPrices_NotInitialized(t *testing.T) { // Create a new server without initializing `MarketToExchange` field. s := createServerWithMocks( + t, mockGrpcServer, mockFileHandler, ) @@ -69,6 +71,7 @@ func TestUpdateMarketPrices_InvalidEmptyRequest(t *testing.T) { mockFileHandler := &mocks.FileHandler{} s := createServerWithMocks( + t, mockGrpcServer, mockFileHandler, ).WithPriceFeedMarketToExchangePrices( @@ -145,6 +148,7 @@ func TestUpdateMarketPrices_InvalidExchangePrices(t *testing.T) { mockFileHandler := &mocks.FileHandler{} s := createServerWithMocks( + t, mockGrpcServer, mockFileHandler, ).WithPriceFeedMarketToExchangePrices( diff --git a/protocol/daemons/server/server.go b/protocol/daemons/server/server.go index 9a4c5e09d6..d146587731 100644 --- a/protocol/daemons/server/server.go +++ b/protocol/daemons/server/server.go @@ -4,7 +4,6 @@ import ( gometrics "github.com/armon/go-metrics" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/telemetry" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" bridgeapi "github.com/dydxprotocol/v4-chain/protocol/daemons/bridge/api" "github.com/dydxprotocol/v4-chain/protocol/daemons/constants" liquidationapi "github.com/dydxprotocol/v4-chain/protocol/daemons/liquidation/api" @@ -42,17 +41,14 @@ func NewServer( grpcServer daemontypes.GrpcServer, fileHandler daemontypes.FileHandler, socketAddress string, - uniqueTestIdentifier string, ) *Server { - srv := &Server{ + return &Server{ logger: logger, gsrv: grpcServer, fileHandler: fileHandler, socketAddress: socketAddress, updateMonitor: types.NewUpdateFrequencyMonitor(types.DaemonStartupGracePeriod, logger), } - stoppable.RegisterServiceForTestCleanup(uniqueTestIdentifier, srv) - return srv } // Stop stops the daemon server's gRPC service. diff --git a/protocol/daemons/server/server_test.go b/protocol/daemons/server/server_test.go index eb9f7adb44..5188409d10 100644 --- a/protocol/daemons/server/server_test.go +++ b/protocol/daemons/server/server_test.go @@ -6,7 +6,6 @@ import ( "github.com/cometbft/cometbft/libs/log" pricefeedconstants "github.com/dydxprotocol/v4-chain/protocol/daemons/constants" "github.com/dydxprotocol/v4-chain/protocol/daemons/server" - daemontypes "github.com/dydxprotocol/v4-chain/protocol/daemons/types" "github.com/dydxprotocol/v4-chain/protocol/mocks" "github.com/dydxprotocol/v4-chain/protocol/testutil/grpc" "github.com/stretchr/testify/mock" @@ -41,7 +40,7 @@ func TestStartServer_ListenFailsWhenInUse(t *testing.T) { return nil }) - s := createServerWithMocks(mockGrpcServer, mockFileHandler) + s := createServerWithMocks(t, mockGrpcServer, mockFileHandler) errorString := fmt.Sprintf( "listen %s %s: bind: address already in use", @@ -67,6 +66,7 @@ func TestStart_Valid(t *testing.T) { mockFileHandler := &mocks.FileHandler{} s := createServerWithMocks( + t, mockGrpcServer, mockFileHandler, ) @@ -115,6 +115,7 @@ func TestStart_MixedInvalid(t *testing.T) { mockFileHandler := &mocks.FileHandler{} s := createServerWithMocks( + t, mockGrpcServer, mockFileHandler, ) @@ -166,7 +167,6 @@ func TestRegisterDaemon_DoesNotPanic(t *testing.T) { grpcServer, &mocks.FileHandler{}, grpc.SocketPath, - "test", ) defer server.Stop() @@ -183,7 +183,6 @@ func TestRegisterDaemon_DoubleRegistrationPanics(t *testing.T) { grpcServer, &mocks.FileHandler{}, grpc.SocketPath, - "test", ) defer server.Stop() @@ -203,16 +202,18 @@ func TestRegisterDaemon_DoubleRegistrationPanics(t *testing.T) { } func createServerWithMocks( - mockGrpcServer daemontypes.GrpcServer, - mockFileHandler daemontypes.FileHandler, + t testing.TB, + mockGrpcServer *mocks.GrpcServer, + mockFileHandler *mocks.FileHandler, ) *server.Server { server := server.NewServer( log.NewNopLogger(), mockGrpcServer, mockFileHandler, grpc.SocketPath, - "test", ) + mockGrpcServer.On("Stop").Return().Once() + t.Cleanup(server.Stop) server.DisableUpdateMonitoringForTesting() return server } diff --git a/protocol/testutil/prices/cli/util.go b/protocol/testutil/prices/cli/util.go index 34550424b8..cec46de6b3 100644 --- a/protocol/testutil/prices/cli/util.go +++ b/protocol/testutil/prices/cli/util.go @@ -2,7 +2,6 @@ package cli import ( "fmt" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "testing" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" @@ -46,9 +45,5 @@ func NetworkWithMarketObjects(t *testing.T, n int) (*network.Network, []types.Ma require.NoError(t, err) cfg.GenesisState[types.ModuleName] = buf - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return network.New(t, cfg), state.MarketParams, state.MarketPrices } diff --git a/protocol/x/blocktime/client/cli/query_test.go b/protocol/x/blocktime/client/cli/query_test.go index 9f4b0c0798..a4c5c6a8df 100644 --- a/protocol/x/blocktime/client/cli/query_test.go +++ b/protocol/x/blocktime/client/cli/query_test.go @@ -3,7 +3,6 @@ package cli_test import ( - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "strconv" "testing" @@ -40,10 +39,6 @@ func setupNetwork( net := network.New(t, cfg) ctx := net.Validators[0].ClientCtx - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return net, ctx } diff --git a/protocol/x/bridge/client/cli/query_test.go b/protocol/x/bridge/client/cli/query_test.go index e52eb5ee2f..6ce5eb6349 100644 --- a/protocol/x/bridge/client/cli/query_test.go +++ b/protocol/x/bridge/client/cli/query_test.go @@ -6,8 +6,6 @@ import ( "strconv" "testing" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" - "github.com/cosmos/cosmos-sdk/client" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/stretchr/testify/require" @@ -41,10 +39,6 @@ func setupNetwork( net := network.New(t, cfg) ctx := net.Validators[0].ClientCtx - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return net, ctx } diff --git a/protocol/x/clob/client/cli/cancel_order_cli_test.go b/protocol/x/clob/client/cli/cancel_order_cli_test.go index a9b8d2321e..9f148f36ba 100644 --- a/protocol/x/clob/client/cli/cancel_order_cli_test.go +++ b/protocol/x/clob/client/cli/cancel_order_cli_test.go @@ -6,7 +6,6 @@ import ( "fmt" networktestutil "github.com/cosmos/cosmos-sdk/testutil/network" appflags "github.com/dydxprotocol/v4-chain/protocol/app/flags" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" daemonflags "github.com/dydxprotocol/v4-chain/protocol/daemons/flags" "github.com/dydxprotocol/v4-chain/protocol/testutil/appoptions" "math/big" @@ -76,11 +75,6 @@ func (s *CancelOrderIntegrationTestSuite) SetupTest() { // Make sure the daemon is using the correct GRPC address. appOptions.Set(appflags.GrpcAddress, testval.AppConfig.GRPC.Address) - - // Make sure all daemon-related services are properly stopped. - s.T().Cleanup(func() { - stoppable.StopServices(s.T(), testval.AppConfig.GRPC.Address) - }) }, }) diff --git a/protocol/x/clob/client/cli/liquidations_cli_test.go b/protocol/x/clob/client/cli/liquidations_cli_test.go index 598851a672..01d02bf1a1 100644 --- a/protocol/x/clob/client/cli/liquidations_cli_test.go +++ b/protocol/x/clob/client/cli/liquidations_cli_test.go @@ -6,8 +6,6 @@ import ( "fmt" appflags "github.com/dydxprotocol/v4-chain/protocol/app/flags" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" - "math/big" "testing" @@ -81,10 +79,6 @@ func TestLiquidationOrderIntegrationTestSuite(t *testing.T) { // Enable the liquidations daemon in the integration tests. appOptions.Set(daemonflags.FlagUnixSocketAddress, liqTestUnixSocketAddress) - // Make sure all daemon-related services are properly stopped. - t.Cleanup(func() { - stoppable.StopServices(t, testval.AppConfig.GRPC.Address) - }) }, }) diff --git a/protocol/x/clob/client/cli/place_order_cli_test.go b/protocol/x/clob/client/cli/place_order_cli_test.go index 50158db86f..bf6832efe8 100644 --- a/protocol/x/clob/client/cli/place_order_cli_test.go +++ b/protocol/x/clob/client/cli/place_order_cli_test.go @@ -5,7 +5,6 @@ package cli_test import ( "fmt" appflags "github.com/dydxprotocol/v4-chain/protocol/app/flags" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "math/big" "testing" @@ -71,11 +70,6 @@ func TestPlaceOrderIntegrationTestSuite(t *testing.T) { // Make sure the daemon is using the correct GRPC address. appOptions.Set(appflags.GrpcAddress, testval.AppConfig.GRPC.Address) - - // Make sure all daemon-related services are properly stopped. - t.Cleanup(func() { - stoppable.StopServices(t, testval.AppConfig.GRPC.Address) - }) }, }) diff --git a/protocol/x/clob/client/cli/query_clob_pair_test.go b/protocol/x/clob/client/cli/query_clob_pair_test.go index 74512ee6da..0f4f2249ed 100644 --- a/protocol/x/clob/client/cli/query_clob_pair_test.go +++ b/protocol/x/clob/client/cli/query_clob_pair_test.go @@ -7,8 +7,6 @@ import ( "strconv" "testing" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" - tmcli "github.com/cometbft/cometbft/libs/cli" "github.com/cosmos/cosmos-sdk/client/flags" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" @@ -82,10 +80,6 @@ func networkWithClobPairObjects(t *testing.T, n int) (*network.Network, []types. require.NoError(t, err) cfg.GenesisState[types.ModuleName] = buf - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return network.New(t, cfg), state.ClobPairs } diff --git a/protocol/x/delaymsg/client/cli/query_test.go b/protocol/x/delaymsg/client/cli/query_test.go index c35e7b0d88..f6e7eaf81c 100644 --- a/protocol/x/delaymsg/client/cli/query_test.go +++ b/protocol/x/delaymsg/client/cli/query_test.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" "github.com/dydxprotocol/v4-chain/protocol/testutil/encoding" "github.com/dydxprotocol/v4-chain/protocol/testutil/network" @@ -50,10 +49,6 @@ func setupNetwork( net := network.New(t, cfg) ctx := net.Validators[0].ClientCtx - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return net, ctx } diff --git a/protocol/x/epochs/client/cli/query_epoch_info_test.go b/protocol/x/epochs/client/cli/query_epoch_info_test.go index a02f573874..30d87ad2ab 100644 --- a/protocol/x/epochs/client/cli/query_epoch_info_test.go +++ b/protocol/x/epochs/client/cli/query_epoch_info_test.go @@ -4,7 +4,6 @@ package cli_test import ( "fmt" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "strconv" "testing" "time" @@ -58,10 +57,6 @@ func networkWithEpochInfoObjects(t *testing.T) network.Config { require.NoError(t, err) cfg.GenesisState[types.ModuleName] = buf - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return cfg } diff --git a/protocol/x/feetiers/client/cli/query_test.go b/protocol/x/feetiers/client/cli/query_test.go index 9330167f7b..8e175be906 100644 --- a/protocol/x/feetiers/client/cli/query_test.go +++ b/protocol/x/feetiers/client/cli/query_test.go @@ -3,7 +3,6 @@ package cli_test import ( - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "strconv" "testing" @@ -40,10 +39,6 @@ func setupNetwork( net := network.New(t, cfg) ctx := net.Validators[0].ClientCtx - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return net, ctx } diff --git a/protocol/x/perpetuals/client/cli/query_perpetual_test.go b/protocol/x/perpetuals/client/cli/query_perpetual_test.go index f0eaedffd1..bef9977b2a 100644 --- a/protocol/x/perpetuals/client/cli/query_perpetual_test.go +++ b/protocol/x/perpetuals/client/cli/query_perpetual_test.go @@ -4,7 +4,6 @@ package cli_test import ( "fmt" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "testing" tmcli "github.com/cometbft/cometbft/libs/cli" @@ -78,10 +77,6 @@ func networkWithLiquidityTierAndPerpetualObjects( require.NoError(t, err) cfg.GenesisState[types.ModuleName] = buf - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return network.New(t, cfg), state.LiquidityTiers, state.Perpetuals } diff --git a/protocol/x/prices/client/cli/prices_cli_test.go b/protocol/x/prices/client/cli/prices_cli_test.go index b342c2be43..86be1bbd8c 100644 --- a/protocol/x/prices/client/cli/prices_cli_test.go +++ b/protocol/x/prices/client/cli/prices_cli_test.go @@ -5,7 +5,6 @@ package cli_test import ( "fmt" appflags "github.com/dydxprotocol/v4-chain/protocol/app/flags" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "time" "testing" @@ -98,11 +97,6 @@ func (s *PricesIntegrationTestSuite) SetupTest() { // Make sure the daemon is using the correct GRPC address. appOptions.Set(appflags.GrpcAddress, testval.AppConfig.GRPC.Address) - - // Make sure all daemon-related services are properly stopped. - s.T().Cleanup(func() { - stoppable.StopServices(s.T(), testval.AppConfig.GRPC.Address) - }) }, }) diff --git a/protocol/x/rewards/client/cli/query_params_test.go b/protocol/x/rewards/client/cli/query_params_test.go index 5534499083..2fb9111fa4 100644 --- a/protocol/x/rewards/client/cli/query_params_test.go +++ b/protocol/x/rewards/client/cli/query_params_test.go @@ -7,7 +7,6 @@ import ( tmcli "github.com/cometbft/cometbft/libs/cli" "github.com/cosmos/cosmos-sdk/client" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "github.com/dydxprotocol/v4-chain/protocol/testutil/network" "github.com/dydxprotocol/v4-chain/protocol/x/rewards/client/cli" "github.com/dydxprotocol/v4-chain/protocol/x/rewards/types" @@ -40,10 +39,6 @@ func setupNetwork( net := network.New(t, cfg) ctx := net.Validators[0].ClientCtx - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return net, ctx } diff --git a/protocol/x/sending/client/cli/sending_cli_test.go b/protocol/x/sending/client/cli/sending_cli_test.go index c15c97eae3..4dd3a5279a 100644 --- a/protocol/x/sending/client/cli/sending_cli_test.go +++ b/protocol/x/sending/client/cli/sending_cli_test.go @@ -4,8 +4,6 @@ package cli_test import ( "fmt" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" - "math/big" "testing" @@ -51,10 +49,6 @@ func (s *SendingIntegrationTestSuite) SetupTest() { // Configure test network. s.cfg = network.DefaultConfig(nil) - s.T().Cleanup(func() { - stoppable.StopServices(s.T(), s.cfg.GRPCAddress) - }) - s.cfg.Mnemonics = append(s.cfg.Mnemonics, validatorMnemonic) s.cfg.ChainID = app.AppName diff --git a/protocol/x/stats/client/cli/query_test.go b/protocol/x/stats/client/cli/query_test.go index 29127faefd..10faef1a74 100644 --- a/protocol/x/stats/client/cli/query_test.go +++ b/protocol/x/stats/client/cli/query_test.go @@ -3,7 +3,6 @@ package cli_test import ( - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "strconv" "testing" @@ -40,10 +39,6 @@ func setupNetwork( net := network.New(t, cfg) ctx := net.Validators[0].ClientCtx - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return net, ctx } diff --git a/protocol/x/subaccounts/client/cli/query_subaccount_test.go b/protocol/x/subaccounts/client/cli/query_subaccount_test.go index fcd0d7b7b1..6f1e6f03d7 100644 --- a/protocol/x/subaccounts/client/cli/query_subaccount_test.go +++ b/protocol/x/subaccounts/client/cli/query_subaccount_test.go @@ -15,7 +15,6 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" keepertest "github.com/dydxprotocol/v4-chain/protocol/testutil/keeper" "github.com/dydxprotocol/v4-chain/protocol/testutil/network" "github.com/dydxprotocol/v4-chain/protocol/testutil/nullify" @@ -47,10 +46,6 @@ func networkWithSubaccountObjects(t *testing.T, n int) (*network.Network, []type require.NoError(t, err) cfg.GenesisState[types.ModuleName] = buf - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return network.New(t, cfg), state.Subaccounts } diff --git a/protocol/x/vest/client/cli/query_vest_entry_test.go b/protocol/x/vest/client/cli/query_vest_entry_test.go index 5fde788bff..05377558e0 100644 --- a/protocol/x/vest/client/cli/query_vest_entry_test.go +++ b/protocol/x/vest/client/cli/query_vest_entry_test.go @@ -10,7 +10,6 @@ import ( tmcli "github.com/cometbft/cometbft/libs/cli" "github.com/cosmos/cosmos-sdk/client" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "github.com/dydxprotocol/v4-chain/protocol/testutil/network" "github.com/dydxprotocol/v4-chain/protocol/x/vest/client/cli" "github.com/dydxprotocol/v4-chain/protocol/x/vest/types" @@ -41,10 +40,6 @@ func setupNetwork( net := network.New(t, cfg) ctx := net.Validators[0].ClientCtx - t.Cleanup(func() { - stoppable.StopServices(t, cfg.GRPCAddress) - }) - return net, ctx }