fix more tests

This commit is contained in:
vyzo 2021-12-14 17:45:38 +02:00
parent 40c61a310f
commit 5e692f9071
7 changed files with 22 additions and 20 deletions

View File

@ -87,7 +87,7 @@ func (fcs *fakeCS) ChainGetPath(ctx context.Context, from, to types.TipSetKey) (
} }
// copied from the chainstore // 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) return fcs.ChainGetTipSet(ctx, tsk)
}, fromTs, toTs) }, fromTs, toTs)
if err != nil { if err != nil {

View File

@ -233,7 +233,7 @@ func TestMessagePool(t *testing.T) {
ds := datastore.NewMapDatastore() 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -277,7 +277,7 @@ func TestCheckMessageBig(t *testing.T) {
ds := datastore.NewMapDatastore() 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) assert.NoError(t, err)
to := mock.Address(1001) to := mock.Address(1001)
@ -340,7 +340,7 @@ func TestMessagePoolMessagesInEachBlock(t *testing.T) {
ds := datastore.NewMapDatastore() 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -389,7 +389,7 @@ func TestRevertMessages(t *testing.T) {
ds := datastore.NewMapDatastore() 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -452,7 +452,7 @@ func TestPruningSimple(t *testing.T) {
ds := datastore.NewMapDatastore() 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -496,7 +496,7 @@ func TestLoadLocal(t *testing.T) {
tma := newTestMpoolAPI() tma := newTestMpoolAPI()
ds := datastore.NewMapDatastore() 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -539,7 +539,7 @@ func TestLoadLocal(t *testing.T) {
t.Fatal(err) 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -568,7 +568,7 @@ func TestClearAll(t *testing.T) {
tma := newTestMpoolAPI() tma := newTestMpoolAPI()
ds := datastore.NewMapDatastore() 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -622,7 +622,7 @@ func TestClearNonLocal(t *testing.T) {
tma := newTestMpoolAPI() tma := newTestMpoolAPI()
ds := datastore.NewMapDatastore() 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -683,7 +683,7 @@ func TestUpdates(t *testing.T) {
tma := newTestMpoolAPI() tma := newTestMpoolAPI()
ds := datastore.NewMapDatastore() 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -75,7 +75,7 @@ func TestSearchForMessageReplacements(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
err = cg.Blockstore().Put(rmb) err = cg.Blockstore().Put(ctx, rmb)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -117,7 +117,7 @@ func TestSearchForMessageReplacements(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
err = cg.Blockstore().Put(nrmb) err = cg.Blockstore().Put(ctx, nrmb)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -10,6 +10,8 @@ import (
) )
func TestChainCheckpoint(t *testing.T) { func TestChainCheckpoint(t *testing.T) {
ctx := context.Background()
cg, err := gen.NewGenerator() cg, err := gen.NewGenerator()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -27,11 +29,11 @@ func TestChainCheckpoint(t *testing.T) {
cs := cg.ChainStore() cs := cg.ChainStore()
checkpoint := last checkpoint := last
checkpointParents, err := cs.GetTipSetFromKey(checkpoint.Parents()) checkpointParents, err := cs.GetTipSetFromKey(ctx, checkpoint.Parents())
require.NoError(t, err) require.NoError(t, err)
// Set the head to the block before the checkpoint. // Set the head to the block before the checkpoint.
err = cs.SetHead(checkpointParents) err = cs.SetHead(ctx, checkpointParents)
require.NoError(t, err) require.NoError(t, err)
// Verify it worked. // Verify it worked.
@ -39,7 +41,7 @@ func TestChainCheckpoint(t *testing.T) {
require.True(t, head.Equals(checkpointParents)) require.True(t, head.Equals(checkpointParents))
// Try to set the checkpoint in the future, it should fail. // Try to set the checkpoint in the future, it should fail.
err = cs.SetCheckpoint(checkpoint) err = cs.SetCheckpoint(ctx, checkpoint)
require.Error(t, err) require.Error(t, err)
// Then move the head back. // Then move the head back.
@ -70,7 +72,7 @@ func TestChainCheckpoint(t *testing.T) {
require.True(t, head.Equals(checkpoint)) require.True(t, head.Equals(checkpoint))
// Remove the checkpoint. // Remove the checkpoint.
err = cs.RemoveCheckpoint() err = cs.RemoveCheckpoint(ctx)
require.NoError(t, err) require.NoError(t, err)
// Now switch to the other fork. // Now switch to the other fork.

View File

@ -44,7 +44,7 @@ func TestIndexSeeks(t *testing.T) {
if err := cs.PutTipSet(ctx, mock.TipSet(gen)); err != nil { if err := cs.PutTipSet(ctx, mock.TipSet(gen)); err != nil {
t.Fatal(err) t.Fatal(err)
} }
assert.NoError(t, cs.SetGenesis(gen)) assert.NoError(t, cs.SetGenesis(ctx, gen))
// Put 113 blocks from genesis // Put 113 blocks from genesis
for i := 0; i < 113; i++ { for i := 0; i < 113; i++ {

View File

@ -149,7 +149,7 @@ func TestChainExportImportFull(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
err = cs.SetHead(last) err = cs.SetHead(context.Background(), last)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -298,7 +298,7 @@ func (tu *syncTestUtil) addSourceNode(gen int) {
lastTs := blocks[len(blocks)-1].Blocks lastTs := blocks[len(blocks)-1].Blocks
for _, lastB := range lastTs { for _, lastB := range lastTs {
cs := out.(*impl.FullNodeAPI).ChainAPI.Chain 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) err = cs.AddBlock(tu.ctx, lastB.Header)
require.NoError(tu.t, err) require.NoError(tu.t, err)
} }