fix TestWorkerKeyChange.

This commit is contained in:
Raúl Kripalani 2021-06-07 23:56:59 +01:00
parent cd6f91ba6f
commit 40ea660cdd

View File

@ -7,7 +7,6 @@ import (
"fmt" "fmt"
"regexp" "regexp"
"strconv" "strconv"
"sync/atomic"
"testing" "testing"
"time" "time"
@ -22,7 +21,6 @@ import (
"github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/itests/kit" "github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/lib/lotuslog"
"github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/node/repo"
) )
@ -40,20 +38,16 @@ func TestWorkerKeyChange(t *testing.T) {
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1) policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
policy.SetMinVerifiedDealSize(abi.NewStoragePower(256)) policy.SetMinVerifiedDealSize(abi.NewStoragePower(256))
lotuslog.SetupLogLevels() kit.QuietMiningLogs()
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("pubsub", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
blocktime := 1 * time.Millisecond 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] client1 := clients[0]
client2 := n[1] client2 := clients[1]
// Connect the nodes. // Connect the nodes.
addrinfo, err := client1.NetAddrsListen(ctx) addrinfo, err := client1.NetAddrsListen(ctx)
@ -66,8 +60,8 @@ func TestWorkerKeyChange(t *testing.T) {
app := cli.NewApp() app := cli.NewApp()
app.Metadata = map[string]interface{}{ app.Metadata = map[string]interface{}{
"repoType": repo.StorageMiner, "repoType": repo.StorageMiner,
"testnode-full": n[0], "testnode-full": clients[0],
"testnode-storage": sn[0], "testnode-storage": miners[0],
} }
app.Writer = output app.Writer = output
api.RunningNodeType = api.NodeMiner api.RunningNodeType = api.NodeMiner
@ -84,23 +78,8 @@ func TestWorkerKeyChange(t *testing.T) {
return cmd.Action(cctx) return cmd.Action(cctx)
} }
// setup miner // start mining
mine := int64(1) kit.ConnectAndStartMining(t, blocktime, miners[0], client1, client2)
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
}()
newKey, err := client1.WalletNew(ctx, types.KTBLS) newKey, err := client1.WalletNew(ctx, types.KTBLS)
require.NoError(t, err) require.NoError(t, err)