isCanonical for slot 0 should return true (#8269)

Co-authored-by: terence tsao <terence@prysmaticlabs.com>
Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
pinglamb
2021-01-17 00:14:14 +08:00
committed by GitHub
parent cf343be76a
commit 09a792ded4
2 changed files with 12 additions and 0 deletions

View File

@@ -859,6 +859,10 @@ func (bs *Server) GetIndividualVotes(
// if the input slot has a skip block, false is returned,
// if the input slot has more than one block, an error is returned.
func (bs *Server) isSlotCanonical(ctx context.Context, slot uint64) (bool, error) {
if slot == 0 {
return true, nil
}
hasBlockRoots, roots, err := bs.BeaconDB.BlockRootsBySlot(ctx, slot)
if err != nil {
return false, err

View File

@@ -2142,3 +2142,11 @@ func TestServer_isSlotCanonical(t *testing.T) {
}
}
}
func TestServer_isSlotCanonicalForSlot0(t *testing.T) {
ctx := context.Background()
bs := &Server{}
c, err := bs.isSlotCanonical(ctx, 0)
require.NoError(t, err)
require.Equal(t, true, c)
}