Skip to content

Commit

Permalink
Fix is_not_finalized_when_head_is_optimistic
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain committed Mar 18, 2023
1 parent b0b7776 commit f83de8c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions beacon-chain/rpc/eth/helpers/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,15 @@ func TestIsOptimistic(t *testing.T) {
ChainSt, err := util.NewBeaconState()
require.NoError(t, err)
require.NoError(t, ChainSt.SetSlot(fieldparams.SlotsPerEpoch*2))
cs := &chainmock.ChainService{Optimistic: true, State: ChainSt, FinalizedCheckPoint: &eth.Checkpoint{Epoch: 0}}
br, err := b.Block().HashTreeRoot()
require.NoError(t, err)
cs := &chainmock.ChainService{Optimistic: true, State: ChainSt, FinalizedCheckPoint: &eth.Checkpoint{Epoch: 0}, OptimisticRoots: map[[32]byte]bool{
br: true,
}}
mf := &testutil.MockFetcher{BeaconState: fetcherSt}
o, err := IsOptimistic(ctx, bytesutil.PadTo([]byte("root"), 32), cs, mf, cs, db)
require.NoError(t, err)
assert.Equal(t, false, o)
assert.Equal(t, true, o)
})
t.Run("no canonical blocks", func(t *testing.T) {
b, err := blocks.NewSignedBeaconBlock(util.NewBeaconBlock())
Expand Down

0 comments on commit f83de8c

Please sign in to comment.