chore: enable errcheck linter (#16406)
This commit is contained in:
+4
-2
@@ -119,8 +119,10 @@ func TestRunMigrations(t *testing.T) {
|
||||
}
|
||||
|
||||
// Initialize the chain
|
||||
app.InitChain(&abci.RequestInitChain{})
|
||||
app.Commit()
|
||||
_, err := app.InitChain(&abci.RequestInitChain{})
|
||||
require.NoError(t, err)
|
||||
_, err = app.Commit()
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
||||
+23
-7
@@ -116,7 +116,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
ctx = ctx.WithBlockHeight(0)
|
||||
|
||||
// reinitialize all validators
|
||||
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
|
||||
err = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
|
||||
// donate any unwithdrawn outstanding reward fraction tokens to the community pool
|
||||
scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator())
|
||||
if err != nil {
|
||||
@@ -136,6 +136,9 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
}
|
||||
return false
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// reinitialize all delegations
|
||||
for _, del := range dels {
|
||||
@@ -162,7 +165,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
/* Handle staking state. */
|
||||
|
||||
// iterate through redelegations, reset creation height
|
||||
app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
|
||||
err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
|
||||
for i := range red.Entries {
|
||||
red.Entries[i].CreationHeight = 0
|
||||
}
|
||||
@@ -172,9 +175,12 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
}
|
||||
return false
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// iterate through unbonding delegations, reset creation height
|
||||
app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
|
||||
err = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
|
||||
for i := range ubd.Entries {
|
||||
ubd.Entries[i].CreationHeight = 0
|
||||
}
|
||||
@@ -184,7 +190,9 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// Iterate through validators by power descending, reset bond heights, and
|
||||
// update bond intra-tx counters.
|
||||
store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey))
|
||||
@@ -203,7 +211,9 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
validator.Jailed = true
|
||||
}
|
||||
|
||||
app.StakingKeeper.SetValidator(ctx, validator)
|
||||
if err = app.StakingKeeper.SetValidator(ctx, validator); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
counter++
|
||||
}
|
||||
|
||||
@@ -220,12 +230,18 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
|
||||
/* Handle slashing state. */
|
||||
|
||||
// reset start height on signing infos
|
||||
app.SlashingKeeper.IterateValidatorSigningInfos(
|
||||
err = app.SlashingKeeper.IterateValidatorSigningInfos(
|
||||
ctx,
|
||||
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
|
||||
info.StartHeight = 0
|
||||
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
|
||||
err := app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return false
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,12 @@ func TestCometRPC_SingleRPCServer(t *testing.T) {
|
||||
|
||||
return cs
|
||||
})
|
||||
defer nodes.StopAndWait()
|
||||
defer func() {
|
||||
err := nodes.StopAndWait()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
require.NoError(t, err)
|
||||
|
||||
// Once HTTP client to be shared across the following subtests.
|
||||
@@ -160,8 +165,12 @@ func TestCometRPC_MultipleRPCError(t *testing.T) {
|
||||
rootDir,
|
||||
).RPCListen() // Every node has RPCListen enabled, which will cause a failure.
|
||||
})
|
||||
defer nodes.StopAndWait()
|
||||
|
||||
defer func() {
|
||||
err := nodes.StopAndWait()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
// Returned error is convertible to CometRPCInUseError.
|
||||
// We can't test the exact value because it includes a stack trace.
|
||||
require.Error(t, err)
|
||||
|
||||
@@ -125,7 +125,12 @@ func TestCometStarter_PortContention(t *testing.T) {
|
||||
|
||||
// Ensure nodes are stopped completely,
|
||||
// so that we don't get t.Cleanup errors around directories not being empty.
|
||||
defer nodes.StopAndWait()
|
||||
defer func() {
|
||||
err := nodes.StopAndWait()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
require.NoError(t, err)
|
||||
|
||||
// Ensure that the height advances.
|
||||
|
||||
@@ -95,13 +95,18 @@ func Example_basicUsage() {
|
||||
dir, // Where to put files on disk.
|
||||
).Logger(logger.With("root_module", fmt.Sprintf("comet_%d", idx)))
|
||||
})
|
||||
// StopAndWait must be deferred before the error check,
|
||||
// as the nodes value may contain some successfully started instances.
|
||||
defer nodes.StopAndWait()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// StopAndWait must be deferred before the error check,"os"
|
||||
// as the nodes value may contain some successfully started instances.
|
||||
defer func() {
|
||||
err := nodes.StopAndWait()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
// Now you can begin interacting with the nodes.
|
||||
// For the sake of this example, we'll just check
|
||||
// a couple simple properties of one node.
|
||||
|
||||
+6
-5
@@ -180,9 +180,10 @@ func TestAppImportExport(t *testing.T) {
|
||||
|
||||
ctxA := app.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()})
|
||||
ctxB := newApp.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()})
|
||||
newApp.ModuleManager.InitGenesis(ctxB, app.AppCodec(), genesisState)
|
||||
newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)
|
||||
|
||||
_, err = newApp.ModuleManager.InitGenesis(ctxB, app.AppCodec(), genesisState)
|
||||
require.NoError(t, err)
|
||||
err = newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)
|
||||
require.NoError(t, err)
|
||||
fmt.Printf("comparing stores...\n")
|
||||
|
||||
// skip certain prefixes
|
||||
@@ -288,11 +289,11 @@ func TestAppSimulationAfterImport(t *testing.T) {
|
||||
newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
|
||||
require.Equal(t, "SimApp", newApp.Name())
|
||||
|
||||
newApp.InitChain(&abci.RequestInitChain{
|
||||
_, err = newApp.InitChain(&abci.RequestInitChain{
|
||||
AppStateBytes: exported.AppState,
|
||||
ChainId: SimAppChainID,
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
_, _, err = simulation.SimulateFromSeed(
|
||||
t,
|
||||
os.Stdout,
|
||||
|
||||
Reference in New Issue
Block a user