diff --git a/testutil/network/network.go b/testutil/network/network.go index b78248f16205..bb016a0a2541 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -273,6 +273,7 @@ type ( ValAddress sdk.ValAddress RPCClient cmtclient.Client + app servertypes.Application tmNode *node.Node api *api.Server grpc *grpc.Server @@ -611,8 +612,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { l.Log("starting test network...") for idx, v := range network.Validators { - err := startInProcess(cfg, v) - if err != nil { + if err := startInProcess(cfg, v); err != nil { return nil, err } l.Log("started validator", idx) @@ -803,6 +803,12 @@ func (n *Network) Cleanup() { if v.grpcWeb != nil { _ = v.grpcWeb.Close() } + + if v.app != nil { + if err := v.app.Close(); err != nil { + n.Logger.Log("failed to stop validator ABCI application", "err", err) + } + } } time.Sleep(100 * time.Millisecond) diff --git a/testutil/network/util.go b/testutil/network/util.go index 9615751600b9..c940e9225d8b 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -18,6 +18,8 @@ import ( cmttime "github.com/cometbft/cometbft/types/time" "golang.org/x/sync/errgroup" + "cosmossdk.io/log" + "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" @@ -43,6 +45,8 @@ func startInProcess(cfg Config, val *Validator) error { } app := cfg.AppConstructor(*val) + val.app = app + appGenesisProvider := func() (*cmttypes.GenesisDoc, error) { appGenesis, err := genutiltypes.AppGenesisFromFile(cmtCfg.GenesisFile()) if err != nil { @@ -101,14 +105,14 @@ func startInProcess(cfg Config, val *Validator) error { // Start the gRPC server in a goroutine. Note, the provided ctx will ensure // that the server is gracefully shut down. val.errGroup.Go(func() error { - return servergrpc.StartGRPCServer(ctx, logger.With("module", "grpc-server"), grpcCfg, grpcSrv) + return servergrpc.StartGRPCServer(ctx, logger.With(log.ModuleKey, "grpc-server"), grpcCfg, grpcSrv) }) val.grpc = grpcSrv } if val.APIAddress != "" { - apiSrv := api.New(val.ClientCtx, logger.With("module", "api-server"), val.grpc) + apiSrv := api.New(val.ClientCtx, logger.With(log.ModuleKey, "api-server"), val.grpc) app.RegisterAPIRoutes(apiSrv, val.AppConfig.API) val.errGroup.Go(func() error {