Skip to content

Commit

Permalink
itests: More fixes after fixing sector metadata import
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Aug 2, 2022
1 parent 6d29903 commit 82f9221
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion itests/ccupgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func runTestCCUpgrade(t *testing.T) *kit.TestFullNode {
t.Fatal(err)
}

CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1)
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner)
fmt.Printf("CCUpgrade: %d\n", CCUpgrade)

miner.PledgeSectors(ctx, 1, 0, nil)
Expand Down
19 changes: 13 additions & 6 deletions itests/kit/ensemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,14 @@ func (n *Ensemble) Miner(minerNode *TestMiner, full *TestFullNode, opts ...NodeO
}

ownerKey := options.ownerKey
var presealSectors int

if !n.bootstrapped {
presealSectors = options.sectors

var (
sectors = options.sectors
k *types.KeyInfo
genm *genesis.Miner
k *types.KeyInfo
genm *genesis.Miner
)

// Will use 2KiB sectors by default (default value of sectorSize).
Expand All @@ -248,9 +251,9 @@ func (n *Ensemble) Miner(minerNode *TestMiner, full *TestFullNode, opts ...NodeO

// Create the preseal commitment.
if n.options.mockProofs {
genm, k, err = mock.PreSeal(proofType, actorAddr, sectors)
genm, k, err = mock.PreSeal(proofType, actorAddr, presealSectors)
} else {
genm, k, err = seed.PreSeal(actorAddr, proofType, 0, sectors, tdir, []byte("make genesis mem random"), nil, true)
genm, k, err = seed.PreSeal(actorAddr, proofType, 0, presealSectors, tdir, []byte("make genesis mem random"), nil, true)
}
require.NoError(n.t, err)

Expand Down Expand Up @@ -281,6 +284,7 @@ func (n *Ensemble) Miner(minerNode *TestMiner, full *TestFullNode, opts ...NodeO
OwnerKey: ownerKey,
FullNode: full,
PresealDir: tdir,
PresealSectors: presealSectors,
options: options,
RemoteListener: rl,
}
Expand Down Expand Up @@ -537,7 +541,10 @@ func (n *Ensemble) Start() *Ensemble {
err = ds.Put(ctx, datastore.NewKey("miner-address"), m.ActorAddr.Bytes())
require.NoError(n.t, err)

require.NoError(n.t, importPreSealMeta(ctx, n.genesis.miners[i], ds))
if i < len(n.genesis.miners) {
// if this is a genesis miner, import preseal metadata
require.NoError(n.t, importPreSealMeta(ctx, n.genesis.miners[i], ds))
}

// using real proofs, therefore need real sectors.
if !n.bootstrapped && !n.options.mockProofs {
Expand Down
9 changes: 5 additions & 4 deletions itests/kit/node_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ type TestMiner struct {
MineOne func(context.Context, miner.MineReq) error
Stop func(context.Context) error

FullNode *TestFullNode
PresealDir string
FullNode *TestFullNode
PresealDir string
PresealSectors int

Libp2p struct {
PeerID peer.ID
Expand Down Expand Up @@ -131,7 +132,7 @@ func (tm *TestMiner) StartPledge(ctx context.Context, n, existing int, blockNoti
for {
s, err := tm.SectorsListNonGenesis(ctx)
require.NoError(tm.t, err)
fmt.Printf("Sectors: %d\n", len(s))
fmt.Printf("Sectors: %d (n %d, ex %d)\n", len(s), n, existing)
if len(s) >= n+existing {
break
}
Expand Down Expand Up @@ -216,5 +217,5 @@ func (tm *TestMiner) SectorsListNonGenesis(ctx context.Context) ([]abi.SectorNum
return l[i] < l[j]
})

return l[tm.options.sectors:], nil
return l[tm.PresealSectors:], nil
}
2 changes: 1 addition & 1 deletion itests/sector_make_cc_avail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestMakeAvailable(t *testing.T) {
t.Fatal(err)
}

CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1)
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner)

miner.PledgeSectors(ctx, 1, 0, nil)
sl, err := miner.SectorsListNonGenesis(ctx)
Expand Down
4 changes: 2 additions & 2 deletions itests/sector_prefer_no_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func TestPreferNoUpgrade(t *testing.T) {
t.Fatal(err)
}

CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1)
Sealed := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 2)
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner)
Sealed := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1)

{
miner.PledgeSectors(ctx, 1, 0, nil)
Expand Down
2 changes: 1 addition & 1 deletion itests/sector_revert_available_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestAbortUpgradeAvailable(t *testing.T) {
t.Fatal(err)
}

CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1)
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner)
fmt.Printf("CCUpgrade: %d\n", CCUpgrade)

miner.PledgeSectors(ctx, 1, 0, nil)
Expand Down

0 comments on commit 82f9221

Please sign in to comment.