diff --git a/.golangci.yml b/.golangci.yml index 46a0a0ca..5b4a6f1c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,6 +24,7 @@ linters: - staticcheck - stylecheck - typecheck + - thelper - unconvert - unparam - unused diff --git a/app/app_test.go b/app/app_test.go index 3c2adb58..57706fc9 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -124,6 +124,7 @@ func TestGetEnabledProposals(t *testing.T) { } func SetupGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, _ []wasm.Option, app *MigalooApp, balances ...banktypes.Balance) GenesisState { + t.Helper() genesisState := NewDefaultGenesisState() // set genesis accounts authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) diff --git a/app/test_access.go b/app/test_access.go index 0ffa02be..b040bb2a 100644 --- a/app/test_access.go +++ b/app/test_access.go @@ -24,8 +24,10 @@ type TestSupport struct { app *MigalooApp } -func NewTestSupport(t testing.TB, app *MigalooApp) *TestSupport { - return &TestSupport{t: t, app: app} +// NewTestSupport creates a new TestSupport instance, which provides access to the app for testing. +func NewTestSupport(tb testing.TB, app *MigalooApp) *TestSupport { + tb.Helper() + return &TestSupport{t: tb, app: app} } func (s TestSupport) IBCKeeper() *ibckeeper.Keeper { diff --git a/app/test_helpers.go b/app/test_helpers.go index fef77b6f..c43b03a2 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -60,13 +60,14 @@ var DefaultConsensusParams = &tmproto.ConsensusParams{ }, } -func setup(t testing.TB, withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*MigalooApp, GenesisState) { - nodeHome := t.TempDir() +func setup(tb testing.TB, withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*MigalooApp, GenesisState) { + tb.Helper() + nodeHome := tb.TempDir() snapshotDir := filepath.Join(nodeHome, "data", "snapshots") snapshotDB, err := dbm.NewDB("metadata", dbm.MemDBBackend, snapshotDir) - require.NoError(t, err) + require.NoError(tb, err) snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir) - require.NoError(t, err) + require.NoError(tb, err) baseAppOpts := []func(*bam.BaseApp){ bam.SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(50000, 2)), } @@ -102,6 +103,7 @@ func Setup(isCheckTx bool, opts ...wasm.Option) *MigalooApp { } func SetupMigalooAppWithValSet(t *testing.T) *MigalooApp { + t.Helper() // generate validator private/public key privVal := mock.NewPV() pubKey, err := privVal.GetPubKey() @@ -131,6 +133,7 @@ func SetupMigalooAppWithValSet(t *testing.T) *MigalooApp { // of one consensus engine unit (10^6) in the default token of the MigalooApp from first genesis // account. A Nop logger is set in MigalooApp. func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, opts []wasm.Option, balances ...banktypes.Balance) *MigalooApp { + t.Helper() app, genesisState := setup(t, true, 5, opts...) genesisState, err := simtestutil.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, genAccs, balances...) require.NoError(t, err) @@ -240,8 +243,9 @@ func GenesisStateWithValSet(app *MigalooApp) GenesisState { } // SetupWithEmptyStore setup a wasmd app instance with empty DB -func SetupWithEmptyStore(t testing.TB) *MigalooApp { - app, _ := setup(t, false, 0) +func SetupWithEmptyStore(tb testing.TB) *MigalooApp { + tb.Helper() + app, _ := setup(tb, false, 0) return app } @@ -366,6 +370,7 @@ func TestAddr(addr string, bech string) (sdk.AccAddress, error) { // CheckBalance checks the balance of an account. func CheckBalance(t *testing.T, app *MigalooApp, addr sdk.AccAddress, balances sdk.Coins) { + t.Helper() ctxCheck := app.BaseApp.NewContext(true, tmproto.Header{}) require.True(t, balances.IsEqual(app.BankKeeper.GetAllBalances(ctxCheck, addr))) } @@ -380,6 +385,7 @@ func SignCheckDeliver( t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { + t.Helper() tx, err := simtestutil.GenSignedMockTx( rand.New(rand.NewSource(time.Now().UnixNano())), txCfg, @@ -430,6 +436,7 @@ func SignAndDeliver( t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { + t.Helper() tx, err := simtestutil.GenSignedMockTx( rand.New(rand.NewSource(time.Now().UnixNano())), txCfg,