Identify invalid signature within batch verification (#11582) (#11741)

* Identify invalid signature within batch verification (#11582)

* Fix issues found by linter

* Make deepsource happy

* Add signature description enums

* Make descriptions a mandatory field

* More readable error message of invalid signatures

* Add 'enable-verbose-sig-verification' option

* Fix format

* Move descriptions to package signing

* Add more validation and test cases

* Fix build failure

Co-authored-by: Nishant Das <nishdas93@gmail.com>
This commit is contained in:
Ye Ding
2022-12-20 18:41:47 +08:00
committed by GitHub
parent 90d5f6097c
commit e43152102e
20 changed files with 486 additions and 131 deletions

View File

@@ -78,6 +78,23 @@ func DeepNotSSZEqual(loggerFn assertionLoggerFn, expected, actual interface{}, m
}
}
// StringContains checks whether a string contains specified substring. If flag is false, inverse is checked.
func StringContains(loggerFn assertionLoggerFn, expected, actual string, flag bool, msg ...interface{}) {
if flag {
if !strings.Contains(actual, expected) {
errMsg := parseMsg("Expected substring is not found", msg...)
_, file, line, _ := runtime.Caller(2)
loggerFn("%s:%d %s, got: %v, want: %s", filepath.Base(file), line, errMsg, actual, expected)
}
} else {
if strings.Contains(actual, expected) {
errMsg := parseMsg("Unexpected substring is found", msg...)
_, file, line, _ := runtime.Caller(2)
loggerFn("%s:%d %s, got: %v, not want: %s", filepath.Base(file), line, errMsg, actual, expected)
}
}
}
// NoError asserts that error is nil.
func NoError(loggerFn assertionLoggerFn, err error, msg ...interface{}) {
if err != nil {