2022-03-17 20:21:52 +00:00
|
|
|
package itests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
"github.com/filecoin-project/go-state-types/network"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/api"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
"github.com/filecoin-project/lotus/itests/kit"
|
|
|
|
"github.com/filecoin-project/lotus/node/config"
|
2022-06-14 17:41:59 +00:00
|
|
|
sealing "github.com/filecoin-project/lotus/storage/pipeline"
|
2022-03-17 20:21:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMakeAvailable(t *testing.T) {
|
|
|
|
kit.QuietMiningLogs()
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
blockTime := 1 * time.Millisecond
|
|
|
|
|
|
|
|
client, miner, ens := kit.EnsembleMinimal(t, kit.GenesisNetworkVersion(network.Version15), kit.ThroughRPC(), kit.MutateSealingConfig(func(sc *config.SealingConfig) {
|
|
|
|
sc.MakeCCSectorsAvailable = true
|
|
|
|
}))
|
|
|
|
ens.InterconnectAll().BeginMiningMustPost(blockTime)
|
|
|
|
|
|
|
|
maddr, err := miner.ActorAddress(ctx)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1)
|
|
|
|
|
|
|
|
miner.PledgeSectors(ctx, 1, 0, nil)
|
|
|
|
sl, err := miner.SectorsList(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, sl, 1, "expected 1 sector")
|
|
|
|
require.Equal(t, CCUpgrade, sl[0], "unexpected sector number")
|
|
|
|
{
|
|
|
|
si, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Less(t, 50000, int(si.Expiration))
|
|
|
|
}
|
2022-03-17 20:39:52 +00:00
|
|
|
client.WaitForSectorActive(ctx, t, CCUpgrade, maddr)
|
2022-03-17 20:21:52 +00:00
|
|
|
|
|
|
|
sl, err = miner.SectorsList(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, sl, 1, "expected 1 sector")
|
|
|
|
|
|
|
|
status, err := miner.SectorsStatus(ctx, CCUpgrade, true)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, api.SectorState(sealing.Available), status.State)
|
|
|
|
|
|
|
|
dh := kit.NewDealHarness(t, client, miner, miner)
|
|
|
|
deal, res, inPath := dh.MakeOnlineDeal(ctx, kit.MakeFullDealParams{
|
|
|
|
Rseed: 6,
|
|
|
|
SuspendUntilCryptoeconStable: true,
|
|
|
|
})
|
|
|
|
outPath := dh.PerformRetrieval(context.Background(), deal, res.Root, false)
|
|
|
|
kit.AssertFilesEqual(t, inPath, outPath)
|
|
|
|
|
|
|
|
sl, err = miner.SectorsList(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, sl, 1, "expected 1 sector")
|
|
|
|
|
|
|
|
status, err = miner.SectorsStatus(ctx, CCUpgrade, true)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, 1, len(status.Deals))
|
|
|
|
miner.WaitSectorsProving(ctx, map[abi.SectorNumber]struct{}{
|
|
|
|
CCUpgrade: {},
|
|
|
|
})
|
2022-03-17 20:27:10 +00:00
|
|
|
}
|