itests: Test lotus-miner with no store/seal paths
This commit is contained in:
parent
cd682e200b
commit
0ca1cc2bcd
@ -968,6 +968,11 @@ workflows:
|
|||||||
suite: itest-wdpost_dispute
|
suite: itest-wdpost_dispute
|
||||||
target: "./itests/wdpost_dispute_test.go"
|
target: "./itests/wdpost_dispute_test.go"
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: test-itest-wdpost_no_miner_storage
|
||||||
|
suite: itest-wdpost_no_miner_storage
|
||||||
|
target: "./itests/wdpost_no_miner_storage_test.go"
|
||||||
|
|
||||||
- test:
|
- test:
|
||||||
name: test-itest-wdpost
|
name: test-itest-wdpost
|
||||||
suite: itest-wdpost
|
suite: itest-wdpost
|
||||||
|
@ -546,7 +546,12 @@ func (n *Ensemble) Start() *Ensemble {
|
|||||||
// using real proofs, therefore need real sectors.
|
// using real proofs, therefore need real sectors.
|
||||||
if !n.bootstrapped && !n.options.mockProofs {
|
if !n.bootstrapped && !n.options.mockProofs {
|
||||||
psd := m.PresealDir
|
psd := m.PresealDir
|
||||||
|
noPaths := m.options.noMinerStorage
|
||||||
|
|
||||||
err := lr.SetStorage(func(sc *paths.StorageConfig) {
|
err := lr.SetStorage(func(sc *paths.StorageConfig) {
|
||||||
|
if noPaths {
|
||||||
|
sc.StoragePaths = []paths.LocalPath{}
|
||||||
|
}
|
||||||
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{Path: psd})
|
sc.StoragePaths = append(sc.StoragePaths, paths.LocalPath{Path: psd})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ type nodeOpts struct {
|
|||||||
minerNoLocalSealing bool // use worker
|
minerNoLocalSealing bool // use worker
|
||||||
minerAssigner string
|
minerAssigner string
|
||||||
disallowRemoteFinalize bool
|
disallowRemoteFinalize bool
|
||||||
|
noMinerStorage bool
|
||||||
|
|
||||||
workerTasks []sealtasks.TaskType
|
workerTasks []sealtasks.TaskType
|
||||||
workerStorageOpt func(paths.Store) paths.Store
|
workerStorageOpt func(paths.Store) paths.Store
|
||||||
@ -154,6 +155,14 @@ func PresealSectors(sectors int) NodeOpt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NoMinerStorage initializes miners with no writable storage paths (just read-only preseal paths)
|
||||||
|
func NoMinerStorage() NodeOpt {
|
||||||
|
return func(opts *nodeOpts) error {
|
||||||
|
opts.noMinerStorage = true
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ThroughRPC makes interactions with this node throughout the test flow through
|
// ThroughRPC makes interactions with this node throughout the test flow through
|
||||||
// the JSON-RPC API.
|
// the JSON-RPC API.
|
||||||
func ThroughRPC() NodeOpt {
|
func ThroughRPC() NodeOpt {
|
||||||
@ -210,6 +219,8 @@ func WithTaskTypes(tt []sealtasks.TaskType) NodeOpt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var WithSealWorkerTasks = WithTaskTypes([]sealtasks.TaskType{sealtasks.TTFetch, sealtasks.TTCommit1, sealtasks.TTFinalize, sealtasks.TTAddPiece, sealtasks.TTPreCommit1, sealtasks.TTPreCommit2, sealtasks.TTCommit2, sealtasks.TTUnseal})
|
||||||
|
|
||||||
func WithWorkerStorage(transform func(paths.Store) paths.Store) NodeOpt {
|
func WithWorkerStorage(transform func(paths.Store) paths.Store) NodeOpt {
|
||||||
return func(opts *nodeOpts) error {
|
return func(opts *nodeOpts) error {
|
||||||
opts.workerStorageOpt = transform
|
opts.workerStorageOpt = transform
|
||||||
|
66
itests/wdpost_no_miner_storage_test.go
Normal file
66
itests/wdpost_no_miner_storage_test.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package itests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
logging "github.com/ipfs/go-log/v2"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/itests/kit"
|
||||||
|
"github.com/filecoin-project/lotus/storage/sealer/sealtasks"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestWindowPostNoMinerStorage(t *testing.T) {
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
_ = logging.SetLogLevel("storageminer", "INFO")
|
||||||
|
|
||||||
|
sealSectors := 2
|
||||||
|
presealSectors := 2*48*2 - sealSectors
|
||||||
|
|
||||||
|
sectors := presealSectors + sealSectors
|
||||||
|
|
||||||
|
var (
|
||||||
|
client kit.TestFullNode
|
||||||
|
miner kit.TestMiner
|
||||||
|
wiw, wdw, sealw kit.TestWorker
|
||||||
|
)
|
||||||
|
ens := kit.NewEnsemble(t, kit.LatestActorsAt(-1)).
|
||||||
|
FullNode(&client, kit.ThroughRPC()).
|
||||||
|
Miner(&miner, &client, kit.WithAllSubsystems(), kit.ThroughRPC(), kit.PresealSectors(presealSectors), kit.NoMinerStorage()).
|
||||||
|
Worker(&miner, &wiw, kit.ThroughRPC(), kit.WithTaskTypes([]sealtasks.TaskType{sealtasks.TTGenerateWinningPoSt})).
|
||||||
|
Worker(&miner, &wdw, kit.ThroughRPC(), kit.WithTaskTypes([]sealtasks.TaskType{sealtasks.TTGenerateWindowPoSt})).
|
||||||
|
Worker(&miner, &sealw, kit.ThroughRPC(), kit.WithSealWorkerTasks).
|
||||||
|
Start()
|
||||||
|
|
||||||
|
ens.InterconnectAll().BeginMiningMustPost(2 * time.Millisecond)
|
||||||
|
|
||||||
|
miner.PledgeSectors(ctx, sealSectors, 0, nil)
|
||||||
|
|
||||||
|
maddr, err := miner.ActorAddress(ctx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
di, err := client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
||||||
|
require.NoError(t, err)
|
||||||
|
di = di.NextNotElapsed()
|
||||||
|
|
||||||
|
// wait for new sectors to become active
|
||||||
|
waitUntil := di.Close + di.WPoStChallengeWindow*2 + di.WPoStProvingPeriod
|
||||||
|
t.Logf("Wait Height > %d", waitUntil)
|
||||||
|
|
||||||
|
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||||
|
t.Logf("Now Height = %d", ts.Height())
|
||||||
|
|
||||||
|
p, err := client.StateMinerPower(ctx, maddr, types.EmptyTSK)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
ssz, err := miner.ActorSectorSize(ctx, maddr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
require.Equal(t, p.MinerPower, p.TotalPower)
|
||||||
|
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)*uint64(sectors)))
|
||||||
|
}
|
@ -29,7 +29,7 @@ import (
|
|||||||
func TestWorkerPledge(t *testing.T) {
|
func TestWorkerPledge(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
_, miner, worker, ens := kit.EnsembleWorker(t, kit.WithAllSubsystems(), kit.ThroughRPC(), kit.WithNoLocalSealing(true),
|
_, miner, worker, ens := kit.EnsembleWorker(t, kit.WithAllSubsystems(), kit.ThroughRPC(), kit.WithNoLocalSealing(true),
|
||||||
kit.WithTaskTypes([]sealtasks.TaskType{sealtasks.TTFetch, sealtasks.TTCommit1, sealtasks.TTFinalize, sealtasks.TTAddPiece, sealtasks.TTPreCommit1, sealtasks.TTPreCommit2, sealtasks.TTCommit2, sealtasks.TTUnseal})) // no mock proofs
|
kit.WithSealWorkerTasks) // no mock proofs
|
||||||
|
|
||||||
ens.InterconnectAll().BeginMining(50 * time.Millisecond)
|
ens.InterconnectAll().BeginMining(50 * time.Millisecond)
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ func TestWorkerPledge(t *testing.T) {
|
|||||||
func TestWorkerPledgeSpread(t *testing.T) {
|
func TestWorkerPledgeSpread(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
_, miner, worker, ens := kit.EnsembleWorker(t, kit.WithAllSubsystems(), kit.ThroughRPC(),
|
_, miner, worker, ens := kit.EnsembleWorker(t, kit.WithAllSubsystems(), kit.ThroughRPC(),
|
||||||
kit.WithTaskTypes([]sealtasks.TaskType{sealtasks.TTFetch, sealtasks.TTCommit1, sealtasks.TTFinalize, sealtasks.TTAddPiece, sealtasks.TTPreCommit1, sealtasks.TTPreCommit2, sealtasks.TTCommit2, sealtasks.TTUnseal}),
|
kit.WithSealWorkerTasks,
|
||||||
kit.WithAssigner("spread"),
|
kit.WithAssigner("spread"),
|
||||||
) // no mock proofs
|
) // no mock proofs
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ func TestWorkerPledgeSpread(t *testing.T) {
|
|||||||
func TestWorkerPledgeLocalFin(t *testing.T) {
|
func TestWorkerPledgeLocalFin(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
_, miner, worker, ens := kit.EnsembleWorker(t, kit.WithAllSubsystems(), kit.ThroughRPC(),
|
_, miner, worker, ens := kit.EnsembleWorker(t, kit.WithAllSubsystems(), kit.ThroughRPC(),
|
||||||
kit.WithTaskTypes([]sealtasks.TaskType{sealtasks.TTFetch, sealtasks.TTCommit1, sealtasks.TTFinalize, sealtasks.TTAddPiece, sealtasks.TTPreCommit1, sealtasks.TTPreCommit2, sealtasks.TTCommit2, sealtasks.TTUnseal}),
|
kit.WithSealWorkerTasks,
|
||||||
kit.WithDisallowRemoteFinalize(true),
|
kit.WithDisallowRemoteFinalize(true),
|
||||||
) // no mock proofs
|
) // no mock proofs
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user