From 05529f9c13f4cf10f706b9fb59ec53d0e24d7378 Mon Sep 17 00:00:00 2001 From: "Samuel E. Moelius" <35515885+smoelius@users.noreply.github.com> Date: Mon, 4 Mar 2019 07:27:01 -0500 Subject: [PATCH] Merge PR #3794: Write changes to store. --- x/gov/simulation/msgs.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/x/gov/simulation/msgs.go b/x/gov/simulation/msgs.go index 551ed65386..4c5eddd372 100644 --- a/x/gov/simulation/msgs.go +++ b/x/gov/simulation/msgs.go @@ -89,9 +89,12 @@ func SimulateMsgSubmitProposal(k gov.Keeper) simulation.Operation { } func simulateHandleMsgSubmitProposal(msg gov.MsgSubmitProposal, handler sdk.Handler, ctx sdk.Context, event func(string)) (action string, ok bool) { - ctx, _ = ctx.CacheContext() + ctx, write := ctx.CacheContext() result := handler(ctx, msg) ok = result.IsOK() + if ok { + write() + } event(fmt.Sprintf("gov/MsgSubmitProposal/%v", ok)) action = fmt.Sprintf("TestMsgSubmitProposal: ok %v, msg %s", ok, msg.GetSignBytes()) return @@ -125,8 +128,11 @@ func SimulateMsgDeposit(k gov.Keeper) simulation.Operation { if msg.ValidateBasic() != nil { return "", nil, fmt.Errorf("expected msg to pass ValidateBasic: %s", msg.GetSignBytes()) } - ctx, _ = ctx.CacheContext() + ctx, write := ctx.CacheContext() result := gov.NewHandler(k)(ctx, msg) + if result.IsOK() { + write() + } event(fmt.Sprintf("gov/MsgDeposit/%v", result.IsOK())) action = fmt.Sprintf("TestMsgDeposit: ok %v, msg %s", result.IsOK(), msg.GetSignBytes()) return action, nil, nil