Skip to content

Commit

Permalink
fix validation of submit-proof
Browse files Browse the repository at this point in the history
  • Loading branch information
any0Ne1010 committed Feb 21, 2024
1 parent c364bff commit 159eed2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions x/committer/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ func (k msgServer) SubmitProof(goCtx context.Context, msg *types.MsgSubmitProof)
Status: types.VotingStatus,
}

if lastProposal.EndIndex+1 != proposal.StartIndex {
if !(lastProposal.EndIndex == 0 && proposal.StartIndex == 1) &&
!(lastProposal.EndIndex != 0 && lastProposal.EndIndex == proposal.StartIndex) {
return &types.MsgSubmitProofResponse{},
fmt.Errorf(
"proposal start index must equal last proposal end index + 1, "+
"if last proposal end index is 0, then proposal start index must be 1, "+
" else if last proposal end index is not 0, then proposal start"+
" index must equal last proposal end index, "+
"last proposal end index: %s", fmt.Sprint(lastProposal.EndIndex))
}

Expand Down
2 changes: 1 addition & 1 deletion x/committer/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestSubmitProof(t *testing.T) {
EndIndex: 11,
},
isError: true,
errMsg: "proposal start index must equal last proposal end index + 1",
errMsg: "proposal start index must equal last proposal end index",
preRun: func(ctx sdk.Context, k keeper.Keeper) {
k.SetLastProposal(ctx, types.Proposal{
Id: 1,
Expand Down

0 comments on commit 159eed2

Please sign in to comment.