Skip to content

Commit

Permalink
Merge pull request #16 from initia-labs/fix/return-err-at-execute-mes…
Browse files Browse the repository at this point in the history
…sages

return error when it met error at iteration
  • Loading branch information
beer-1 authored Jan 9, 2024
2 parents f5c2684 + 8f0404a commit a93c34f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 2 additions & 6 deletions x/opchild/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,12 @@ func (ms MsgServer) ExecuteMessages(ctx context.Context, req *types.MsgExecuteMe
var res *sdk.Result
res, err = handler(cacheCtx, msg)
if err != nil {
break
return nil, err
}

events = append(events, res.GetEvents()...)

}
if err != nil {
return nil, err
}

writeCache()

// TODO - merge events of MsgExecuteMessages itself
Expand Down Expand Up @@ -258,7 +255,6 @@ func (ms MsgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams
}

return &types.MsgUpdateParamsResponse{}, nil

}

// SpendFeePool implements MsgServer interface.
Expand Down
16 changes: 16 additions & 0 deletions x/opchild/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ func Test_MsgServer_ExecuteMessages(t *testing.T) {
require.NoError(t, err)
require.Len(t, vals, 1)
require.Equal(t, vals[0].Moniker, "val2")

// should failed with err (denom not sorted)
params := types.DefaultParams()
params.MinGasPrices = sdk.DecCoins{{
Denom: "22222",
Amount: math.LegacyNewDec(1),
}, {
Denom: "11111",
Amount: math.LegacyNewDec(2),
}}
updateParamsMsg := types.NewMsgUpdateParams(moduleAddr, &params)
msg, err = types.NewMsgExecuteMessages(addrsStr[0], []sdk.Msg{updateParamsMsg})
require.NoError(t, err)

_, err = ms.ExecuteMessages(ctx, msg)
require.Error(t, err)
}

/////////////////////////////////////////
Expand Down

0 comments on commit a93c34f

Please sign in to comment.