From eb0260aa377bb45b6647692b6587ea9fa8c52203 Mon Sep 17 00:00:00 2001 From: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Date: Wed, 12 Jul 2023 14:26:09 +0200 Subject: [PATCH] fix: Sims failing and not skipping with empty valset (#16947) --- simapp/sim_test.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/simapp/sim_test.go b/simapp/sim_test.go index f0b33efd84b9..00dba9ec7b8c 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -167,20 +167,18 @@ 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()}) - _, err = newApp.ModuleManager.InitGenesis(ctxB, app.AppCodec(), genesisState) require.NoError(t, err) err = newApp.StoreConsensusParams(ctxB, exported.ConsensusParams) require.NoError(t, err)