diff --git a/chain/events/events_height.go b/chain/events/events_height.go index 12cafbc99..b5bf297e5 100644 --- a/chain/events/events_height.go +++ b/chain/events/events_height.go @@ -127,7 +127,7 @@ func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence bestH := e.tsc.best().Height() if bestH >= h+uint64(confidence) { - ts, err := e.tsc.get(h) + ts, err := e.tsc.getNonNull(h) if err != nil { log.Warnf("events.ChainAt: calling HandleFunc with nil tipset, not found in cache: %s", err) } diff --git a/chain/events/events_test.go b/chain/events/events_test.go index 733c728b6..474d0dce0 100644 --- a/chain/events/events_test.go +++ b/chain/events/events_test.go @@ -434,6 +434,35 @@ func TestAtChainedConfidence(t *testing.T) { require.Equal(t, false, reverted) } +func TestAtChainedConfidenceNull(t *testing.T) { + fcs := &fakeCS{ + t: t, + h: 1, + tsc: newTSCache(2*build.ForkLengthThreshold, nil), + } + require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid))) + + events := NewEvents(context.Background(), fcs) + + fcs.advance(0, 15, nil, 5) + + var applied bool + var reverted bool + + err := events.ChainAt(func(ts *types.TipSet, curH uint64) error { + applied = true + require.Equal(t, 6, int(ts.Height())) + return nil + }, func(ts *types.TipSet) error { + reverted = true + return nil + }, 3, 5) + require.NoError(t, err) + + require.Equal(t, true, applied) + require.Equal(t, false, reverted) +} + func TestCalled(t *testing.T) { fcs := &fakeCS{ t: t,