Skip to content

Commit

Permalink
fix: Sims failing and not skipping with empty valset (backport #16947) (
Browse files Browse the repository at this point in the history
#16952)

Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people authored Jul 12, 2023
1 parent 0028264 commit 12d9cdc
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,21 @@ func TestAppImportExport(t *testing.T) {
err = json.Unmarshal(exported.AppState, &genesisState)
require.NoError(t, err)

defer func() {
if r := recover(); r != nil {
err := fmt.Sprintf("%v", r)
if !strings.Contains(err, "validator set is empty after InitGenesis") {
panic(r)
}
ctxA := app.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()})
ctxB := newApp.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()})
_, err = newApp.ModuleManager.InitGenesis(ctxB, app.AppCodec(), genesisState)

if err != nil {
if strings.Contains(err.Error(), "validator set is empty after InitGenesis") {
logger.Info("Skipping simulation as all validators have been unbonded")
logger.Info("err", err, "stacktrace", string(debug.Stack()))
return
}
}()

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)
}

require.NoError(t, err)
err = newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)
require.NoError(t, err)
fmt.Printf("comparing stores...\n")

// skip certain prefixes
Expand Down

0 comments on commit 12d9cdc

Please sign in to comment.