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

View File

@ -1,6 +1,8 @@
package sectorbuilder_test package sectorbuilder_test
import ( import (
"context"
"fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"math/rand" "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) { func (s *seal) post(t *testing.T, sb *sectorbuilder.SectorBuilder) {
/* 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}
// 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}
ssi := sectorbuilder.NewSortedPublicSectorInfo([]sectorbuilder.PublicSectorInfo{{ ssi := sectorbuilder.NewSortedPublicSectorInfo([]sectorbuilder.PublicSectorInfo{{
SectorID: s.sid, SectorID: s.sid,
CommR: s.pco.CommR, CommR: s.pco.CommR,
}}) }})
postProof, err := sb.GeneratePoSt(ssi, cSeed, []uint64{}) candndates, err := sb.GenerateEPostCandidates(ssi, cSeed, []uint64{})
if err != nil { if err != nil {
t.Fatalf("%+v", err) t.Fatalf("%+v", err)
} }
ok, err := sectorbuilder.VerifyPost(context.TODO(), sb.SectorSize(), ssi, cSeed, postProof, []uint64{}) postProof, err := sb.ComputeElectionPoSt(ssi, cSeed[:], candndates)
if err != nil { if err != nil {
t.Fatalf("%+v", err) t.Fatalf("%+v", err)
} }
if !ok {
t.Fatal("bad post") 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) { func TestSealAndVerify(t *testing.T) {
@ -126,6 +130,10 @@ func TestSealAndVerify(t *testing.T) {
} }
cleanup := func() { cleanup := func() {
sb.Destroy() sb.Destroy()
if t.Failed() {
fmt.Printf("not removing %s\n", dir)
return
}
if err := os.RemoveAll(dir); err != nil { if err := os.RemoveAll(dir); err != nil {
t.Error(err) t.Error(err)
} }