From e075eb163fea3ce88b1cc19a085884595bb7f8dc Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Tue, 5 Nov 2019 17:22:16 -0800 Subject: [PATCH] Add a test for the sectorstore --- storage/sector/store_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/storage/sector/store_test.go b/storage/sector/store_test.go index 613f2836b..cf7fe5e0b 100644 --- a/storage/sector/store_test.go +++ b/storage/sector/store_test.go @@ -1,11 +1,17 @@ package sector import ( + "context" + "fmt" + "io" + "math/rand" "testing" "github.com/stretchr/testify/assert" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/lib/sectorbuilder" + "github.com/ipfs/go-datastore" ) func testFill(t *testing.T, n uint64, exp []uint64) { @@ -44,3 +50,33 @@ func TestFillersFromRem(t *testing.T) { } } + +func TestSectorStore(t *testing.T) { + if err := build.GetParams(true); err != nil { + t.Fatal(err) + } + + sb, cleanup, err := sectorbuilder.TempSectorbuilder(1024) + if err != nil { + t.Fatal(err) + } + defer cleanup() + + tktFn := func(context.Context) (*sectorbuilder.SealTicket, error) { + return §orbuilder.SealTicket{ + BlockHeight: 17, + TicketBytes: [32]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2}, + }, nil + } + + ds := datastore.NewMapDatastore() + + store := NewStore(sb, ds, tktFn) + + pr := io.LimitReader(rand.New(rand.NewSource(17)), 300) + sid, err := store.AddPiece("a", 300, pr, 1) + if err != nil { + t.Fatal(err) + } + fmt.Println(sid) +}