itests: Helper returning non-genesis sector list

This commit is contained in:
Łukasz Magiera 2022-08-02 15:29:38 +02:00
parent eb366c6aa0
commit d1173265b3
12 changed files with 34 additions and 21 deletions

View File

@ -74,7 +74,7 @@ func TestBatchDealInput(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
checkNoPadding := func() { checkNoPadding := func() {
sl, err := miner.SectorsList(ctx) sl, err := miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
sort.Slice(sl, func(i, j int) bool { sort.Slice(sl, func(i, j int) bool {
@ -125,7 +125,7 @@ func TestBatchDealInput(t *testing.T) {
checkNoPadding() checkNoPadding()
sl, err := miner.SectorsList(ctx) sl, err := miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, len(sl), expectSectors) require.Equal(t, len(sl), expectSectors)
} }

View File

@ -64,7 +64,7 @@ func runTestCCUpgrade(t *testing.T) *kit.TestFullNode {
fmt.Printf("CCUpgrade: %d\n", CCUpgrade) fmt.Printf("CCUpgrade: %d\n", CCUpgrade)
miner.PledgeSectors(ctx, 1, 0, nil) miner.PledgeSectors(ctx, 1, 0, nil)
sl, err := miner.SectorsList(ctx) sl, err := miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sl, 1, "expected 1 sector") require.Len(t, sl, 1, "expected 1 sector")
require.Equal(t, CCUpgrade, sl[0], "unexpected sector number") require.Equal(t, CCUpgrade, sl[0], "unexpected sector number")
@ -79,7 +79,7 @@ func runTestCCUpgrade(t *testing.T) *kit.TestFullNode {
err = miner.SectorMarkForUpgrade(ctx, sl[0], true) err = miner.SectorMarkForUpgrade(ctx, sl[0], true)
require.NoError(t, err) require.NoError(t, err)
sl, err = miner.SectorsList(ctx) sl, err = miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sl, 1, "expected 1 sector") require.Len(t, sl, 1, "expected 1 sector")

View File

@ -308,7 +308,7 @@ func TestDeadlineToggling(t *testing.T) {
// terminate sectors on minerD // terminate sectors on minerD
{ {
var terminationDeclarationParams []miner2.TerminationDeclaration var terminationDeclarationParams []miner2.TerminationDeclaration
secs, err := minerD.SectorsList(ctx) secs, err := minerD.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, secs, sectorsD) require.Len(t, secs, sectorsD)

View File

@ -70,7 +70,7 @@ func TestQuotePriceForUnsealedRetrieval(t *testing.T) {
//stm: @STORAGE_LIST_001, @MINER_SECTOR_LIST_001 //stm: @STORAGE_LIST_001, @MINER_SECTOR_LIST_001
ss, err := miner.StorageList(context.Background()) ss, err := miner.StorageList(context.Background())
require.NoError(t, err) require.NoError(t, err)
_, err = miner.SectorsList(ctx) _, err = miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
//stm: @STORAGE_DROP_SECTOR_001, @STORAGE_LIST_001 //stm: @STORAGE_DROP_SECTOR_001, @STORAGE_LIST_001
@ -95,7 +95,7 @@ iLoop:
// remove the other unsealed file as well // remove the other unsealed file as well
ss, err = miner.StorageList(context.Background()) ss, err = miner.StorageList(context.Background())
require.NoError(t, err) require.NoError(t, err)
_, err = miner.SectorsList(ctx) _, err = miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
for storeID, sd := range ss { for storeID, sd := range ss {
for _, sector := range sd { for _, sector := range sd {

View File

@ -292,7 +292,7 @@ func (dh *DealHarness) WaitDealPublished(ctx context.Context, deal *cid.Cid) {
} }
func (dh *DealHarness) StartSealingWaiting(ctx context.Context) { func (dh *DealHarness) StartSealingWaiting(ctx context.Context) {
snums, err := dh.main.SectorsList(ctx) snums, err := dh.main.SectorsListNonGenesis(ctx)
require.NoError(dh.t, err) require.NoError(dh.t, err)
for _, snum := range snums { for _, snum := range snums {
si, err := dh.main.SectorsStatus(ctx, snum, false) si, err := dh.main.SectorsStatus(ctx, snum, false)

View File

@ -8,6 +8,7 @@ import (
"net" "net"
"os" "os"
"path/filepath" "path/filepath"
"sort"
"strings" "strings"
"testing" "testing"
"time" "time"
@ -128,7 +129,7 @@ func (tm *TestMiner) StartPledge(ctx context.Context, n, existing int, blockNoti
} }
for { for {
s, err := tm.StorageMiner.SectorsList(ctx) // Note - the test builder doesn't import genesis sectors into FSM s, err := tm.SectorsListNonGenesis(ctx)
require.NoError(tm.t, err) require.NoError(tm.t, err)
fmt.Printf("Sectors: %d\n", len(s)) fmt.Printf("Sectors: %d\n", len(s))
if len(s) >= n+existing { if len(s) >= n+existing {
@ -140,7 +141,7 @@ func (tm *TestMiner) StartPledge(ctx context.Context, n, existing int, blockNoti
fmt.Printf("All sectors is fsm\n") fmt.Printf("All sectors is fsm\n")
s, err := tm.StorageMiner.SectorsList(ctx) s, err := tm.SectorsListNonGenesis(ctx)
require.NoError(tm.t, err) require.NoError(tm.t, err)
toCheck := map[abi.SectorNumber]struct{}{} toCheck := map[abi.SectorNumber]struct{}{}
@ -205,3 +206,15 @@ func (tm *TestMiner) AddStorage(ctx context.Context, t *testing.T, conf func(*pa
return cfg.ID return cfg.ID
} }
func (tm *TestMiner) SectorsListNonGenesis(ctx context.Context) ([]abi.SectorNumber, error) {
l, err := tm.SectorsList(ctx)
if err != nil {
return nil, err
}
// sort just in case
sort.Slice(l, func(i, j int) bool {
return l[i] < l[j]
})
return l[tm.options.sectors:], nil
}

View File

@ -95,7 +95,7 @@ func TestSDRUpgrade(t *testing.T) {
// before. // before.
miner.PledgeSectors(ctx, 9, 0, pledge) miner.PledgeSectors(ctx, 9, 0, pledge)
s, err := miner.SectorsList(ctx) s, err := miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
sort.Slice(s, func(i, j int) bool { sort.Slice(s, func(i, j int) bool {
return s[i] < s[j] return s[i] < s[j]

View File

@ -37,7 +37,7 @@ func TestMakeAvailable(t *testing.T) {
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1) CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1)
miner.PledgeSectors(ctx, 1, 0, nil) miner.PledgeSectors(ctx, 1, 0, nil)
sl, err := miner.SectorsList(ctx) sl, err := miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sl, 1, "expected 1 sector") require.Len(t, sl, 1, "expected 1 sector")
require.Equal(t, CCUpgrade, sl[0], "unexpected sector number") require.Equal(t, CCUpgrade, sl[0], "unexpected sector number")
@ -48,7 +48,7 @@ func TestMakeAvailable(t *testing.T) {
} }
client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) client.WaitForSectorActive(ctx, t, CCUpgrade, maddr)
sl, err = miner.SectorsList(ctx) sl, err = miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sl, 1, "expected 1 sector") require.Len(t, sl, 1, "expected 1 sector")
@ -64,7 +64,7 @@ func TestMakeAvailable(t *testing.T) {
outPath := dh.PerformRetrieval(context.Background(), deal, res.Root, false) outPath := dh.PerformRetrieval(context.Background(), deal, res.Root, false)
kit.AssertFilesEqual(t, inPath, outPath) kit.AssertFilesEqual(t, inPath, outPath)
sl, err = miner.SectorsList(ctx) sl, err = miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sl, 1, "expected 1 sector") require.Len(t, sl, 1, "expected 1 sector")

View File

@ -96,7 +96,7 @@ func TestMinerBalanceCollateral(t *testing.T) {
} }
// check that sector messages had zero value set // check that sector messages had zero value set
sl, err := miner.SectorsList(ctx) sl, err := miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
for _, number := range sl { for _, number := range sl {

View File

@ -39,7 +39,7 @@ func TestPreferNoUpgrade(t *testing.T) {
{ {
miner.PledgeSectors(ctx, 1, 0, nil) miner.PledgeSectors(ctx, 1, 0, nil)
sl, err := miner.SectorsList(ctx) sl, err := miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sl, 1, "expected 1 sector") require.Len(t, sl, 1, "expected 1 sector")
require.Equal(t, CCUpgrade, sl[0], "unexpected sector number") require.Equal(t, CCUpgrade, sl[0], "unexpected sector number")
@ -53,7 +53,7 @@ func TestPreferNoUpgrade(t *testing.T) {
err = miner.SectorMarkForUpgrade(ctx, sl[0], true) err = miner.SectorMarkForUpgrade(ctx, sl[0], true)
require.NoError(t, err) require.NoError(t, err)
sl, err = miner.SectorsList(ctx) sl, err = miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sl, 1, "expected 1 sector") require.Len(t, sl, 1, "expected 1 sector")
} }
@ -68,7 +68,7 @@ func TestPreferNoUpgrade(t *testing.T) {
kit.AssertFilesEqual(t, inPath, outPath) kit.AssertFilesEqual(t, inPath, outPath)
} }
sl, err := miner.SectorsList(ctx) sl, err := miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sl, 2, "expected 2 sectors") require.Len(t, sl, 2, "expected 2 sectors")

View File

@ -35,7 +35,7 @@ func TestAbortUpgradeAvailable(t *testing.T) {
fmt.Printf("CCUpgrade: %d\n", CCUpgrade) fmt.Printf("CCUpgrade: %d\n", CCUpgrade)
miner.PledgeSectors(ctx, 1, 0, nil) miner.PledgeSectors(ctx, 1, 0, nil)
sl, err := miner.SectorsList(ctx) sl, err := miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sl, 1, "expected 1 sector") require.Len(t, sl, 1, "expected 1 sector")
require.Equal(t, CCUpgrade, sl[0], "unexpected sector number") require.Equal(t, CCUpgrade, sl[0], "unexpected sector number")
@ -49,7 +49,7 @@ func TestAbortUpgradeAvailable(t *testing.T) {
err = miner.SectorMarkForUpgrade(ctx, sl[0], true) err = miner.SectorMarkForUpgrade(ctx, sl[0], true)
require.NoError(t, err) require.NoError(t, err)
sl, err = miner.SectorsList(ctx) sl, err = miner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sl, 1, "expected 1 sector") require.Len(t, sl, 1, "expected 1 sector")

View File

@ -94,7 +94,7 @@ func TestWindowPostDispute(t *testing.T) {
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz))) require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)))
//stm: @MINER_SECTOR_LIST_001 //stm: @MINER_SECTOR_LIST_001
evilSectors, err := evilMiner.SectorsList(ctx) evilSectors, err := evilMiner.SectorsListNonGenesis(ctx)
require.NoError(t, err) require.NoError(t, err)
evilSectorNo := evilSectors[0] // only one. evilSectorNo := evilSectors[0] // only one.
//stm: @CHAIN_STATE_SECTOR_PARTITION_001 //stm: @CHAIN_STATE_SECTOR_PARTITION_001