From d1173265b3f0de5df872bf95b47f87d97c444ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 2 Aug 2022 15:29:38 +0200 Subject: [PATCH] itests: Helper returning non-genesis sector list --- itests/batch_deal_test.go | 4 ++-- itests/ccupgrade_test.go | 4 ++-- itests/deadlines_test.go | 2 +- itests/deals_pricing_test.go | 4 ++-- itests/kit/deals.go | 2 +- itests/kit/node_miner.go | 17 +++++++++++++++-- itests/sdr_upgrade_test.go | 2 +- itests/sector_make_cc_avail_test.go | 6 +++--- itests/sector_miner_collateral_test.go | 2 +- itests/sector_prefer_no_upgrade_test.go | 6 +++--- itests/sector_revert_available_test.go | 4 ++-- itests/wdpost_dispute_test.go | 2 +- 12 files changed, 34 insertions(+), 21 deletions(-) diff --git a/itests/batch_deal_test.go b/itests/batch_deal_test.go index 64326c822..329a6b3bb 100644 --- a/itests/batch_deal_test.go +++ b/itests/batch_deal_test.go @@ -74,7 +74,7 @@ func TestBatchDealInput(t *testing.T) { require.NoError(t, err) checkNoPadding := func() { - sl, err := miner.SectorsList(ctx) + sl, err := miner.SectorsListNonGenesis(ctx) require.NoError(t, err) sort.Slice(sl, func(i, j int) bool { @@ -125,7 +125,7 @@ func TestBatchDealInput(t *testing.T) { checkNoPadding() - sl, err := miner.SectorsList(ctx) + sl, err := miner.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Equal(t, len(sl), expectSectors) } diff --git a/itests/ccupgrade_test.go b/itests/ccupgrade_test.go index 880c4f309..1bfbf048b 100644 --- a/itests/ccupgrade_test.go +++ b/itests/ccupgrade_test.go @@ -64,7 +64,7 @@ func runTestCCUpgrade(t *testing.T) *kit.TestFullNode { fmt.Printf("CCUpgrade: %d\n", CCUpgrade) miner.PledgeSectors(ctx, 1, 0, nil) - sl, err := miner.SectorsList(ctx) + sl, err := miner.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Len(t, sl, 1, "expected 1 sector") 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) require.NoError(t, err) - sl, err = miner.SectorsList(ctx) + sl, err = miner.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Len(t, sl, 1, "expected 1 sector") diff --git a/itests/deadlines_test.go b/itests/deadlines_test.go index edcabba21..e76d4dafd 100644 --- a/itests/deadlines_test.go +++ b/itests/deadlines_test.go @@ -308,7 +308,7 @@ func TestDeadlineToggling(t *testing.T) { // terminate sectors on minerD { var terminationDeclarationParams []miner2.TerminationDeclaration - secs, err := minerD.SectorsList(ctx) + secs, err := minerD.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Len(t, secs, sectorsD) diff --git a/itests/deals_pricing_test.go b/itests/deals_pricing_test.go index e01f74e0c..15482f62b 100644 --- a/itests/deals_pricing_test.go +++ b/itests/deals_pricing_test.go @@ -70,7 +70,7 @@ func TestQuotePriceForUnsealedRetrieval(t *testing.T) { //stm: @STORAGE_LIST_001, @MINER_SECTOR_LIST_001 ss, err := miner.StorageList(context.Background()) require.NoError(t, err) - _, err = miner.SectorsList(ctx) + _, err = miner.SectorsListNonGenesis(ctx) require.NoError(t, err) //stm: @STORAGE_DROP_SECTOR_001, @STORAGE_LIST_001 @@ -95,7 +95,7 @@ iLoop: // remove the other unsealed file as well ss, err = miner.StorageList(context.Background()) require.NoError(t, err) - _, err = miner.SectorsList(ctx) + _, err = miner.SectorsListNonGenesis(ctx) require.NoError(t, err) for storeID, sd := range ss { for _, sector := range sd { diff --git a/itests/kit/deals.go b/itests/kit/deals.go index 55ca4e1b7..794a63803 100644 --- a/itests/kit/deals.go +++ b/itests/kit/deals.go @@ -292,7 +292,7 @@ func (dh *DealHarness) WaitDealPublished(ctx context.Context, deal *cid.Cid) { } func (dh *DealHarness) StartSealingWaiting(ctx context.Context) { - snums, err := dh.main.SectorsList(ctx) + snums, err := dh.main.SectorsListNonGenesis(ctx) require.NoError(dh.t, err) for _, snum := range snums { si, err := dh.main.SectorsStatus(ctx, snum, false) diff --git a/itests/kit/node_miner.go b/itests/kit/node_miner.go index 65c7abe38..bec9e247c 100644 --- a/itests/kit/node_miner.go +++ b/itests/kit/node_miner.go @@ -8,6 +8,7 @@ import ( "net" "os" "path/filepath" + "sort" "strings" "testing" "time" @@ -128,7 +129,7 @@ func (tm *TestMiner) StartPledge(ctx context.Context, n, existing int, blockNoti } 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) fmt.Printf("Sectors: %d\n", len(s)) 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") - s, err := tm.StorageMiner.SectorsList(ctx) + s, err := tm.SectorsListNonGenesis(ctx) require.NoError(tm.t, err) 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 } +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 +} diff --git a/itests/sdr_upgrade_test.go b/itests/sdr_upgrade_test.go index a90d0bebe..493dc1224 100644 --- a/itests/sdr_upgrade_test.go +++ b/itests/sdr_upgrade_test.go @@ -95,7 +95,7 @@ func TestSDRUpgrade(t *testing.T) { // before. miner.PledgeSectors(ctx, 9, 0, pledge) - s, err := miner.SectorsList(ctx) + s, err := miner.SectorsListNonGenesis(ctx) require.NoError(t, err) sort.Slice(s, func(i, j int) bool { return s[i] < s[j] diff --git a/itests/sector_make_cc_avail_test.go b/itests/sector_make_cc_avail_test.go index 437e803b0..f441fe3a3 100644 --- a/itests/sector_make_cc_avail_test.go +++ b/itests/sector_make_cc_avail_test.go @@ -37,7 +37,7 @@ func TestMakeAvailable(t *testing.T) { CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1) miner.PledgeSectors(ctx, 1, 0, nil) - sl, err := miner.SectorsList(ctx) + sl, err := miner.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Len(t, sl, 1, "expected 1 sector") require.Equal(t, CCUpgrade, sl[0], "unexpected sector number") @@ -48,7 +48,7 @@ func TestMakeAvailable(t *testing.T) { } client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) - sl, err = miner.SectorsList(ctx) + sl, err = miner.SectorsListNonGenesis(ctx) require.NoError(t, err) 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) kit.AssertFilesEqual(t, inPath, outPath) - sl, err = miner.SectorsList(ctx) + sl, err = miner.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Len(t, sl, 1, "expected 1 sector") diff --git a/itests/sector_miner_collateral_test.go b/itests/sector_miner_collateral_test.go index 07dad8edd..b722dae65 100644 --- a/itests/sector_miner_collateral_test.go +++ b/itests/sector_miner_collateral_test.go @@ -96,7 +96,7 @@ func TestMinerBalanceCollateral(t *testing.T) { } // check that sector messages had zero value set - sl, err := miner.SectorsList(ctx) + sl, err := miner.SectorsListNonGenesis(ctx) require.NoError(t, err) for _, number := range sl { diff --git a/itests/sector_prefer_no_upgrade_test.go b/itests/sector_prefer_no_upgrade_test.go index 30674b36e..6c35cba1a 100644 --- a/itests/sector_prefer_no_upgrade_test.go +++ b/itests/sector_prefer_no_upgrade_test.go @@ -39,7 +39,7 @@ func TestPreferNoUpgrade(t *testing.T) { { miner.PledgeSectors(ctx, 1, 0, nil) - sl, err := miner.SectorsList(ctx) + sl, err := miner.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Len(t, sl, 1, "expected 1 sector") 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) require.NoError(t, err) - sl, err = miner.SectorsList(ctx) + sl, err = miner.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Len(t, sl, 1, "expected 1 sector") } @@ -68,7 +68,7 @@ func TestPreferNoUpgrade(t *testing.T) { kit.AssertFilesEqual(t, inPath, outPath) } - sl, err := miner.SectorsList(ctx) + sl, err := miner.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Len(t, sl, 2, "expected 2 sectors") diff --git a/itests/sector_revert_available_test.go b/itests/sector_revert_available_test.go index 559e8e8b0..d47e06051 100644 --- a/itests/sector_revert_available_test.go +++ b/itests/sector_revert_available_test.go @@ -35,7 +35,7 @@ func TestAbortUpgradeAvailable(t *testing.T) { fmt.Printf("CCUpgrade: %d\n", CCUpgrade) miner.PledgeSectors(ctx, 1, 0, nil) - sl, err := miner.SectorsList(ctx) + sl, err := miner.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Len(t, sl, 1, "expected 1 sector") 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) require.NoError(t, err) - sl, err = miner.SectorsList(ctx) + sl, err = miner.SectorsListNonGenesis(ctx) require.NoError(t, err) require.Len(t, sl, 1, "expected 1 sector") diff --git a/itests/wdpost_dispute_test.go b/itests/wdpost_dispute_test.go index f26adb39b..0982f44c8 100644 --- a/itests/wdpost_dispute_test.go +++ b/itests/wdpost_dispute_test.go @@ -94,7 +94,7 @@ func TestWindowPostDispute(t *testing.T) { require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz))) //stm: @MINER_SECTOR_LIST_001 - evilSectors, err := evilMiner.SectorsList(ctx) + evilSectors, err := evilMiner.SectorsListNonGenesis(ctx) require.NoError(t, err) evilSectorNo := evilSectors[0] // only one. //stm: @CHAIN_STATE_SECTOR_PARTITION_001