itests: More fixes after fixing sector metadata import

This commit is contained in:
Łukasz Magiera 2022-08-02 16:05:29 +02:00
parent 6d2990314f
commit 8294e03d4e
6 changed files with 23 additions and 15 deletions

View File

@ -60,7 +60,7 @@ func runTestCCUpgrade(t *testing.T) *kit.TestFullNode {
t.Fatal(err) t.Fatal(err)
} }
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1) CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner)
fmt.Printf("CCUpgrade: %d\n", CCUpgrade) fmt.Printf("CCUpgrade: %d\n", CCUpgrade)
miner.PledgeSectors(ctx, 1, 0, nil) miner.PledgeSectors(ctx, 1, 0, nil)

View File

@ -235,9 +235,12 @@ func (n *Ensemble) Miner(minerNode *TestMiner, full *TestFullNode, opts ...NodeO
} }
ownerKey := options.ownerKey ownerKey := options.ownerKey
var presealSectors int
if !n.bootstrapped { if !n.bootstrapped {
presealSectors = options.sectors
var ( var (
sectors = options.sectors
k *types.KeyInfo k *types.KeyInfo
genm *genesis.Miner genm *genesis.Miner
) )
@ -248,9 +251,9 @@ func (n *Ensemble) Miner(minerNode *TestMiner, full *TestFullNode, opts ...NodeO
// Create the preseal commitment. // Create the preseal commitment.
if n.options.mockProofs { if n.options.mockProofs {
genm, k, err = mock.PreSeal(proofType, actorAddr, sectors) genm, k, err = mock.PreSeal(proofType, actorAddr, presealSectors)
} else { } 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) require.NoError(n.t, err)
@ -281,6 +284,7 @@ func (n *Ensemble) Miner(minerNode *TestMiner, full *TestFullNode, opts ...NodeO
OwnerKey: ownerKey, OwnerKey: ownerKey,
FullNode: full, FullNode: full,
PresealDir: tdir, PresealDir: tdir,
PresealSectors: presealSectors,
options: options, options: options,
RemoteListener: rl, RemoteListener: rl,
} }
@ -537,7 +541,10 @@ func (n *Ensemble) Start() *Ensemble {
err = ds.Put(ctx, datastore.NewKey("miner-address"), m.ActorAddr.Bytes()) err = ds.Put(ctx, datastore.NewKey("miner-address"), m.ActorAddr.Bytes())
require.NoError(n.t, err) require.NoError(n.t, err)
if i < len(n.genesis.miners) && !n.bootstrapped {
// if this is a genesis miner, import preseal metadata
require.NoError(n.t, importPreSealMeta(ctx, n.genesis.miners[i], ds)) require.NoError(n.t, importPreSealMeta(ctx, n.genesis.miners[i], ds))
}
// using real proofs, therefore need real sectors. // using real proofs, therefore need real sectors.
if !n.bootstrapped && !n.options.mockProofs { if !n.bootstrapped && !n.options.mockProofs {

View File

@ -79,6 +79,7 @@ type TestMiner struct {
FullNode *TestFullNode FullNode *TestFullNode
PresealDir string PresealDir string
PresealSectors int
Libp2p struct { Libp2p struct {
PeerID peer.ID PeerID peer.ID
@ -131,7 +132,7 @@ func (tm *TestMiner) StartPledge(ctx context.Context, n, existing int, blockNoti
for { for {
s, err := tm.SectorsListNonGenesis(ctx) 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 %d, ex %d)\n", len(s), n, existing)
if len(s) >= n+existing { if len(s) >= n+existing {
break break
} }
@ -216,5 +217,5 @@ func (tm *TestMiner) SectorsListNonGenesis(ctx context.Context) ([]abi.SectorNum
return l[i] < l[j] return l[i] < l[j]
}) })
return l[tm.options.sectors:], nil return l[tm.PresealSectors:], nil
} }

View File

@ -34,7 +34,7 @@ func TestMakeAvailable(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1) CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner)
miner.PledgeSectors(ctx, 1, 0, nil) miner.PledgeSectors(ctx, 1, 0, nil)
sl, err := miner.SectorsListNonGenesis(ctx) sl, err := miner.SectorsListNonGenesis(ctx)

View File

@ -34,8 +34,8 @@ func TestPreferNoUpgrade(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1) CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner)
Sealed := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 2) Sealed := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1)
{ {
miner.PledgeSectors(ctx, 1, 0, nil) miner.PledgeSectors(ctx, 1, 0, nil)

View File

@ -31,7 +31,7 @@ func TestAbortUpgradeAvailable(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner + 1) CCUpgrade := abi.SectorNumber(kit.DefaultPresealsPerBootstrapMiner)
fmt.Printf("CCUpgrade: %d\n", CCUpgrade) fmt.Printf("CCUpgrade: %d\n", CCUpgrade)
miner.PledgeSectors(ctx, 1, 0, nil) miner.PledgeSectors(ctx, 1, 0, nil)