Add a test for the sectorstore

This commit is contained in:
whyrusleeping 2019-11-05 17:22:16 -08:00 committed by Łukasz Magiera
parent d615b7242a
commit e075eb163f

View File

@ -1,11 +1,17 @@
package sector package sector
import ( import (
"context"
"fmt"
"io"
"math/rand"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/lib/sectorbuilder" "github.com/filecoin-project/lotus/lib/sectorbuilder"
"github.com/ipfs/go-datastore"
) )
func testFill(t *testing.T, n uint64, exp []uint64) { 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 &sectorbuilder.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)
}