From bb106cb50d32722599842db0321ec780dbdf3349 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 25 Aug 2023 01:15:37 +0200 Subject: [PATCH] test(baseapp): use no-op logger (#17528) --- baseapp/abci_test.go | 24 ++++++++++++------------ baseapp/baseapp_test.go | 14 +++++++------- baseapp/grpcrouter_test.go | 2 +- baseapp/msg_service_router_test.go | 4 ++-- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index e24af9706503..3de62e4fb0f7 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -78,7 +78,7 @@ func TestABCI_First_block_Height(t *testing.T) { func TestABCI_InitChain(t *testing.T) { name := t.Name() db := dbm.NewMemDB() - logger := log.NewTestLogger(t) + logger := log.NewNopLogger() app := baseapp.NewBaseApp(name, logger, db, nil, baseapp.SetChainID("test-chain-id")) capKey := storetypes.NewKVStoreKey("main") @@ -180,7 +180,7 @@ func TestABCI_InitChain(t *testing.T) { func TestABCI_InitChain_WithInitialHeight(t *testing.T) { name := t.Name() db := dbm.NewMemDB() - app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) + app := baseapp.NewBaseApp(name, log.NewNopLogger(), db, nil) _, err := app.InitChain( &abci.RequestInitChain{ @@ -197,7 +197,7 @@ func TestABCI_InitChain_WithInitialHeight(t *testing.T) { func TestABCI_FinalizeBlock_WithInitialHeight(t *testing.T) { name := t.Name() db := dbm.NewMemDB() - app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) + app := baseapp.NewBaseApp(name, log.NewNopLogger(), db, nil) _, err := app.InitChain( &abci.RequestInitChain{ @@ -219,7 +219,7 @@ func TestABCI_FinalizeBlock_WithInitialHeight(t *testing.T) { func TestABCI_FinalizeBlock_WithBeginAndEndBlocker(t *testing.T) { name := t.Name() db := dbm.NewMemDB() - app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) + app := baseapp.NewBaseApp(name, log.NewNopLogger(), db, nil) app.SetBeginBlocker(func(ctx sdk.Context) (sdk.BeginBlock, error) { return sdk.BeginBlock{ @@ -286,7 +286,7 @@ func TestABCI_FinalizeBlock_WithBeginAndEndBlocker(t *testing.T) { func TestABCI_ExtendVote(t *testing.T) { name := t.Name() db := dbm.NewMemDB() - app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) + app := baseapp.NewBaseApp(name, log.NewNopLogger(), db, nil) app.SetExtendVoteHandler(func(ctx sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { voteExt := "foo" + hex.EncodeToString(req.Hash) + strconv.FormatInt(req.Height, 10) @@ -369,7 +369,7 @@ func TestABCI_ExtendVote(t *testing.T) { func TestABCI_OnlyVerifyVoteExtension(t *testing.T) { name := t.Name() db := dbm.NewMemDB() - app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) + app := baseapp.NewBaseApp(name, log.NewNopLogger(), db, nil) app.SetVerifyVoteExtensionHandler(func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { // do some kind of verification here @@ -503,7 +503,7 @@ func TestABCI_P2PQuery(t *testing.T) { func TestBaseApp_PrepareCheckState(t *testing.T) { db := dbm.NewMemDB() name := t.Name() - logger := log.NewTestLogger(t) + logger := log.NewNopLogger() cp := &cmtproto.ConsensusParams{ Block: &cmtproto.BlockParams{ @@ -532,7 +532,7 @@ func TestBaseApp_PrepareCheckState(t *testing.T) { func TestBaseApp_Precommit(t *testing.T) { db := dbm.NewMemDB() name := t.Name() - logger := log.NewTestLogger(t) + logger := log.NewNopLogger() cp := &cmtproto.ConsensusParams{ Block: &cmtproto.BlockParams{ @@ -1238,7 +1238,7 @@ func TestABCI_Query(t *testing.T) { } func TestABCI_GetBlockRetentionHeight(t *testing.T) { - logger := log.NewTestLogger(t) + logger := log.NewNopLogger() db := dbm.NewMemDB() name := t.Name() @@ -1351,7 +1351,7 @@ func TestABCI_GetBlockRetentionHeight(t *testing.T) { func TestPrepareCheckStateCalledWithCheckState(t *testing.T) { t.Parallel() - logger := log.NewTestLogger(t) + logger := log.NewNopLogger() db := dbm.NewMemDB() name := t.Name() app := baseapp.NewBaseApp(name, logger, db, nil) @@ -1374,7 +1374,7 @@ func TestPrepareCheckStateCalledWithCheckState(t *testing.T) { func TestPrecommiterCalledWithDeliverState(t *testing.T) { t.Parallel() - logger := log.NewTestLogger(t) + logger := log.NewNopLogger() db := dbm.NewMemDB() name := t.Name() app := baseapp.NewBaseApp(name, logger, db, nil) @@ -2009,7 +2009,7 @@ func TestABCI_HaltChain(t *testing.T) { func TestBaseApp_PreFinalizeBlockHook(t *testing.T) { db := dbm.NewMemDB() name := t.Name() - logger := log.NewTestLogger(t) + logger := log.NewNopLogger() app := baseapp.NewBaseApp(name, logger, db, nil) _, err := app.InitChain(&abci.RequestInitChain{}) diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 0fef6903b776..77c7c955e0ec 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -66,7 +66,7 @@ func NewBaseAppSuite(t *testing.T, opts ...func(*baseapp.BaseApp)) *BaseAppSuite txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes) db := dbm.NewMemDB() - app := baseapp.NewBaseApp(t.Name(), log.NewTestLogger(t), db, txConfig.TxDecoder(), opts...) + app := baseapp.NewBaseApp(t.Name(), log.NewNopLogger(), db, txConfig.TxDecoder(), opts...) require.Equal(t, t.Name(), app.Name()) app.SetInterfaceRegistry(cdc.InterfaceRegistry()) @@ -91,7 +91,7 @@ func getQueryBaseapp(t *testing.T) *baseapp.BaseApp { db := dbm.NewMemDB() name := t.Name() - app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) + app := baseapp.NewBaseApp(name, log.NewNopLogger(), db, nil) _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) require.NoError(t, err) @@ -192,7 +192,7 @@ func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...fun } func TestLoadVersion(t *testing.T) { - logger := log.NewTestLogger(t) + logger := log.NewNopLogger() pruningOpt := baseapp.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) db := dbm.NewMemDB() name := t.Name() @@ -323,7 +323,7 @@ func TestSetLoader(t *testing.T) { if tc.setLoader != nil { opts = append(opts, tc.setLoader) } - app := baseapp.NewBaseApp(t.Name(), log.NewTestLogger(t), db, nil, opts...) + app := baseapp.NewBaseApp(t.Name(), log.NewNopLogger(), db, nil, opts...) app.MountStores(storetypes.NewKVStoreKey(tc.loadStoreKey)) err := app.LoadLatestVersion() require.Nil(t, err) @@ -346,7 +346,7 @@ func TestVersionSetterGetter(t *testing.T) { pruningOpt := baseapp.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningDefault)) db := dbm.NewMemDB() name := t.Name() - app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil, pruningOpt) + app := baseapp.NewBaseApp(name, log.NewNopLogger(), db, nil, pruningOpt) require.Equal(t, "", app.Version()) res, err := app.Query(context.TODO(), &abci.RequestQuery{Path: "app/version"}) @@ -405,7 +405,7 @@ func TestOptionFunction(t *testing.T) { } db := dbm.NewMemDB() - bap := baseapp.NewBaseApp("starting name", log.NewTestLogger(t), db, nil, testChangeNameHelper("new name")) + bap := baseapp.NewBaseApp("starting name", log.NewNopLogger(), db, nil, testChangeNameHelper("new name")) require.Equal(t, bap.Name(), "new name", "BaseApp should have had name changed via option function") } @@ -597,7 +597,7 @@ func TestABCI_CreateQueryContext(t *testing.T) { db := dbm.NewMemDB() name := t.Name() - app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) + app := baseapp.NewBaseApp(name, log.NewNopLogger(), db, nil) _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) require.NoError(t, err) diff --git a/baseapp/grpcrouter_test.go b/baseapp/grpcrouter_test.go index 593125c692f8..976708ba58c8 100644 --- a/baseapp/grpcrouter_test.go +++ b/baseapp/grpcrouter_test.go @@ -59,7 +59,7 @@ func TestRegisterQueryServiceTwice(t *testing.T) { err := depinject.Inject( depinject.Configs( makeMinimalConfig(), - depinject.Supply(log.NewTestLogger(t)), + depinject.Supply(log.NewNopLogger()), ), &appBuilder) require.NoError(t, err) diff --git a/baseapp/msg_service_router_test.go b/baseapp/msg_service_router_test.go index 23acbe99409b..a9b5cd161379 100644 --- a/baseapp/msg_service_router_test.go +++ b/baseapp/msg_service_router_test.go @@ -30,7 +30,7 @@ func TestRegisterMsgService(t *testing.T) { err := depinject.Inject( depinject.Configs( makeMinimalConfig(), - depinject.Supply(log.NewTestLogger(t)), + depinject.Supply(log.NewNopLogger()), ), &appBuilder, ®istry) require.NoError(t, err) app := appBuilder.Build(dbm.NewMemDB(), nil) @@ -62,7 +62,7 @@ func TestRegisterMsgServiceTwice(t *testing.T) { err := depinject.Inject( depinject.Configs( makeMinimalConfig(), - depinject.Supply(log.NewTestLogger(t)), + depinject.Supply(log.NewNopLogger()), ), &appBuilder, ®istry) require.NoError(t, err) db := dbm.NewMemDB()