Tweak LastRoot to return head root (#12985)

This commit is contained in:
Potuz
2023-10-02 23:22:52 -03:00
committed by GitHub
parent 56f3dafb54
commit 2c32a87d17
2 changed files with 2 additions and 5 deletions

View File

@@ -13,10 +13,7 @@ func (f *ForkChoice) LastRoot(epoch primitives.Epoch) [32]byte {
if err != nil {
return [32]byte{}
}
if headEpoch < epoch {
return [32]byte{}
}
if headEpoch == epoch {
if headEpoch <= epoch {
return head.root
}
for head != nil && head.slot > epochEnd {

View File

@@ -35,5 +35,5 @@ func TestLastRoot(t *testing.T) {
require.Equal(t, [32]byte{'6'}, f.store.headNode.root)
require.Equal(t, [32]byte{'2'}, f.LastRoot(0))
require.Equal(t, [32]byte{'6'}, f.LastRoot(1))
require.Equal(t, [32]byte{}, f.LastRoot(2))
require.Equal(t, [32]byte{'6'}, f.LastRoot(2))
}