WIP getting post in sectorbuilder_test to work

This commit is contained in:
Łukasz Magiera 2019-11-26 00:31:34 +01:00
parent 2421f5d589
commit 7a3ffbf9fe
2 changed files with 29 additions and 21 deletions

View File

@ -291,7 +291,7 @@ func (sb *SectorBuilder) SealCommit(sectorID uint64, ticket SealTicket, seed Sea
}
}
sealedPath, err := sb.sealedSectorPath(sectorID)
/* sealedPath, err := sb.sealedSectorPath(sectorID)
if err != nil {
return nil, err
}
@ -312,7 +312,7 @@ func (sb *SectorBuilder) SealCommit(sectorID uint64, ticket SealTicket, seed Sea
)
if err != nil {
return nil, xerrors.Errorf("ImportSealedSector: %w", err)
}
}*/
return proof, nil
}

View File

@ -1,6 +1,8 @@
package sectorbuilder_test
import (
"context"
"fmt"
"io"
"io/ioutil"
"math/rand"
@ -76,28 +78,30 @@ func (s *seal) commit(t *testing.T, sb *sectorbuilder.SectorBuilder, done func()
}
func (s *seal) post(t *testing.T, sb *sectorbuilder.SectorBuilder) {
/*
// TODO: fixme
cSeed := [32]byte{0, 9, 2, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 45, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9}
cSeed := [32]byte{0, 9, 2, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 45, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9}
ssi := sectorbuilder.NewSortedPublicSectorInfo([]sectorbuilder.PublicSectorInfo{{
SectorID: s.sid,
CommR: s.pco.CommR,
}})
ssi := sectorbuilder.NewSortedPublicSectorInfo([]sectorbuilder.PublicSectorInfo{{
SectorID: s.sid,
CommR: s.pco.CommR,
}})
postProof, err := sb.GeneratePoSt(ssi, cSeed, []uint64{})
if err != nil {
t.Fatalf("%+v", err)
}
candndates, err := sb.GenerateEPostCandidates(ssi, cSeed, []uint64{})
if err != nil {
t.Fatalf("%+v", err)
}
ok, err := sectorbuilder.VerifyPost(context.TODO(), sb.SectorSize(), ssi, cSeed, postProof, []uint64{})
if err != nil {
t.Fatalf("%+v", err)
}
if !ok {
t.Fatal("bad post")
}
*/
postProof, err := sb.ComputeElectionPoSt(ssi, cSeed[:], candndates)
if err != nil {
t.Fatalf("%+v", err)
}
ok, err := sectorbuilder.VerifyPost(context.TODO(), sb.SectorSize(), ssi, cSeed[:], postProof, candndates, sb.Miner)
if err != nil {
t.Fatalf("%+v", err)
}
if !ok {
t.Fatal("bad post")
}
}
func TestSealAndVerify(t *testing.T) {
@ -126,6 +130,10 @@ func TestSealAndVerify(t *testing.T) {
}
cleanup := func() {
sb.Destroy()
if t.Failed() {
fmt.Printf("not removing %s\n", dir)
return
}
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}