From 09ddfae1d91ed37f95ce76238c2ce406035f9850 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Mon, 22 Feb 2021 07:33:55 -0800 Subject: [PATCH] Use DeepSSZEqual for tests (#8484) Co-authored-by: Raul Jordan --- beacon-chain/rpc/beacon/attestations_test.go | 6 ++---- beacon-chain/rpc/beacon/blocks_test.go | 4 +--- shared/sszutil/deep_equal.go | 2 ++ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/beacon-chain/rpc/beacon/attestations_test.go b/beacon-chain/rpc/beacon/attestations_test.go index 079f10d497..cd94385e80 100644 --- a/beacon-chain/rpc/beacon/attestations_test.go +++ b/beacon-chain/rpc/beacon/attestations_test.go @@ -105,7 +105,7 @@ func TestServer_ListAttestations_Genesis(t *testing.T) { }, }) require.NoError(t, err) - require.DeepEqual(t, wanted, res) + require.DeepSSZEqual(t, wanted, res) } func TestServer_ListAttestations_NoPagination(t *testing.T) { @@ -349,9 +349,7 @@ func TestServer_ListAttestations_Pagination_CustomPageParameters(t *testing.T) { t.Run(test.name, func(t *testing.T) { res, err := bs.ListAttestations(ctx, test.req) require.NoError(t, err) - if !proto.Equal(res, test.res) { - t.Errorf("Incorrect attestations response, wanted \n%v, received \n%v", test.res, res) - } + require.DeepSSZEqual(t, res, test.res) }) } } diff --git a/beacon-chain/rpc/beacon/blocks_test.go b/beacon-chain/rpc/beacon/blocks_test.go index bc3c6ff03f..c9bad71971 100644 --- a/beacon-chain/rpc/beacon/blocks_test.go +++ b/beacon-chain/rpc/beacon/blocks_test.go @@ -271,9 +271,7 @@ func TestServer_ListBlocks_Pagination(t *testing.T) { t.Run(fmt.Sprintf("test_%d", i), func(t *testing.T) { res, err := bs.ListBlocks(ctx, test.req) require.NoError(t, err) - if !proto.Equal(res, test.res) { - t.Errorf("Incorrect blocks response, wanted %v, received %v", test.res, res) - } + require.DeepSSZEqual(t, res, test.res) }) } } diff --git a/shared/sszutil/deep_equal.go b/shared/sszutil/deep_equal.go index b8d740f796..bad8f4a751 100644 --- a/shared/sszutil/deep_equal.go +++ b/shared/sszutil/deep_equal.go @@ -225,6 +225,8 @@ func deepValueBaseTypeEqual(v1, v2 reflect.Value) bool { return v1.Interface().(types.Epoch) == v2.Interface().(types.Epoch) case "Slot": return v1.Interface().(types.Slot) == v2.Interface().(types.Slot) + case "CommitteeIndex": + return v1.Interface().(types.CommitteeIndex) == v2.Interface().(types.CommitteeIndex) } return v1.Interface().(uint64) == v2.Interface().(uint64) case reflect.Uint32: