Skip to content

Commit

Permalink
fix fillback test
Browse files Browse the repository at this point in the history
  • Loading branch information
kasey committed Jan 22, 2024
1 parent e577f2f commit d25d43c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions beacon-chain/sync/backfill/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type mockBackfillDB struct {
status *dbval.BackfillStatus
err error
states map[[32]byte]state.BeaconState
blocks map[[32]byte]interfaces.ReadOnlySignedBeaconBlock
blocks map[[32]byte]blocks.ROBlock
}

var _ BeaconDB = &mockBackfillDB{}
Expand Down Expand Up @@ -83,15 +83,13 @@ func (d *mockBackfillDB) Block(ctx context.Context, blockRoot [32]byte) (interfa
return b, nil
}

func (d *mockBackfillDB) SaveBlock(ctx context.Context, signed interfaces.ReadOnlySignedBeaconBlock) error {
func (d *mockBackfillDB) SaveROBlocks(ctx context.Context, blks []blocks.ROBlock, cache bool) error {
if d.blocks == nil {
d.blocks = make(map[[32]byte]interfaces.ReadOnlySignedBeaconBlock)
d.blocks = make(map[[32]byte]blocks.ROBlock)
}
r, err := signed.Block().HashTreeRoot()
if err != nil {
return err
for i := range blks {
d.blocks[blks[i].Root()] = blks[i]
}
d.blocks[r] = signed
return nil
}

Expand Down Expand Up @@ -142,11 +140,12 @@ func TestSlotCovered(t *testing.T) {
func TestStatusUpdater_FillBack(t *testing.T) {
ctx := context.Background()
mdb := &mockBackfillDB{}
s := &Store{bs: &dbval.BackfillStatus{LowSlot: 100}, store: mdb}
b, err := setupTestBlock(90)
require.NoError(t, err)
rob, err := blocks.NewROBlock(b)
require.NoError(t, err)
s := &Store{bs: &dbval.BackfillStatus{LowSlot: 100, LowParentRoot: rob.RootSlice()}, store: mdb}
require.Equal(t, false, s.AvailableBlock(95))
_, err = s.fillBack(ctx, []blocks.ROBlock{rob})
require.NoError(t, err)
require.Equal(t, true, s.AvailableBlock(95))
Expand Down

0 comments on commit d25d43c

Please sign in to comment.