Skip to content

Commit

Permalink
Revert "Change sszutil DeepEqual to ignore unexported fields" (#8391)
Browse files Browse the repository at this point in the history
* Revert "Change sszutil DeepEqual to ignore unexported (#8336)"

This reverts commit 8d986bd.

* 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>
  • Loading branch information
prestonvanloon and prylabs-bulldozer[bot] authored Feb 3, 2021
1 parent afa5b5e commit 48ae497
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions shared/sszutil/deep_equal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion shared/sszutil/deep_equal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 48ae497

Please sign in to comment.