diff --git a/itests/direct_data_onboard_test.go b/itests/direct_data_onboard_test.go index 7c6ce8fbb..2b2adb299 100644 --- a/itests/direct_data_onboard_test.go +++ b/itests/direct_data_onboard_test.go @@ -444,15 +444,11 @@ func TestOnboardRawPieceVerified_WithActorEvents(t *testing.T) { // check that our `ToHeight` filter works as expected var initialEvents []*types.ActorEvent - // TODO: this should probably close the channel when it knows it's done for evt := range initialEventsChan { initialEvents = append(initialEvents, evt) - // sector-precommitted, sector-activated, verifier-balance, verifier-balance - if len(initialEvents) == 4 { - break - } } - require.Equal(t, eventsFromMessages[0:4], initialEvents) + // sector-precommitted, sector-activated, verifier-balance, verifier-balance, allocation + require.Equal(t, eventsFromMessages[0:5], initialEvents) // construct ActorEvents from subscription channel for all actor events allEvtsChan, err := miner.FullNode.SubscribeActorEvents(ctx, &types.ActorEventFilter{ diff --git a/node/impl/full/actor_events.go b/node/impl/full/actor_events.go index ef6fcec7a..de5e3b966 100644 --- a/node/impl/full/actor_events.go +++ b/node/impl/full/actor_events.go @@ -284,6 +284,14 @@ func (a *ActorEventHandler) SubscribeActorEvents(ctx context.Context, evtFilter return true } + // for the case where we have a MaxHeight set, we don't get a signal from the filter when we + // reach that height, so we need to check it ourselves, do it now but also in the loop + if params.MaxHeight > 0 && a.Chain.GetHeaviestTipSet().Height() > params.MaxHeight { + return + } + ticker := time.NewTicker(time.Duration(build.BlockDelaySecs) * time.Second) + defer ticker.Stop() + for ctx.Err() == nil { if len(buffer) > 0 { // check if we need to disconnect the client because they've fallen behind, always allow at @@ -312,6 +320,10 @@ func (a *ActorEventHandler) SubscribeActorEvents(ctx context.Context, evtFilter } case <-ctx.Done(): return + case <-ticker.C: + if params.MaxHeight > 0 && a.Chain.GetHeaviestTipSet().Height() > params.MaxHeight { + return + } } } }