diff --git a/score_params.go b/score_params.go index 65a1919..4d2ffff 100644 --- a/score_params.go +++ b/score_params.go @@ -179,6 +179,9 @@ func (p *TopicScoreParams) validate() error { } // check P1 + if p.TimeInMeshQuantum == 0 { + return fmt.Errorf("invalid TimeInMeshQuantum; must be non zero") + } if p.TimeInMeshWeight < 0 { return fmt.Errorf("invalid TimeInMeshWeight; must be positive (or 0 to disable)") } diff --git a/score_params_test.go b/score_params_test.go index f481863..66482d2 100644 --- a/score_params_test.go +++ b/score_params_test.go @@ -32,6 +32,10 @@ func TestPeerScoreThresholdsValidation(t *testing.T) { } func TestTopicScoreParamsValidation(t *testing.T) { + if (&TopicScoreParams{}).validate() == nil { + t.Fatal("expected validation error") + } + if (&TopicScoreParams{TopicWeight: -1}).validate() == nil { t.Fatal("expected validation error") }