Skip to content

Commit

Permalink
go/staking/api: Check if thresholds for all kinds are defined in genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
tjanez committed Jan 31, 2020
1 parent 4e22a8a commit 01d29d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .changelog/2633.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/staking/api: Check if thresholds for all kinds are defined in genesis.
8 changes: 6 additions & 2 deletions go/staking/api/sanity_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ func SanityCheckAccountShares(acct *Account, delegations map[signature.PublicKey

// SanityCheck does basic sanity checking on the genesis state.
func (g *Genesis) SanityCheck(now epochtime.EpochTime) error { // nolint: gocyclo
for thr, val := range g.Parameters.Thresholds {
for kind := KindEntity; kind <= KindMax; kind++ {
val, ok := g.Parameters.Thresholds[kind]
if !ok {
return fmt.Errorf("staking: sanity check failed: threshold for kind '%s' not defined", kind)
}
if !val.IsValid() {
return fmt.Errorf("staking: sanity check failed: threshold '%s' has invalid value", thr.String())
return fmt.Errorf("staking: sanity check failed: threshold '%s' has invalid value", kind)
}
}

Expand Down

0 comments on commit 01d29d0

Please sign in to comment.