Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix validation of submitproof #118

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading