Revert "Change sszutil DeepEqual to ignore unexported fields" (#8391)

* Revert "Change sszutil DeepEqual to ignore unexported (#8336)"

This reverts commit 8d986bd414.

* Add back tests, make tests have equal and non equal check

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Preston Van Loon 2021-02-03 14:39:07 -06:00 committed by GitHub
parent afa5b5e790
commit 48ae49765e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 8 deletions

View File

@ -109,13 +109,7 @@ func deepValueEqual(v1, v2 reflect.Value, visited map[visit]bool, depth int) boo
return deepValueEqual(v1.Elem(), v2.Elem(), visited, depth+1)
case reflect.Struct:
for i, n := 0, v1.NumField(); i < n; i++ {
v1Field := v1.Field(i)
v2Field := v2.Field(i)
if !v1Field.CanInterface() || !v2Field.CanInterface() {
// Continue for unexported fields, since they cannot be read anyways.
continue
}
if !deepValueEqual(v1Field, v2Field, visited, depth+1) {
if !deepValueEqual(v1.Field(i), v2.Field(i), visited, depth+1) {
return false
}
}

View File

@ -51,7 +51,7 @@ func TestDeepEqualStructs_Unexported(t *testing.T) {
ignoreMe string
}
store1 := Store{uint64(1234), nil, "hi there"}
store2 := Store{uint64(1234), []byte{}, "oh hey"}
store2 := Store{uint64(1234), []byte{}, "hi there"}
store3 := Store{uint64(4321), []byte{}, "wow"}
assert.Equal(t, true, sszutil.DeepEqual(store1, store2))
assert.Equal(t, false, sszutil.DeepEqual(store1, store3))