update error message and add tests (#8166)

This commit is contained in:
colin axnér 2020-12-14 15:56:10 +01:00 committed by GitHub
parent e4e39234c8
commit ed5f120232
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -64,7 +64,7 @@ func ValidateEvidenceParams(i interface{}) error {
}
if v.MaxBytes < 0 {
return fmt.Errorf("maximum evidence bytes must be positive: %v", v.MaxBytes)
return fmt.Errorf("maximum evidence bytes must be non-negative: %v", v.MaxBytes)
}
return nil

View File

@ -37,7 +37,10 @@ func TestValidateEvidenceParams(t *testing.T) {
{&tmproto.EvidenceParams{}, true},
{tmproto.EvidenceParams{}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: -1, MaxAgeDuration: 18004000, MaxBytes: 5000000}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: -1, MaxBytes: 5000000}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: -1}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 5000000}, false},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 0}, false},
}
for _, tc := range testCases {