mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
* Ran gopls modernize to fix everything go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./... * Override rules_go provided dependency for golang.org/x/tools to v0.38.0. To update this, checked out rules_go, then ran `bazel run //go/tools/releaser -- upgrade-dep -mirror=false org_golang_x_tools` and copied the patches. * Fix buildtag violations and ignore buildtag violations in external * Introduce modernize analyzer package. * Add modernize "any" analyzer. * Fix violations of any analyzer * Add modernize "appendclipped" analyzer. * Fix violations of appendclipped * Add modernize "bloop" analyzer. * Add modernize "fmtappendf" analyzer. * Add modernize "forvar" analyzer. * Add modernize "mapsloop" analyzer. * Add modernize "minmax" analyzer. * Fix violations of minmax analyzer * Add modernize "omitzero" analyzer. * Add modernize "rangeint" analyzer. * Fix violations of rangeint. * Add modernize "reflecttypefor" analyzer. * Fix violations of reflecttypefor analyzer. * Add modernize "slicescontains" analyzer. * Add modernize "slicessort" analyzer. * Add modernize "slicesdelete" analyzer. This is disabled by default for now. See https://go.dev/issue/73686. * Add modernize "stringscutprefix" analyzer. * Add modernize "stringsbuilder" analyzer. * Fix violations of stringsbuilder analyzer. * Add modernize "stringsseq" analyzer. * Add modernize "testingcontext" analyzer. * Add modernize "waitgroup" analyzer. * Changelog fragment * gofmt * gazelle * Add modernize "newexpr" analyzer. * Disable newexpr until go1.26 * Add more details in WORKSPACE on how to update the override * @nalepae feedback on min() * gofmt * Fix violations of forvar
84 lines
3.4 KiB
Go
84 lines
3.4 KiB
Go
package assert
|
|
|
|
import (
|
|
"github.com/OffchainLabs/prysm/v7/testing/assertions"
|
|
"github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
// Equal compares values using comparison operator.
|
|
func Equal(tb assertions.AssertionTestingTB, expected, actual any, msg ...any) {
|
|
assertions.Equal(tb.Errorf, expected, actual, msg...)
|
|
}
|
|
|
|
// NotEqual compares values using comparison operator.
|
|
func NotEqual(tb assertions.AssertionTestingTB, expected, actual any, msg ...any) {
|
|
assertions.NotEqual(tb.Errorf, expected, actual, msg...)
|
|
}
|
|
|
|
// DeepEqual compares values using DeepEqual.
|
|
// NOTE: this function does not work for checking arrays/slices or maps of protobuf messages.
|
|
// For arrays/slices, please use DeepSSZEqual.
|
|
// For maps, please iterate through and compare the individual keys and values.
|
|
func DeepEqual(tb assertions.AssertionTestingTB, expected, actual any, msg ...any) {
|
|
assertions.DeepEqual(tb.Errorf, expected, actual, msg...)
|
|
}
|
|
|
|
// DeepNotEqual compares values using DeepEqual.
|
|
// NOTE: this function does not work for checking arrays/slices or maps of protobuf messages.
|
|
// For arrays/slices, please use DeepNotSSZEqual.
|
|
// For maps, please iterate through and compare the individual keys and values.
|
|
func DeepNotEqual(tb assertions.AssertionTestingTB, expected, actual any, msg ...any) {
|
|
assertions.DeepNotEqual(tb.Errorf, expected, actual, msg...)
|
|
}
|
|
|
|
// DeepSSZEqual compares values using ssz.DeepEqual.
|
|
func DeepSSZEqual(tb assertions.AssertionTestingTB, expected, actual any, msg ...any) {
|
|
assertions.DeepSSZEqual(tb.Errorf, expected, actual, msg...)
|
|
}
|
|
|
|
// DeepNotSSZEqual compares values using ssz.DeepEqual.
|
|
func DeepNotSSZEqual(tb assertions.AssertionTestingTB, expected, actual any, msg ...any) {
|
|
assertions.DeepNotSSZEqual(tb.Errorf, expected, actual, msg...)
|
|
}
|
|
|
|
// StringContains asserts a string contains specified substring.
|
|
func StringContains(tb assertions.AssertionTestingTB, expected, actual string, msg ...any) {
|
|
assertions.StringContains(tb.Errorf, expected, actual, true, msg...)
|
|
}
|
|
|
|
// StringNotContains asserts a string does not contain specified substring.
|
|
func StringNotContains(tb assertions.AssertionTestingTB, expected, actual string, msg ...any) {
|
|
assertions.StringContains(tb.Errorf, expected, actual, false, msg...)
|
|
}
|
|
|
|
// NoError asserts that error is nil.
|
|
func NoError(tb assertions.AssertionTestingTB, err error, msg ...any) {
|
|
assertions.NoError(tb.Errorf, err, msg...)
|
|
}
|
|
|
|
// ErrorContains asserts that actual error contains wanted message.
|
|
func ErrorContains(tb assertions.AssertionTestingTB, want string, err error, msg ...any) {
|
|
assertions.ErrorContains(tb.Errorf, want, err, msg...)
|
|
}
|
|
|
|
// NotNil asserts that passed value is not nil.
|
|
func NotNil(tb assertions.AssertionTestingTB, obj any, msg ...any) {
|
|
assertions.NotNil(tb.Errorf, obj, msg...)
|
|
}
|
|
|
|
// LogsContain checks that the desired string is a subset of the current log output.
|
|
func LogsContain(tb assertions.AssertionTestingTB, hook *test.Hook, want string, msg ...any) {
|
|
assertions.LogsContain(tb.Errorf, hook, want, true, msg...)
|
|
}
|
|
|
|
// LogsDoNotContain is the inverse check of LogsContain.
|
|
func LogsDoNotContain(tb assertions.AssertionTestingTB, hook *test.Hook, want string, msg ...any) {
|
|
assertions.LogsContain(tb.Errorf, hook, want, false, msg...)
|
|
}
|
|
|
|
// NotEmpty checks that the object fields are not empty. This method also checks all of the
|
|
// pointer fields to ensure none of those fields are empty.
|
|
func NotEmpty(tb assertions.AssertionTestingTB, obj any, msg ...any) {
|
|
assertions.NotEmpty(tb.Errorf, obj, msg...)
|
|
}
|