Pool returns empty contribution slice instead of nil (#9808)

This commit is contained in:
terence tsao 2021-10-20 14:45:57 -07:00 committed by GitHub
parent 290b4273dd
commit d7cad27cc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -74,7 +74,7 @@ func (s *Store) SyncCommitteeContributions(slot types.Slot) ([]*ethpb.SyncCommit
item := s.contributionCache.RetrieveByKey(syncCommitteeKey(slot))
if item == nil {
return nil, nil
return []*ethpb.SyncCommitteeContribution{}, nil
}
contributions, ok := item.Value.([]*ethpb.SyncCommitteeContribution)

View File

@ -36,11 +36,11 @@ func TestSyncCommitteeContributionCache_RoundTrip(t *testing.T) {
conts, err := store.SyncCommitteeContributions(1)
require.NoError(t, err)
require.DeepSSZEqual(t, []*ethpb.SyncCommitteeContribution(nil), conts)
require.DeepSSZEqual(t, []*ethpb.SyncCommitteeContribution{}, conts)
conts, err = store.SyncCommitteeContributions(2)
require.NoError(t, err)
require.DeepSSZEqual(t, []*ethpb.SyncCommitteeContribution(nil), conts)
require.DeepSSZEqual(t, []*ethpb.SyncCommitteeContribution{}, conts)
conts, err = store.SyncCommitteeContributions(3)
require.NoError(t, err)
@ -73,10 +73,10 @@ func TestSyncCommitteeContributionCache_RoundTrip(t *testing.T) {
// All the contributions should persist after get.
conts, err = store.SyncCommitteeContributions(1)
require.NoError(t, err)
require.DeepSSZEqual(t, []*ethpb.SyncCommitteeContribution(nil), conts)
require.DeepSSZEqual(t, []*ethpb.SyncCommitteeContribution{}, conts)
conts, err = store.SyncCommitteeContributions(2)
require.NoError(t, err)
require.DeepSSZEqual(t, []*ethpb.SyncCommitteeContribution(nil), conts)
require.DeepSSZEqual(t, []*ethpb.SyncCommitteeContribution{}, conts)
conts, err = store.SyncCommitteeContributions(3)
require.NoError(t, err)