From 7a3ffbf9fef01180f48f65f38868f11fb0dd3478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 26 Nov 2019 00:31:34 +0100 Subject: [PATCH] WIP getting post in sectorbuilder_test to work --- lib/sectorbuilder/sectorbuilder.go | 4 +-- lib/sectorbuilder/sectorbuilder_test.go | 46 +++++++++++++++---------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/lib/sectorbuilder/sectorbuilder.go b/lib/sectorbuilder/sectorbuilder.go index 4299dd18d..6126db082 100644 --- a/lib/sectorbuilder/sectorbuilder.go +++ b/lib/sectorbuilder/sectorbuilder.go @@ -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 } diff --git a/lib/sectorbuilder/sectorbuilder_test.go b/lib/sectorbuilder/sectorbuilder_test.go index 15f8beeed..4f5c111fb 100644 --- a/lib/sectorbuilder/sectorbuilder_test.go +++ b/lib/sectorbuilder/sectorbuilder_test.go @@ -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) }