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