From 8ee296d130b5d167db2e519a6916a87af98993fd Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 23 Apr 2020 15:53:24 -0700 Subject: [PATCH] fix tests --- chain/events/events_test.go | 12 ++++++------ tools/stats/head_buffer.go | 6 +++--- tools/stats/head_buffer_test.go | 34 ++++++++++++++++----------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/chain/events/events_test.go b/chain/events/events_test.go index c599b676b..bfd734281 100644 --- a/chain/events/events_test.go +++ b/chain/events/events_test.go @@ -92,21 +92,21 @@ func makeTs(t *testing.T, h abi.ChainEpoch, msgcid cid.Cid) *types.TipSet { return ts } -func (fcs *fakeCS) ChainNotify(context.Context) (<-chan []*store.HeadChange, error) { - out := make(chan []*store.HeadChange, 1) - out <- []*store.HeadChange{{Type: store.HCCurrent, Val: fcs.tsc.best()}} +func (fcs *fakeCS) ChainNotify(context.Context) (<-chan []*api.HeadChange, error) { + out := make(chan []*api.HeadChange, 1) + out <- []*api.HeadChange{{Type: store.HCCurrent, Val: fcs.tsc.best()}} fcs.sub = func(rev, app []*types.TipSet) { - notif := make([]*store.HeadChange, len(rev)+len(app)) + notif := make([]*api.HeadChange, len(rev)+len(app)) for i, r := range rev { - notif[i] = &store.HeadChange{ + notif[i] = &api.HeadChange{ Type: store.HCRevert, Val: r, } } for i, r := range app { - notif[i+len(rev)] = &store.HeadChange{ + notif[i+len(rev)] = &api.HeadChange{ Type: store.HCApply, Val: r, } diff --git a/tools/stats/head_buffer.go b/tools/stats/head_buffer.go index 77102e034..08a817233 100644 --- a/tools/stats/head_buffer.go +++ b/tools/stats/head_buffer.go @@ -3,7 +3,7 @@ package main import ( "container/list" - "github.com/filecoin-project/lotus/chain/store" + "github.com/filecoin-project/lotus/api" ) type headBuffer struct { @@ -21,12 +21,12 @@ func NewHeadBuffer(size int) *headBuffer { } } -func (h *headBuffer) Push(hc *store.HeadChange) (rethc *store.HeadChange) { +func (h *headBuffer) Push(hc *api.HeadChange) (rethc *api.HeadChange) { if h.buffer.Len() == h.size { var ok bool el := h.buffer.Front() - rethc, ok = el.Value.(*store.HeadChange) + rethc, ok = el.Value.(*api.HeadChange) if !ok { panic("Value from list is not the correct type") } diff --git a/tools/stats/head_buffer_test.go b/tools/stats/head_buffer_test.go index 3ae7d749c..6266f35fd 100644 --- a/tools/stats/head_buffer_test.go +++ b/tools/stats/head_buffer_test.go @@ -3,7 +3,7 @@ package main import ( "testing" - "github.com/filecoin-project/lotus/chain/store" + "github.com/filecoin-project/lotus/api" "github.com/stretchr/testify/require" ) @@ -11,33 +11,33 @@ func TestHeadBuffer(t *testing.T) { t.Run("Straight push through", func(t *testing.T) { hb := NewHeadBuffer(5) - require.Nil(t, hb.Push(&store.HeadChange{Type: "1"})) - require.Nil(t, hb.Push(&store.HeadChange{Type: "2"})) - require.Nil(t, hb.Push(&store.HeadChange{Type: "3"})) - require.Nil(t, hb.Push(&store.HeadChange{Type: "4"})) - require.Nil(t, hb.Push(&store.HeadChange{Type: "5"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "1"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "2"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "3"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "4"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "5"})) - hc := hb.Push(&store.HeadChange{Type: "6"}) + hc := hb.Push(&api.HeadChange{Type: "6"}) require.Equal(t, hc.Type, "1") }) t.Run("Reverts", func(t *testing.T) { hb := NewHeadBuffer(5) - require.Nil(t, hb.Push(&store.HeadChange{Type: "1"})) - require.Nil(t, hb.Push(&store.HeadChange{Type: "2"})) - require.Nil(t, hb.Push(&store.HeadChange{Type: "3"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "1"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "2"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "3"})) hb.Pop() - require.Nil(t, hb.Push(&store.HeadChange{Type: "3a"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "3a"})) hb.Pop() - require.Nil(t, hb.Push(&store.HeadChange{Type: "3b"})) - require.Nil(t, hb.Push(&store.HeadChange{Type: "4"})) - require.Nil(t, hb.Push(&store.HeadChange{Type: "5"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "3b"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "4"})) + require.Nil(t, hb.Push(&api.HeadChange{Type: "5"})) - hc := hb.Push(&store.HeadChange{Type: "6"}) + hc := hb.Push(&api.HeadChange{Type: "6"}) require.Equal(t, hc.Type, "1") - hc = hb.Push(&store.HeadChange{Type: "7"}) + hc = hb.Push(&api.HeadChange{Type: "7"}) require.Equal(t, hc.Type, "2") - hc = hb.Push(&store.HeadChange{Type: "8"}) + hc = hb.Push(&api.HeadChange{Type: "8"}) require.Equal(t, hc.Type, "3b") }) }