diff --git a/itests/ccupgrade_test.go b/itests/ccupgrade_test.go index b5e37cdcd..ba2b5b4eb 100644 --- a/itests/ccupgrade_test.go +++ b/itests/ccupgrade_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" @@ -58,7 +57,7 @@ func runTestCCUpgrade(t *testing.T) *kit.TestFullNode { require.NoError(t, err) require.Less(t, 50000, int(si.Expiration)) } - waitForSectorActive(ctx, t, CCUpgrade, client, maddr) + client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) //stm: @SECTOR_CC_UPGRADE_001 err = miner.SectorMarkForUpgrade(ctx, sl[0], true) @@ -86,18 +85,3 @@ func runTestCCUpgrade(t *testing.T) *kit.TestFullNode { return client } - -func waitForSectorActive(ctx context.Context, t *testing.T, sn abi.SectorNumber, node *kit.TestFullNode, maddr address.Address) { - for { - active, err := node.StateMinerActiveSectors(ctx, maddr, types.EmptyTSK) - require.NoError(t, err) - for _, si := range active { - if si.SectorNumber == sn { - fmt.Printf("ACTIVE\n") - return - } - } - - time.Sleep(time.Second) - } -} diff --git a/itests/kit/node_full.go b/itests/kit/node_full.go index b606db8f4..1714e01e0 100644 --- a/itests/kit/node_full.go +++ b/itests/kit/node_full.go @@ -2,7 +2,9 @@ package kit import ( "context" + "fmt" "testing" + "time" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" @@ -67,6 +69,21 @@ func (f *TestFullNode) WaitTillChain(ctx context.Context, pred ChainPredicate) * return nil } +func (f *TestFullNode) WaitForSectorActive(ctx context.Context, t *testing.T, sn abi.SectorNumber, maddr address.Address) { + for { + active, err := f.StateMinerActiveSectors(ctx, maddr, types.EmptyTSK) + require.NoError(t, err) + for _, si := range active { + if si.SectorNumber == sn { + fmt.Printf("ACTIVE\n") + return + } + } + + time.Sleep(time.Second) + } +} + // ChainPredicate encapsulates a chain condition. type ChainPredicate func(set *types.TipSet) bool diff --git a/itests/sector_make_cc_avail_test.go b/itests/sector_make_cc_avail_test.go index 10c068370..094367e96 100644 --- a/itests/sector_make_cc_avail_test.go +++ b/itests/sector_make_cc_avail_test.go @@ -46,7 +46,7 @@ func TestMakeAvailable(t *testing.T) { require.NoError(t, err) require.Less(t, 50000, int(si.Expiration)) } - waitForSectorActive(ctx, t, CCUpgrade, client, maddr) + client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) sl, err = miner.SectorsList(ctx) require.NoError(t, err) diff --git a/itests/sector_prefer_no_upgrade_test.go b/itests/sector_prefer_no_upgrade_test.go index e7e0e60fd..11fd2c1de 100644 --- a/itests/sector_prefer_no_upgrade_test.go +++ b/itests/sector_prefer_no_upgrade_test.go @@ -48,7 +48,7 @@ func TestPreferNoUpgrade(t *testing.T) { require.NoError(t, err) require.Less(t, 50000, int(si.Expiration)) } - waitForSectorActive(ctx, t, CCUpgrade, client, maddr) + client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) err = miner.SectorMarkForUpgrade(ctx, sl[0], true) require.NoError(t, err) diff --git a/itests/sector_revert_available_test.go b/itests/sector_revert_available_test.go index a23f6c609..6827a85fa 100644 --- a/itests/sector_revert_available_test.go +++ b/itests/sector_revert_available_test.go @@ -44,7 +44,7 @@ func TestAbortUpgradeAvailable(t *testing.T) { require.NoError(t, err) require.Less(t, 50000, int(si.Expiration)) } - waitForSectorActive(ctx, t, CCUpgrade, client, maddr) + client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) err = miner.SectorMarkForUpgrade(ctx, sl[0], true) require.NoError(t, err)