Skip to content

Commit

Permalink
fix test and bug
Browse files Browse the repository at this point in the history
  • Loading branch information
janezpodhostnik committed Nov 13, 2024
1 parent cb45e91 commit 2e65322
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion services/ingestion/event_subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ func (r *RPCEventSubscriber) backfill(ctx context.Context, currentHeight uint64)
return
}

currentHeight, err := r.backfillSpork(ctx, currentHeight, eventsChan)
var err error
currentHeight, err = r.backfillSpork(ctx, currentHeight, eventsChan)
if err != nil {
r.logger.Error().Err(err).Msg("error backfilling spork")
eventsChan <- models.NewBlockEventsError(err)
Expand Down
18 changes: 16 additions & 2 deletions services/testutils/mock_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,23 @@ func SetupClient(startHeight uint64, endHeight uint64) (*MockClient, chan flow.B
return events, make(chan error), nil
},
GetEventsForHeightRangeFunc: func(
ctx context.Context, eventType string, startHeight uint64, endHeight uint64,
ctx context.Context, eventType string, sh uint64, eh uint64,
) ([]flow.BlockEvents, error) {
return []flow.BlockEvents{}, nil
if sh < startHeight || sh > endHeight {
return nil, storage.ErrNotFound
}
if eh < startHeight || eh > endHeight {
return nil, storage.ErrNotFound
}

evts := make([]flow.BlockEvents, 0, eh-sh+1)
for i := uint64(0); i <= eh-sh; i++ {
evts = append(evts, flow.BlockEvents{
Height: sh + i,
})
}

return evts, nil
},
}, events
}

0 comments on commit 2e65322

Please sign in to comment.