itests: Share WaitForSectorActive correctly
This commit is contained in:
parent
433e9c351d
commit
0536eb898d
@ -7,7 +7,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ func runTestCCUpgrade(t *testing.T) *kit.TestFullNode {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Less(t, 50000, int(si.Expiration))
|
require.Less(t, 50000, int(si.Expiration))
|
||||||
}
|
}
|
||||||
waitForSectorActive(ctx, t, CCUpgrade, client, maddr)
|
client.WaitForSectorActive(ctx, t, CCUpgrade, maddr)
|
||||||
|
|
||||||
//stm: @SECTOR_CC_UPGRADE_001
|
//stm: @SECTOR_CC_UPGRADE_001
|
||||||
err = miner.SectorMarkForUpgrade(ctx, sl[0], true)
|
err = miner.SectorMarkForUpgrade(ctx, sl[0], true)
|
||||||
@ -86,18 +85,3 @@ func runTestCCUpgrade(t *testing.T) *kit.TestFullNode {
|
|||||||
|
|
||||||
return client
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -2,7 +2,9 @@ package kit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
@ -67,6 +69,21 @@ func (f *TestFullNode) WaitTillChain(ctx context.Context, pred ChainPredicate) *
|
|||||||
return nil
|
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.
|
// ChainPredicate encapsulates a chain condition.
|
||||||
type ChainPredicate func(set *types.TipSet) bool
|
type ChainPredicate func(set *types.TipSet) bool
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func TestMakeAvailable(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Less(t, 50000, int(si.Expiration))
|
require.Less(t, 50000, int(si.Expiration))
|
||||||
}
|
}
|
||||||
waitForSectorActive(ctx, t, CCUpgrade, client, maddr)
|
client.WaitForSectorActive(ctx, t, CCUpgrade, maddr)
|
||||||
|
|
||||||
sl, err = miner.SectorsList(ctx)
|
sl, err = miner.SectorsList(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -48,7 +48,7 @@ func TestPreferNoUpgrade(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Less(t, 50000, int(si.Expiration))
|
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)
|
err = miner.SectorMarkForUpgrade(ctx, sl[0], true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -44,7 +44,7 @@ func TestAbortUpgradeAvailable(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Less(t, 50000, int(si.Expiration))
|
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)
|
err = miner.SectorMarkForUpgrade(ctx, sl[0], true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user