From 704904e2da17dfe5f956e5caba180147c216e335 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 14 Dec 2021 17:45:38 +0200 Subject: [PATCH] fix more tests --- chain/events/events_test.go | 2 +- chain/messagepool/messagepool_test.go | 20 ++++++++++---------- chain/stmgr/searchwait_test.go | 4 ++-- chain/store/checkpoint_test.go | 10 ++++++---- chain/store/index_test.go | 2 +- chain/store/store_test.go | 2 +- chain/sync_test.go | 2 +- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/chain/events/events_test.go b/chain/events/events_test.go index 61dd25fbb..304463c04 100644 --- a/chain/events/events_test.go +++ b/chain/events/events_test.go @@ -87,7 +87,7 @@ func (fcs *fakeCS) ChainGetPath(ctx context.Context, from, to types.TipSetKey) ( } // copied from the chainstore - revert, apply, err := store.ReorgOps(func(tsk types.TipSetKey) (*types.TipSet, error) { + revert, apply, err := store.ReorgOps(ctx, func(tsk types.TipSetKey) (*types.TipSet, error) { return fcs.ChainGetTipSet(ctx, tsk) }, fromTs, toTs) if err != nil { diff --git a/chain/messagepool/messagepool_test.go b/chain/messagepool/messagepool_test.go index 4a2bbfe94..e768e18f1 100644 --- a/chain/messagepool/messagepool_test.go +++ b/chain/messagepool/messagepool_test.go @@ -233,7 +233,7 @@ func TestMessagePool(t *testing.T) { ds := datastore.NewMapDatastore() - mp, err := New(tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) + mp, err := New(context.Background(), tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) if err != nil { t.Fatal(err) } @@ -277,7 +277,7 @@ func TestCheckMessageBig(t *testing.T) { ds := datastore.NewMapDatastore() - mp, err := New(tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) + mp, err := New(context.Background(), tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) assert.NoError(t, err) to := mock.Address(1001) @@ -340,7 +340,7 @@ func TestMessagePoolMessagesInEachBlock(t *testing.T) { ds := datastore.NewMapDatastore() - mp, err := New(tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) + mp, err := New(context.Background(), tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) if err != nil { t.Fatal(err) } @@ -389,7 +389,7 @@ func TestRevertMessages(t *testing.T) { ds := datastore.NewMapDatastore() - mp, err := New(tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) + mp, err := New(context.Background(), tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) if err != nil { t.Fatal(err) } @@ -452,7 +452,7 @@ func TestPruningSimple(t *testing.T) { ds := datastore.NewMapDatastore() - mp, err := New(tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) + mp, err := New(context.Background(), tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) if err != nil { t.Fatal(err) } @@ -496,7 +496,7 @@ func TestLoadLocal(t *testing.T) { tma := newTestMpoolAPI() ds := datastore.NewMapDatastore() - mp, err := New(tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) + mp, err := New(context.Background(), tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) if err != nil { t.Fatal(err) } @@ -539,7 +539,7 @@ func TestLoadLocal(t *testing.T) { t.Fatal(err) } - mp, err = New(tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) + mp, err = New(context.Background(), tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) if err != nil { t.Fatal(err) } @@ -568,7 +568,7 @@ func TestClearAll(t *testing.T) { tma := newTestMpoolAPI() ds := datastore.NewMapDatastore() - mp, err := New(tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) + mp, err := New(context.Background(), tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) if err != nil { t.Fatal(err) } @@ -622,7 +622,7 @@ func TestClearNonLocal(t *testing.T) { tma := newTestMpoolAPI() ds := datastore.NewMapDatastore() - mp, err := New(tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) + mp, err := New(context.Background(), tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) if err != nil { t.Fatal(err) } @@ -683,7 +683,7 @@ func TestUpdates(t *testing.T) { tma := newTestMpoolAPI() ds := datastore.NewMapDatastore() - mp, err := New(tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) + mp, err := New(context.Background(), tma, ds, filcns.DefaultUpgradeSchedule(), "mptest", nil) if err != nil { t.Fatal(err) } diff --git a/chain/stmgr/searchwait_test.go b/chain/stmgr/searchwait_test.go index 1e4776ff7..b8cd7ddcf 100644 --- a/chain/stmgr/searchwait_test.go +++ b/chain/stmgr/searchwait_test.go @@ -75,7 +75,7 @@ func TestSearchForMessageReplacements(t *testing.T) { t.Fatal(err) } - err = cg.Blockstore().Put(rmb) + err = cg.Blockstore().Put(ctx, rmb) if err != nil { t.Fatal(err) } @@ -117,7 +117,7 @@ func TestSearchForMessageReplacements(t *testing.T) { t.Fatal(err) } - err = cg.Blockstore().Put(nrmb) + err = cg.Blockstore().Put(ctx, nrmb) if err != nil { t.Fatal(err) } diff --git a/chain/store/checkpoint_test.go b/chain/store/checkpoint_test.go index 81bbab6ea..cc5337f58 100644 --- a/chain/store/checkpoint_test.go +++ b/chain/store/checkpoint_test.go @@ -10,6 +10,8 @@ import ( ) func TestChainCheckpoint(t *testing.T) { + ctx := context.Background() + cg, err := gen.NewGenerator() if err != nil { t.Fatal(err) @@ -27,11 +29,11 @@ func TestChainCheckpoint(t *testing.T) { cs := cg.ChainStore() checkpoint := last - checkpointParents, err := cs.GetTipSetFromKey(checkpoint.Parents()) + checkpointParents, err := cs.GetTipSetFromKey(ctx, checkpoint.Parents()) require.NoError(t, err) // Set the head to the block before the checkpoint. - err = cs.SetHead(checkpointParents) + err = cs.SetHead(ctx, checkpointParents) require.NoError(t, err) // Verify it worked. @@ -39,7 +41,7 @@ func TestChainCheckpoint(t *testing.T) { require.True(t, head.Equals(checkpointParents)) // Try to set the checkpoint in the future, it should fail. - err = cs.SetCheckpoint(checkpoint) + err = cs.SetCheckpoint(ctx, checkpoint) require.Error(t, err) // Then move the head back. @@ -70,7 +72,7 @@ func TestChainCheckpoint(t *testing.T) { require.True(t, head.Equals(checkpoint)) // Remove the checkpoint. - err = cs.RemoveCheckpoint() + err = cs.RemoveCheckpoint(ctx) require.NoError(t, err) // Now switch to the other fork. diff --git a/chain/store/index_test.go b/chain/store/index_test.go index 9bc31e5a8..13054e95d 100644 --- a/chain/store/index_test.go +++ b/chain/store/index_test.go @@ -44,7 +44,7 @@ func TestIndexSeeks(t *testing.T) { if err := cs.PutTipSet(ctx, mock.TipSet(gen)); err != nil { t.Fatal(err) } - assert.NoError(t, cs.SetGenesis(gen)) + assert.NoError(t, cs.SetGenesis(ctx, gen)) // Put 113 blocks from genesis for i := 0; i < 113; i++ { diff --git a/chain/store/store_test.go b/chain/store/store_test.go index 2004b266c..f7cf32e8a 100644 --- a/chain/store/store_test.go +++ b/chain/store/store_test.go @@ -149,7 +149,7 @@ func TestChainExportImportFull(t *testing.T) { t.Fatal(err) } - err = cs.SetHead(last) + err = cs.SetHead(context.Background(), last) if err != nil { t.Fatal(err) } diff --git a/chain/sync_test.go b/chain/sync_test.go index e14601cb6..9b6f0c598 100644 --- a/chain/sync_test.go +++ b/chain/sync_test.go @@ -299,7 +299,7 @@ func (tu *syncTestUtil) addSourceNode(gen int) { lastTs := blocks[len(blocks)-1].Blocks for _, lastB := range lastTs { cs := out.(*impl.FullNodeAPI).ChainAPI.Chain - require.NoError(tu.t, cs.AddToTipSetTracker(lastB.Header)) + require.NoError(tu.t, cs.AddToTipSetTracker(context.Background(), lastB.Header)) err = cs.AddBlock(tu.ctx, lastB.Header) require.NoError(tu.t, err) }