Skip to content

Commit

Permalink
check duplicate seq in genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
tkxkd0159 committed May 7, 2024
1 parent 4136321 commit b6c2f13
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion x/fbridge/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,18 @@ func validateSendingState(state SendingState) error {
if state.NextSeq-1 != uint64(len(state.SeqToBlocknum)) {
return errors.New("sequence to blocknum mapping is invalid")

Check warning on line 91 in x/fbridge/types/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/fbridge/types/genesis.go#L90-L91

Added lines #L90 - L91 were not covered by tests
}

chkSeq := make(map[uint64]struct{})
for _, v := range state.SeqToBlocknum {
if v.Blocknum < 1 || v.Seq < 1 {
if v.Blocknum == 0 || v.Seq == 0 {
return errors.New("blocknum and seq must be positive")

Check warning on line 97 in x/fbridge/types/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/fbridge/types/genesis.go#L94-L97

Added lines #L94 - L97 were not covered by tests
}

if _, ok := chkSeq[v.Seq]; ok {
return errors.New("duplicate sequence")

Check warning on line 101 in x/fbridge/types/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/fbridge/types/genesis.go#L100-L101

Added lines #L100 - L101 were not covered by tests
}

chkSeq[v.Seq] = struct{}{}

Check warning on line 104 in x/fbridge/types/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/fbridge/types/genesis.go#L104

Added line #L104 was not covered by tests
}

return nil

Check warning on line 107 in x/fbridge/types/genesis.go

View check run for this annotation

Codecov / codecov/patch

x/fbridge/types/genesis.go#L107

Added line #L107 was not covered by tests
Expand Down

0 comments on commit b6c2f13

Please sign in to comment.