adapt cmd/lotus-storage-miner tests.
This commit is contained in:
parent
b56568d720
commit
2e9b0f0895
@ -18,13 +18,12 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/test"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"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"
|
||||
builder "github.com/filecoin-project/lotus/node/test"
|
||||
)
|
||||
|
||||
func TestWorkerKeyChange(t *testing.T) {
|
||||
@ -51,7 +50,7 @@ func TestWorkerKeyChange(t *testing.T) {
|
||||
|
||||
blocktime := 1 * time.Millisecond
|
||||
|
||||
n, sn := builder.MockSbBuilder(t, []test.FullNodeOpts{test.FullNodeWithLatestActorsAt(-1), test.FullNodeWithLatestActorsAt(-1)}, test.OneMiner)
|
||||
n, sn := kit.MockMinerBuilder(t, []kit.FullNodeOpts{kit.FullNodeWithLatestActorsAt(-1), kit.FullNodeWithLatestActorsAt(-1)}, kit.OneMiner)
|
||||
|
||||
client1 := n[0]
|
||||
client2 := n[1]
|
||||
@ -92,7 +91,7 @@ func TestWorkerKeyChange(t *testing.T) {
|
||||
defer close(done)
|
||||
for atomic.LoadInt64(&mine) == 1 {
|
||||
time.Sleep(blocktime)
|
||||
if err := sn[0].MineOne(ctx, test.MineNext); err != nil {
|
||||
if err := sn[0].MineOne(ctx, kit.MineNext); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
@ -107,7 +106,7 @@ func TestWorkerKeyChange(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Initialize wallet.
|
||||
test.SendFunds(ctx, t, client1, newKey, abi.NewTokenAmount(0))
|
||||
kit.SendFunds(ctx, t, client1, newKey, abi.NewTokenAmount(0))
|
||||
|
||||
require.NoError(t, run(actorProposeChangeWorker, "--really-do-it", newKey.String()))
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/itests/kit"
|
||||
"github.com/filecoin-project/lotus/node/impl"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/urfave/cli/v2"
|
||||
@ -12,11 +15,8 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/test"
|
||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
builder "github.com/filecoin-project/lotus/node/test"
|
||||
)
|
||||
|
||||
func TestMinerAllInfo(t *testing.T) {
|
||||
@ -32,12 +32,7 @@ func TestMinerAllInfo(t *testing.T) {
|
||||
|
||||
_test = true
|
||||
|
||||
lotuslog.SetupLogLevels()
|
||||
logging.SetLogLevel("miner", "ERROR")
|
||||
logging.SetLogLevel("chainstore", "ERROR")
|
||||
logging.SetLogLevel("chain", "ERROR")
|
||||
logging.SetLogLevel("sub", "ERROR")
|
||||
logging.SetLogLevel("storageminer", "ERROR")
|
||||
kit.QuietMiningLogs()
|
||||
|
||||
oldDelay := policy.GetPreCommitChallengeDelay()
|
||||
policy.SetPreCommitChallengeDelay(5)
|
||||
@ -45,8 +40,9 @@ func TestMinerAllInfo(t *testing.T) {
|
||||
policy.SetPreCommitChallengeDelay(oldDelay)
|
||||
})
|
||||
|
||||
var n []test.TestNode
|
||||
var sn []test.TestStorageNode
|
||||
n, sn := kit.Builder(t, kit.OneFull, kit.OneMiner)
|
||||
client, miner := n[0].FullNode, sn[0]
|
||||
kit.ConnectAndStartMining(t, time.Second, miner, client.(*impl.FullNodeAPI))
|
||||
|
||||
run := func(t *testing.T) {
|
||||
app := cli.NewApp()
|
||||
@ -62,15 +58,10 @@ func TestMinerAllInfo(t *testing.T) {
|
||||
require.NoError(t, infoAllCmd.Action(cctx))
|
||||
}
|
||||
|
||||
bp := func(t *testing.T, fullOpts []test.FullNodeOpts, storage []test.StorageMiner) ([]test.TestNode, []test.TestStorageNode) {
|
||||
n, sn = builder.Builder(t, fullOpts, storage)
|
||||
t.Run("pre-info-all", run)
|
||||
|
||||
t.Run("pre-info-all", run)
|
||||
|
||||
return n, sn
|
||||
}
|
||||
|
||||
test.TestDealFlow(t, bp, time.Second, false, false, 0)
|
||||
dh := kit.NewDealHarness(t, client, miner)
|
||||
dh.MakeFullDeal(context.Background(), 6, false, false, 0)
|
||||
|
||||
t.Run("post-info-all", run)
|
||||
}
|
||||
|
@ -1,8 +1,13 @@
|
||||
package kit
|
||||
|
||||
import logging "github.com/ipfs/go-log/v2"
|
||||
import (
|
||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
)
|
||||
|
||||
func QuietMiningLogs() {
|
||||
lotuslog.SetupLogLevels()
|
||||
|
||||
_ = logging.SetLogLevel("Miner", "ERROR")
|
||||
_ = logging.SetLogLevel("chainstore", "ERROR")
|
||||
_ = logging.SetLogLevel("chain", "ERROR")
|
||||
|
Loading…
Reference in New Issue
Block a user