From 40ea660cdd3cb9956613688e259948085fa0685a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Mon, 7 Jun 2021 23:56:59 +0100 Subject: [PATCH] fix TestWorkerKeyChange. --- cmd/lotus-storage-miner/actor_test.go | 41 +++++++-------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/cmd/lotus-storage-miner/actor_test.go b/cmd/lotus-storage-miner/actor_test.go index 7b57f9c2d..7f36812bc 100644 --- a/cmd/lotus-storage-miner/actor_test.go +++ b/cmd/lotus-storage-miner/actor_test.go @@ -7,7 +7,6 @@ import ( "fmt" "regexp" "strconv" - "sync/atomic" "testing" "time" @@ -22,7 +21,6 @@ import ( "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/itests/kit" - "github.com/filecoin-project/lotus/lib/lotuslog" "github.com/filecoin-project/lotus/node/repo" ) @@ -40,20 +38,16 @@ func TestWorkerKeyChange(t *testing.T) { policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1) policy.SetMinVerifiedDealSize(abi.NewStoragePower(256)) - lotuslog.SetupLogLevels() - logging.SetLogLevel("miner", "ERROR") - logging.SetLogLevel("chainstore", "ERROR") - logging.SetLogLevel("chain", "ERROR") - logging.SetLogLevel("pubsub", "ERROR") - logging.SetLogLevel("sub", "ERROR") - logging.SetLogLevel("storageminer", "ERROR") + kit.QuietMiningLogs() blocktime := 1 * time.Millisecond - n, sn := kit.MockMinerBuilder(t, []kit.FullNodeOpts{kit.FullNodeWithLatestActorsAt(-1), kit.FullNodeWithLatestActorsAt(-1)}, kit.OneMiner) + clients, miners := kit.MockMinerBuilder(t, + []kit.FullNodeOpts{kit.FullNodeWithLatestActorsAt(-1), kit.FullNodeWithLatestActorsAt(-1)}, + kit.OneMiner) - client1 := n[0] - client2 := n[1] + client1 := clients[0] + client2 := clients[1] // Connect the nodes. addrinfo, err := client1.NetAddrsListen(ctx) @@ -66,8 +60,8 @@ func TestWorkerKeyChange(t *testing.T) { app := cli.NewApp() app.Metadata = map[string]interface{}{ "repoType": repo.StorageMiner, - "testnode-full": n[0], - "testnode-storage": sn[0], + "testnode-full": clients[0], + "testnode-storage": miners[0], } app.Writer = output api.RunningNodeType = api.NodeMiner @@ -84,23 +78,8 @@ func TestWorkerKeyChange(t *testing.T) { return cmd.Action(cctx) } - // setup miner - mine := int64(1) - done := make(chan struct{}) - go func() { - defer close(done) - for atomic.LoadInt64(&mine) == 1 { - time.Sleep(blocktime) - if err := sn[0].MineOne(ctx, kit.MineNext); err != nil { - t.Error(err) - } - } - }() - defer func() { - atomic.AddInt64(&mine, -1) - fmt.Println("shutting down mining") - <-done - }() + // start mining + kit.ConnectAndStartMining(t, blocktime, miners[0], client1, client2) newKey, err := client1.WalletNew(ctx, types.KTBLS) require.NoError(t, err)